After having tried to figure out why the hell my textures weren’t affected I found out it was caused by setting GL_REPLACE with glTexEnv by commenting it out.
As I’ve learned previously from one of my earlier question is this used to prevent the modulating of textures with any previously drawn texture/colors.
Now, my question is will this result in modulation again (I can’t see it quite well from my scene) ? If so, how can I combine these two settings?
Please don’t be shy of writing a big piece of text. Every little bit of information is welcome and can very well be used by this newbie.
The lighting appears to cause another problem:
As you can see is the bottom plane a tad dark-grey-ish, while it is supposed to be red.
I’ve tested it without lighting and it’s nice and red there.
Please, does anyone know what this could be?
glTexEnv is used to define the behavior of how a polygon has a texture applied.
GL_MODULATE (the default) causes it to modulte with the color of that polygon. Lighting affects the color of the polygon, so if you want a textured object to be affected by lighting, you have to use this mode.
GL_REPLACE causes the texture to just replace the color (and thus any lighting effects.)
Generally, if you use GL_MODULATE, you set the color to be white, unless you want another color to be modulated.
If you are using lighting, however, you set material properties with glMaterial to determine the color, not glColor. (You can use glColor if you enable GL_COLOR_MATERIAL, but that just causes glColor to affect the material properties.)
Thanks, the colored polygons get their color now.
Textures modulate with the last painted color now, but that is solved by setting the color back to white.
Is the only way to solve this to set the color back to white after having drawn the colored polygon, or is there another setting for it?
oh, and another thing… how can I prevent a COLOR to modulate with a texture?
Yes, the only way to do that is to set it back to white. That is because OpenGL is a state machine. The color stays what you set it until you set it to something else. Think of it as setting global variables.
currentColor = yellow;
You wouldn’t expect Object2 to be drawn with white because you never set currentColor to white again.
The same thing goes for the texture environment settings. If you want some drawn with GL_MODULATE and some with GL_REPLACE, you need to explicitly set the mode before you draw those objects.
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);