View Full Version : Not sure what's wrong

07-08-2003, 07:35 AM
I have a problem with lighting

If i change the view to the other side of the wall the normals are not defined.

if key=1
else if key=2
side =side2

draw ()
If view = side 1
normal nx,ny,nz
normal -nx,-ny,-nz

this is my logic

only side 1 is working. the value of 'side' changes. but no change in normals

where i went wrong?

Also do i have to specify glNormal() inside GLbegin or outside??


07-08-2003, 08:08 AM
OpenGL does not figure out which side of a face is front by the normals at the vertices (there is no face normal!), but through the order in which the vertices are given.
glFrontFace default is counter clockwise GL_CCW.

To get the face lit from the backside you either need to change both, normal direction and vertex order, or you need to change the frontface winding direction and invert the normal, or you'll need to enable two sided lighting, disable face culling, and set back materials, too. OpenGL will invert the normal for you in case it finds a backfacing polygon and use the back material to light it.

If you have only one normal for all vertices it's better to put it before the glBegin.

[This message has been edited by Relic (edited 07-08-2003).]