View Full Version : Confused with lighting effects

03-19-2008, 05:27 AM
Hello, I am new to OpenGL. I am currently having problems with lighting.

I have a cube at the origin and have a light at X=1.0,Y=1.0,Z=1.0

The problem is, the reflection of the light is too much. By too much I mean that it covers the entire face of my cube.

I will be attaching my code so that you may see what I am talking about and hopefully, have a solution for my problem.

Here is the link: piano.c (http://bloodfire1004.angelfire.com/piano.c)

You can rotate the cube by using X,Y,and Z. Thank you for your time!

03-19-2008, 07:41 AM
This would be the problem: glScalef (1.5,1.0,0.35);

Scaling requires normals to be normalized for correct lighting because they are transformed by the inverse transpose modelview matrix.
Add glEnable(GL_NORMALIZE) during the init phase.

If that's not fixing it, you probably have not enough geometric detail inside the cube to show nice highlights. That lighting is done per-vertex.

Described in the very first two pitfalls of this list:

03-19-2008, 05:23 PM
That fixed my problem!!! Thank you very much!!!