Textures change geometry!

Started by
5 comments, last by virvelvinden 16 years ago
I've been doing the GLUT tutorials on Lighthouse and nehe's OpenGL tutorials for a while, and since the GLUT tutorials doesnt contain texture examples i used one of nehe's tutorials for texturing (the TGA example in lesson 32, i think). I've managed to load and display a 2d texture, which works fine except that my previously drawn geometry (couple of spheres) renders weird... For example, when I display a ground texture (brown), everything turns brown, with a sky texture (blue and white) everything becomes semi-transparent and blue, and with some textures containing alpha information everything turns black. It's always the last rendered texture that sets the "mode" btw, and the textures themselves looks normal... Thanks for any help!
Advertisement
You have to turn off texturing before you can draw something without a texture:

glDisable(GL_TEXTURE_2D);
Well, it works, but now the textures render with whatever color set in the last glColor3f(); !
Yes, that's how it's supposed to work. You set the color, and everything rendered after that will use that color until you set it to something different.
Oh ok, maybe I'll just ditch the non-textured things since everything will be textured later anyways... thanks for your help!
I think you're confused.

Do the following:

.. set up the texture, by opening the texture, and loading it into OpenGL

Then, in your display loop, call this:

glEnable(GL_TEXTURE_2D);

Once that is enabled, draw everything that requires a texture.

After, call:

glDisable (GL_TEXTURE_2D);

Now, draw all the geometry that doesn't require a texture, and they will be drawn with whatever color you specify with glColor* commands.
Thanks, I found that out myself... pretty obvious after all. And you're right I'm a bit confused, just trial&erroring my way through the tutorials to see what things I can get running... :D

This topic is closed to new replies.

Advertisement