Jump to content
  • Advertisement
Sign in to follow this  
Greywhind

OpenGL Last texture loaded doesn't display

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I apologize if this question has been asked before - I did search the web and this forum before posting, but I might have missed it. Please forgive me if that is the case. I'm using SDL + OpenGL for 2D, loading textures through an SDL surface and then drawing them with OpenGL quads. I've run into a strange problem. The last texture I load (we'll call it tex1) refuses to draw itself, although OpenGL tells me it loaded correctly and the dimensions, etc. are all correct. I've found that if I load another texture (which we'll call tex2) after loading tex1, then tex1 will draw correctly, but tex2 will not. This is true even if i then delete tex2. But if I use glBindTexture to bind any other texture to GL_TEXTURE_2D at least once before loading tex2, tex1 never draws even after tex2 is loaded. It doesn't matter what image files I try to load. Has anyone seen something like this before, and if so, what can be done to solve it? If you need my image-loading/texture binding code, I'll post it.

Share this post


Link to post
Share on other sites
Advertisement
I seem to have solved the problem - apparently, I need to call

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

after loading the texture.

I was calling this code inside the texture-loading routine, but apparently it needed to be called again.

Share this post


Link to post
Share on other sites
only need to call it once, at the end of your load texture function.

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

Share this post


Link to post
Share on other sites
Heh. You're right - I should have realized that. I was calling it in my load function a couple of lines too early.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!