- openGL and JOGL Contents / Previous / Next


Steps in Texture Mapping

  1. Set texture environment parameter (if not common for all texture, this has to be done later):
     gl.glTexEnvf( .... );
    
  2. Read the texture into main memory (usually from a file) into a ByteBuffer.
    
    
    
  3. Create texture object(s), one ID for each texture we want in texture memory:
     gl.glGenTextures( ... );
    
  4. Specify a texture for an object and load the texture from client memory (main memory) into OpenGL's texture memory:
     gl.glBindTexture( ... );  // Set current texture.
     gl.glTexImage2D( ... );
     OR
     glu.gluBuild2DMipmaps(  ... )
    
  5. Set the textures' parameter:
     gl.glBindTexture( ... );  // Set current texture.
     gl.glTexParameteri( ... );
    
  6. Enable texture mapping:
     gl.glEnable( GL.GL_TEXTURE_2D );
    
  7. Indicate how the texture is to be applied to each pixel Draw the scene, supplying both texture and geometric coordinates:
     gl.glBindTexture( ... );  // Set current texture.
    
    	gl.glTexCoord2f( .. );
    	gl.glVertex3f( .. );
    	gl.glTexCoord2f( .. );
    	gl.glVertex3f( .. );
    
  8. Delete texture from texture memory (maybe disable textureing):
     gl.glDeleteTextures( ... );
     gl.glDisable( ... );