int LoadGLTextures() // Load Bitmaps And Convert To Textures
{
int Status=FALSE;
// Status Indicator
AUX_RGBImageRec *TextureImage[2]; // Create Storage Space For The Texture
memset(TextureImage,1,sizeof(void *)*2); // Set The Pointer To NULL
// Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit
if (TextureImage[0]=LoadBMP("Data/Mud.bmp"))
{
Status=TRUE; // Set The Status To TRUE
glGenTextures(3, &texture[0]); // Create Three Textures
// Create Nearest Filtered Texture
glBindTexture(GL_TEXTURE_2D, texture[0]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
// Create Linear Filtered Texture
glBindTexture(GL_TEXTURE_2D, texture[1]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
// Create MipMapped Texture
glBindTexture(GL_TEXTURE_2D, texture[2]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
}
if (TextureImage[0]) // If Texture Exists
{
if (TextureImage[0]->data) // If Texture Image Exists
{
free(TextureImage[0]->data); // Free The Texture Image Memory
}
free(TextureImage[0]); // Free The Image Structure
}
// Return The Status
return Status;
i have Question with Lesson 10
first, you should wrap that code you have in [ source ] [ /source ] tags.
second, could you rephrase your question, i have no clue what you are asking...
second, could you rephrase your question, i have no clue what you are asking...
- relpats_eht
perhaps something like this
then just use it like this
unsigned int tex1,tex2;
tex1=LoadGLTexture("texture1.bmp");
tex2=LoadGLTexture("texture2.bmp");
and then just call bind like this glBindTexture(GL_TEXTURE_2D, tex1);
and of cause i can not guarante that this code works, but it might be a hint on how to do it.
unsigned int LoadGLTexture(char filename[120]) // Load Bitmaps And Convert To Textures{ unsigned int texture; AUX_RGBImageRec *TextureImage=NULL; // Create Storage Space For The Texture // Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit if (TextureImage=LoadBMP(filename)) { glGenTextures(1, &texture); // Create Three Textures // Create MipMapped Texture glBindTexture(GL_TEXTURE_2D, texture); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST); gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage->sizeX, TextureImage->sizeY, GL_RGB, GL_UNSIGNED_BYTE, TextureImage->data); } if (TextureImage) // If Texture Exists { if (TextureImage->data) // If Texture Image Exists { free(TextureImage->data); // Free The Texture Image Memory } free(TextureImage); // Free The Image Structure } // Return The Status return texture; }
then just use it like this
unsigned int tex1,tex2;
tex1=LoadGLTexture("texture1.bmp");
tex2=LoadGLTexture("texture2.bmp");
and then just call bind like this glBindTexture(GL_TEXTURE_2D, tex1);
and of cause i can not guarante that this code works, but it might be a hint on how to do it.
www.flashbang.se | www.thegeekstate.com | nehe.gamedev.net | glAux fix for lesson 6 | [twitter]thegeekstate[/twitter]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement