Sign in to follow this  

OpenGL textures copy last color used

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

This topic is 3843 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this