Jump to content
  • Advertisement
Sign in to follow this  
Blips

OpenGL Odd texture filtering issue

This topic is 2639 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'm approaching completion on my first OpenGL ES game (yay!) but just recently ran into an odd issue with texture filtering. I was trying to improve the game's performance when linear filtering suddenly broke. Code when creating textures was this:


glGenTextures(1, &textureID);
glBindTexture(GL_TEXTURE_2D, textureID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);


But now, I'm having to set the texture parameters when binding textures and rendering geometry. Is this normal and was it just a fluke that it was working before?

Share this post


Link to post
Share on other sites
Advertisement

You only need to set it once for each texture.


So why is it not working unless I re-set it during rendering?

Share this post


Link to post
Share on other sites
Unbind the texture after you are done creating it to make sure you are not accidentally changing its properties later.

glBindTexture( GL_TEXTURE_2D, 0 );


L. Spiro

Share this post


Link to post
Share on other sites

Unbind the texture after you are done creating it to make sure you are not accidentally changing its properties later.

glBindTexture( GL_TEXTURE_2D, 0 );

L. Spiro


Sorry, I forgot to include that line. I already was / am doing that.

Share this post


Link to post
Share on other sites
Search your project for GL_TEXTURE_MIN_FILTER and check every location where you are calling that.

After you have set the GL_TEXTURE_MIN_FILTER property on your texture, you do not need to change it. Therefore you need to focus your search on where you are re-binding that texture (unintentionally) and changing its GL_TEXTURE_MIN_FILTER.
Check every location where you use GL_TEXTURE_MIN_FILTER, and be sure of exactly which texture is bound. It may not be the one you think.


L. Spiro

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!