View Full Version : Color mixed with texture

07-25-2012, 02:48 AM
My previous colors are mysteriously being mixed together with my texture. I first use glColor4f to produce a green and red (alpha) colors for some quads. Then i make a quad that holds just my texture. And from this, somehow the green from drawing previous quads has leaked onto the texture ?

I found two option, none of which work:


This successfully removes the leaked colors onto the textures, but now the textures fails to work with basic OGL lighting.

Using no glTexEnvi (Which is what OpenGL FAQ suggested i do in this situation)
This leaks the previous colors onto the texture, but now successfully works with basic OGL lighting.

07-25-2012, 06:02 AM
It sounds like you need glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE)
and set all the glMaterial parameters to white.

07-25-2012, 11:58 AM
Modulate produced the same results as REPLACE.

Setting glColor to white actually solves the problem :)

However, i'd like to know what the pipeline is the final color of each fragment in OpenGL.

Is it->

Final color = glColor*texture*lighting;

If so, is that why multiplying the glColor white (all 1's) has no effect on final color?

07-25-2012, 02:20 PM
If you had to use glColor instead of glMaterial, then you had enable material color tracking.
Yes, when your glTexEnv mode is MODULATE, then the final color is glColor*texture*lighting.

07-25-2012, 03:13 PM
I'v been using glColor always and instead of glMaterial, i dont know if thats a bad thing, but i haven't had any problems.
Normally i dont set any texture environment. Is MODULATE the same having the texture environment at default?

07-26-2012, 06:42 AM
I'm not saying that enabling color tracking is bad. I'm just saying that you had not indicated in your post so I said use glMaterial.
Yes, the default is MODULATE.
Overall, all this is ancient history and eventually, you should move to GL 3.3 or 4.0.