Jump to content
  • Advertisement
Sign in to follow this  
Access2

OpenGL textures copy last color used

This topic is 4125 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

Hello, Why is it that, when you draw a shape (say, a polygon) in openGL, and then you draw a textured object, the textured object will be have a hint of the color I used on the shape i drew before? for example, if i do this: glBegin(GL_QUADS) //code for drawing a red polygon glEnd(); now, I enable texturing, and draw another polygon but with the texture of a preloaded bitmap- glBindTexture(bla.bmp) glBegin(GL_QUADS) //code for drawing a textured polygon glEnd(); Result: The second polygon which is textured, will have a hint of red surrounding it! Why is this? and how can i stop that from happening? thank you so much.

Share this post


Link to post
Share on other sites
Advertisement
Because your still using that color. Set your color back to 1.0f,1.0f,1.0f,1.0f before drawing the textured object.

OpenGL is a state machine, and anything you set stays set until you set it to something else.

Share this post


Link to post
Share on other sites


Thanks very much. I had thought that setting it to 1.0f,1.0f,1.0f would just color it a hint of white. But i've tried it out and instead it loads fine.

Many spanks

Share this post


Link to post
Share on other sites
Quote:
Original post by Access2


Thanks very much. I had thought that setting it to 1.0f,1.0f,1.0f would just color it a hint of white. But i've tried it out and instead it loads fine.

Many spanks
The default texture blending mode adds or modulates on top of the polygon's existing color.. This allows lighting or vertex colors to tint the texture. There is another texturing mode called GL_REPLACE that will just put the texture on, and disregard whatever color the polygon is beforehand.

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!