Archived

This topic is now archived and is closed to further replies.

Maxwan

gl_lighting & glcolor3f

Recommended Posts

Just a simpel question. Is it possible to use gl_lighting and glcolor3f at the same time. I would like to have my quads in a specific color and then change the light, but, when I enable the gl_lighting all the colors turns to white.. I use a ambient ligth to light the whole world.

Share this post


Link to post
Share on other sites
Thanks for the help. However, I didnt understand it all and need some more help now. My code looks like this:

glEnable(GL_LIGHTING);
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);
glLightfv(GL_LIGHT1, GL_AMBIENT, ambient_light);
glEnable(GL_LIGHT1);

Okey, I have a landshape with colored ground. In a function ambient_light is lowered.
I would like this code to fade everything from their first color into black... But it dosent work the way I would like it to do. I looks more like the glcolor3f values is changing.. aaagh, it''s hard to explain, but it dosent work the way I would like it to work, thats for sure. If I disable the GL_COLOR_MATERIAL the fading-effect works the way I would like it to, but then ofcourse, no colors. I hope this makes sense and someone can help me =)

Share this post


Link to post
Share on other sites
Try
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);

Make sure you set the current material's ambient and specular colour to black too.

float black[4]={0,0,0,0};
glMaterialfv(GL_FRONT,GL_AMBIENT,black);
glMaterialfv(GL_FRONT,GL_SPECULAR,black);

[edited by - benjamin bunny on May 5, 2003 6:29:15 PM]

Share this post


Link to post
Share on other sites