Original Post
I know that this question has been asked about 400 times but none of the other posts seem to help. I have a texture class that can load and bind a bitmap but it only works when it is global. when it is part of another class the textures load fine but don''t bind. Texturing is enabled and all BMP loading happens at the very end of the window creation code.
//==============================================================
void Textures::Bind()
{
glBindTexture(GL_TEXTURE_2D,TexName);
}
//==============================================================
bool Textures::LoadFromBMP(char* Filename)
{
FILE *File;
if(!Filename)
return FALSE;
File=fopen(Filename,"r");
if (File)
{
fclose(File);
Data=auxDIBImageLoad(Filename);
glGenTextures(1, &TexName);
glBindTexture(GL_TEXTURE_2D, TexName);
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,Data->sizeX,Data->sizeY, GL_RGB, GL_UNSIGNED_BYTE,Data->data);
}
else
return FALSE;
TexEmpty=FALSE;
TexHeight=Data->sizeY;
TexWidth=Data->sizeX;
TexDepth=3;
TexPixels=TexHeight*TexWidth;
return TRUE;
}
//==============================================================