#### Archived

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

# Texture Problems

This topic is 5589 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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?

##### Share on other sites
PLEASE GUYS, i need help; I have been trying to solve this problem for over 2 weeks now, ..and i cannot waste anymore time.

##### Share on other sites
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.

Post some code.

##### Share on other sites
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.

##### Share on other sites
Step through Texture::LoadTexture line by line with a debugger and your problem should be obvious.

##### Share on other sites
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?

Thnx heaps.

##### Share on other sites
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]

##### Share on other sites
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.

1. 1
2. 2
JoeJ
20
3. 3
frob
19
4. 4
5. 5

• 10
• 10
• 12
• 13
• 9
• ### Forum Statistics

• Total Topics
632199
• Total Posts
3004736

×