Archived

This topic is now archived and is closed to further replies.

Leroy1891

Texturing problem

Recommended Posts

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; } //==============================================================

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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?

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites