Lighting problem


I drew two yellow polygons parallel to the axis Z. Both are looking toward the positive X axis. The problem is: when the light is close to the polygon A, it becomes dark yellow. Otherwise, when the light is close to the polygon B, it becomes light yellow, as I expected. I tried to change the normal vector of the polygon A to (-1, 0, 0) and it seems to work,i.e., hen the light is close it, it becomes light yellow. I cannot figure out why the behavior is completely different for polygon A and B. What am I missing ?

I attached a small program to show what I am talking about: the “r” key rotates the light and the arrows move the camera.



You called:

glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);

in your code. Last argument should be {0,0,0,1}, because light position is transformed by Modelview matrix.
(set by glTranslate and glRotate before call to glLightfv)

That´s it !

Thanks a lot.