Game Development Reference
In-Depth Information
//Set height repeat option
if (heightRepeat){
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
}else{
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
}
//Set scaling functions to fastest possible
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
GL_NEAREST);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_NEAREST);
//Set enviroment option to modulate with surface colour
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
if (useMipMaps){
gluBuild2DMipmaps (GL_TEXTURE_2D, //target
GL_RGB, //components
pic.GetWidth(), //width
pic.GetHeight(), //height
GL_BGR_EXT, //format
GL_UNSIGNED_BYTE, //type
pic.GetBitsAddress());//data
}else{
glTexImage2D(GL_TEXTURE_2D, //target
0, //level
GL_RGB, //components
pic.GetWidth(), //width
pic.GetHeight(), //height
0, //border
GL_BGR_EXT, //format
GL_UNSIGNED_BYTE, //type
pic.GetBitsAddress());//data
}
When working with textures in OpenGL, you must delete any that you
have finished using. This is done using a call to
glDeleteTextures(1, &texID);
If your texture IDs are stored in an array of integers, then you can delete
several textures in one function call.
Search Nedrilad ::




Custom Search