Trying to understand the light and work through the OpenGL Superbible book. Below I use this for lighting. It is placed in the SetupRC function.
The lighting basically works as I expected, depending on the position, etc., but I'm confused about why, when I turn the camera, it gets brighter in places where it used to be darker. I did not move the position of the camera, but the light was still moving.
Why is this? Here is a bit of embarrassment.
GLfloat ambient[] = { 0.7f, 0.7f, 0.7f, 0.5f };
GLfloat diffuse[] = { 1.0, 1.0f, 1.0f, 1.0f };
glEnable(GL_LIGHTING);
glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
glEnable(GL_LIGHT0);
GLfloat ambientLight[] = {1.0f, 0.0f, 1.0f, 0.5f};
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientLight);
glEnable(GL_COLOR_MATERIAL);
glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE); //GL_AMBIENT_AND_DIFFUSE
source
share