PDA

View Full Version : OGL ignores glColor4f



Libby
04-22-2002, 05:58 AM
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

dorbie
04-22-2002, 06:06 AM
Do you have texturing enabled?

Bad texture is rendered white.

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

Libby
04-22-2002, 06:31 AM
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

jimmi
04-22-2002, 07:18 AM
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

Furrage
04-22-2002, 07:23 AM
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.

Libby
04-22-2002, 07:34 AM
Thanks Jimmie, You're a genious! You made my day, now I can go home!

Libby
04-22-2002, 07:35 AM
And thanks also to Furrage!