Thursday, April 28, 2011

What are the usual troubleshooting steps for OpenGL textures not showing?

After making a few changes in my application, my textures are no longer showing. So far I've checked the following:

  • The camera direction hasn't changed.
  • I can see the vectors (when colored instead of textured).

Any usual suspects?

From stackoverflow
  • You may want to check the following:

    • glEnable(GL_TEXTURE_2D); presence

    • glBindTexture(GL_TEXTURE_2D, texture[i]); and glBindTexture(GL_TEXTURE_2D, 0); when you don't need texture anymore

    nbolton : Even though I had both these, the issue still wasn't resolved. After doing some heavy refactoring, it started working again. I suspect it was perhaps a translation issue, but thanks for the suggestions anyway; I have accepted this answer as it has the highest upvotes! :)
    Hooray Im Helping : I did have a problem with my textures, and calling `glEnable(GL_TEXTURE_2D);` fixed my problem. Thank you.
  • A few more things to check:

    • glColorMaterial(...); To make sure colors aren't overwriting the texture
    • glEnable/glDisable(GL_LIGHTING); Sometimes lighting can wash out the texture
    • glDisable(GL_BLEND); Make sure that you're not blending the texture out
    • Make sure the texture coordinates are set properly.
  • Does a glColor3ub(255,255,255) before rendering your textured object help? I think the default OpenGL state multiplies the current glColor by the incoming texel; a stray glColor3ub(0,0,0) will make all your textures look black.

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.