help me on lighting!!!


I put a QUAD in the space and textured a image onto it, so that it looks like a background. I also put a cube on the space and disable the depth test, the code is like:

put a Quad
mapping texture
disable depth test
put a cube
enable texture

now I want to give some light effect on it so that I can simulate daytime and nighttime.
question is:

what kind of light I should put on?
how to light it?
how can I set a nomal to object?
once I set a nomal to object, how opengl keep it?

thanks lot



Try ambient light. It simulates the daylight/nightlight effect. For some directional light effect add some diffuse light as well.

Set its position in 3D space and then finaly call


where 0<<MAXLIGHTS supported by your board. Atleast 8 are supported anyway so o<<7

you also need to enable lighting by calling


to set a normal to object for eq your quad…

use glNormal3f(x,y,z); to specify the noral vector to the quad and then call glVertex3f(x,y,z) for the quad…

Also try out NEHE’s or someother opengl tutorials on lighting. They halp you a lot.

try for nehe OpenGL tutorials.

Hope this helps