views:

165

answers:

1

I have loaded an object, and when I draw the object, I set the color to green.. After drawing the object, I draw lines in red.

It all worked out fine. The problem arise when I input lighting properties. When I create a light source, everything where the light projects becomes white. Why does the lighting over writes my color? And how do I solve this problem?

Thanks in advance..

A: 

The code you have would help in diagnosing the problem. This sounds like a problem with setting up the materials for the items (which define how they interact with the lights).

You may want to look into the glColorMaterial function. The following snippet of code will set this up:

GLfloat mat_specular[] = {0.3, 0.3, 0.3, 1.0};
GLfloat mat_shininess[] = { 10.0 };
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);
Kyle Lutz