View Full Version : glColor3f(,,) wash out?

09-26-2006, 09:18 PM
Hello, I am a beginner OpenGL programer.
I am using the glColor3f function with a texture.
When I set the rgb to 1,1,1 it doesn't resault in a whited out texture. I see how this could be usefull in many cases, but in my project I would like to be able to make a 0,0,0 black and 1,1,1 to bw white and 0.5, 0.5, 0.5 to be the texture's original brightness.
Is there any way for openGL to do this? Or atleast the input of a value greater than 1,1,1 such as 2,2,2 to be brighter.

I hope this is a valid question.

09-27-2006, 02:30 AM
If you don't use shaders than you can only use color values in range <0;1>.
Read about glTexenv function - when you use it with GL_TEXTURE_ENV_MODE then you can specify how color (glColor) interacts with your texture.
If it's GL_MODULATE, then your texture is multiplied by color, so you get black when color is 0,0,0 and original texture when color is 1,1,1. If you use GL_ADD you have original texture with color set to 0,0,0 and white when color is set to 1,1,1.
So you can switch between GL_MODULATE/GL_ADD whenever you need darkened texture or brightened texture.
The problem is if you need both at the same time (on one polygon). Then you have two options:
1. Use GL_MODULATE and render darkened texture, and then disable texture, enable blending with glBlendFunc(GL_ONE, GL_ONE), and render polygon with color that should be added to your texture.
2. Create a 1D texture with linear filtering and 2 pixels: black and white. Use multitexturing - put your original texture to unit #0, and modulate it with glColor, and set texture unit #1 to add this 2-pixel texture to your modulated texture - by manipulating texture coordinate at unit #1 from center of first texel (0.25f) to center of second texel (0.75f) you can change the final color that is added.