Texture Problems

Started by
8 comments, last by Smokey97 20 years, 11 months ago
Hey, i seem to be having a weird problem with OpenGL inside SDL. I load the texture and create mipmaps and what not, now here''s the problem: I enable GL_TEXTURE_2D, i bind the texture, and map a quad (for example). Now everyhting should work (and it does if i do the exact same thing in Win32 API), BUT it doesent, it just shows a white quad... I also cannot see fnots if i try to use them in SDL. I know it''s an SDL pproblem because i have tryed the exact same code with Win32 API and it works fine... Any ideas on what is happening? or better yet, how i could fix it?
Advertisement
PLEASE GUYS, i need help; I have been trying to solve this problem for over 2 weeks now, ..and i cannot waste anymore time.
Don''t be so fast to blame SDL. Just because the code works under Win32 doesn''t mean SDL is broken. Do you have a rendering context at the time you create your texture?
No, i didnt.

But i tryed loading the texture once i had a rendering context, and it made no difference, still just a white quad.
Post some code.
i knocked up a qick test program....

http://bansheeforcestudios.digitalexplosions.com/test.cpp

This is driving me crazy, there is no reason why it shouldnt show these textures, but it doesent...

This totaly has me stumped.
Step through Texture::LoadTexture line by line with a debugger and your problem should be obvious.
I saw one fairly big problem, textureType was being set to 6204 or something because apparently GL_RGB wasent defined, but i fixed that, BUT it still doesent work...

Do you know what the problem actualy is?
If so, PLEASE tell me.

Thnx heaps.
Did you run the code through a debugger as I told you to do?

Take this switch-statement as an example. It's the second of the three in Texture::LoadTexture. This one illustrates the problem best but all three have the same problem.

    switch(TT) {    case TGA_Type:        textureType = GL_RGB;        if(pImage->channels == 4) textureType = GL_RGBA;	        gluBuild2DMipmaps(GL_TEXTURE_2D, pImage->channels, pImage->sizeX, pImage->sizeY, textureType, GL_UNSIGNED_BYTE, pImage->data);		        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR);    break;    case BMP_Type:        //    break;}    

What is the value of TT? Is it really TGA_Type, which is the only value that will create the texture?

EDIT: Here's a hint. This is where you call Texture::LoadTexture.

  texture.LoadTexture("face.bmp", "TEST", BMP_Type);                                           ^                                           |                                           |  


[edited by - Brother Bob on May 3, 2003 11:10:35 PM]
Ya, that was a type, it should be something like texture.LoadTexture("Image.tga", "TEST", TGA_Type);


but guys, dont worry thnx heaps for helping.

My problem was a mix of loading the texture when there was no rendering context (like the first person said...) and i was initializing SDL incorrectly.

Once again, thank you for all your help.

This topic is closed to new replies.

Advertisement