OGL ignores glColor4f

Hello,

I tried to put the line :

glColor4f(1.0,0.0,0.0,0.9);

just after:

glBegin(GL_QUADS);

But still the quades are white… WHY???
Should I glEnable something?

I would be happy to get any ideas

Cheers,
Libby

Do you have texturing enabled?

Bad texture is rendered white.

Do you have lighting enabled, this may be undermining your efforts.

Thanks a lot,
But…
Now I comment out the line:

glEnable(GL_LIGHTING);

And it does display the colors, but it doesn’t display any light.

How can I have color AND light?

Libby

Hi Libby,
Enable GL_COLOR_MATERIAL, this uses your calls of glColor to set the material properties. Otherwise you will need to set up materials using glMaterial. For example:

glEnable(GL_LIGHTING);
glEnable(GL_COLOR_MATERIAL);
glColorMaterial(GL_FRONT, GL_DIFFUSE);
glColor4f(1, 0, 0, 1);

is the same as:

float diff[] = {1, 0, 0, 1};
glEnable(GL_LIGHTING);
glMaterialfv(GL_FRONT, GL_DIFFUSE, diff);

jimmi

Once you enable lighting you have two options to ensure your colour shows properly.

  1. Use glMaterial*() to specify colours.
  2. Use glEnable(GL_COLOR_MATERIAL) and glColorMaterial*(). Then your glColor*() calls will work.

Thanks Jimmie, You’re a genious! You made my day, now I can go home!

And thanks also to Furrage!