Graphics Reference
In-Depth Information
Figure 9.1. Docking texture parameters with the OpenGL system.
a texture identifier (an integer generated by glGenTextures( ) ; this is texA in
Figure 9.1) with a texture, you must set a number of texture parameters (such
as texture wrap and filter), and you must set the texture image parameters that
interpret the texture (color model, dimensions, size of texture component, and
texture data). This is illustrated in Figure 9.1, which shows how the usual set of
texture functions specify texture properties. The texture unit is the number of
the “docking port” in the graphics context, with default zero, and the texture
identifier, texA acts as a pointer to a specific area in GPU memory.
In a fixed-function program, you must also associate a texture name with
the texture identifier, enable textures, and specify the texture environment.
Overall, the setup for a single fixed-function texture that has been loaded into
an array texImage looks like this:
GLuint texA;
glGenTextures( 1, &texA );
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, texA );
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexImage3D(GL_TEXTURE_2D,0,GL_RGB8,TEX_WIDTH,TEX_HEIGHT,
0,GL_RGB,GL_UNSIGNED_BYTE,texImage);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND);
Search WWH ::




Custom Search