Jump to content
  • Advertisement
Sign in to follow this  
virvelvinden

OpenGL Textures change geometry!

This topic is 3771 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'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!

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!