I have a small problem when I set a light to act as a sun in my scene of objects.
I’ve put the light at some coordinates but when I rotate the scene (including the light) even a bit, the following thing happens:
http://img194.imageshack.us/gal.php?g=beforexf.jpg
Do you have any idea why this is happening ?
In initOpenGl I set the light
{
glEnable(GL_LIGHTING);
glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
}
and then in renderScene I have
{
// Some global trasformations (rotation,translation, etc).
glLightfv(GL_LIGHT0, GL_POSITION, light_position0);
// draw objects
}
The light parameters are basically the default ones :
GLfloat light_position0[] = { 15, 15, 0, 1.0 };
GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 };
GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 };