Texturing problem
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;
}
//==============================================================
Are you trying to use display lists? If so, the scope of the texture is limited to the display list in which it was created.
no i''m not using display lists. One of the classes that it doesn''t work in uses vertex arrays but i''ve tested it in a class that has nothing but the info for the texture.
Have you tried rendering the object without the texture? Sorry if it seems a bit too obvious...
Oh, and is the rendering context valid and selected?
[edited by - Ferdinand the Bull on March 16, 2003 12:28:45 AM]
Oh, and is the rendering context valid and selected?
[edited by - Ferdinand the Bull on March 16, 2003 12:28:45 AM]
I have tried to render w/o the tex and it gives me the same white square. as for the rendering context, do i have to make it current beforehand since it''s in a class or does it stay valid once it is created?
I have tried to render w/o the tex and it gives me the same white square. as for the rendering context, do i have to make it current beforehand since it''s in a class or does it stay valid once it is created?
i have experienced a similar anomaly with accessing textures from external files. although i have a global id variable to track the texture id''s AND the file with the actual declaration of this variable contains codde to initialize the texture.
whenever i attempt to bind the textures from an external file (yes, i did declare extern for the id''s), the texture doesnt get applied. but attempting to bind the texture on the same source file seems to work.. any ideas?
it may be my error on some part, but will look into again later tonight
whenever i attempt to bind the textures from an external file (yes, i did declare extern for the id''s), the texture doesnt get applied. but attempting to bind the texture on the same source file seems to work.. any ideas?
it may be my error on some part, but will look into again later tonight
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement