Entire object is affected by highlight, not just a single polygon

I’m working though the OpenGL Programming Guide and I have run into a slight problem.

I rendering a torus (page 258) using a positional light.

When I rotate the torus around its axis I would expect a highligh to move across the torus as the light is reflected into the viewport. However the entire object dims as it rotates until it is completely dark at around 180 degrees. It starts brighting again as it approaches 0 degrees.

I am not rotating the light along with the object as I have only replaced the code that creates the ‘OpenGL gears’ (from the OpenGL grears example) with the code to create the torus.

I use the standard GL_LIGHT0 and the default settings.

I use (glMaterialfv GL_FRONT GL_AMBIENT_AND_DIFFUSE red) for the torus.

The torus is created using a GL_QUAD_STRIP.

I set (glShadeModel GL_SMOOTH) before glBegin(GL_QUAD_STRIP);

Anyone have any hints as to what may be going on ?

Proper lighting is dependent on normals being normal/perpindicular and unit length = 1 to the surface. You can either use 1 normal per vertex or 1 normal per face or a mix dependent on smoothness of the surface you are trying to emulate or jaggedness.

You have to calculate normals for each of your vertices/faces. If you do not know how to calulate normals look at Appendix E page 663 of OpenGL Programming Guide. Default normal is 0,0,1 the reason for your odd lighting behavior.

[This message has been edited by shinpaughp (edited 05-07-2003).]

Originally posted by shinpaughp:
You have to calculate normals for each of your vertices/faces.

Ah. So what’s happening now is that the value for the first vertex is being applied over all vertices ?