views:

69

answers:

1

Trying to get a grasp on lights and working through the OpenGL Superbible book. Below is what I am currently using for my lighting. It's placed in the SetupRC function.

The lighting is mostly working as I expected as per position etc but I am confused on why when I turn the camera, it gets brighter on places where it was previously darker. I have not moved the camera position's but the light still moves.

Why is this? Sort of confused here.

    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
+2  A: 

The reflected lights has a direction, set by the normal to the surface.
The position of the light, surface and camera affect how much light the camera sees.

Or possibly see http://stackoverflow.com/questions/1917776/opengl-lighting-problem-when-rotating-the-camera

Martin Beckett
What do you mean by "reflected lights"? The amount of light I am seeing on the surfaces (a cube in this case).I just want spotlight lighting at the moment.
bobber205