OpenGL textures copy last color used

Started by
2 comments, last by Daaark 16 years, 10 months ago
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.
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.


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
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.

This topic is closed to new replies.

Advertisement