PDA

View Full Version : help me on lighting!!!



huangzl99
09-27-2001, 01:49 PM
hi,

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

Jerry


what

Fastian
09-28-2001, 12:52 AM
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

glEnable(GL_LIGHT*)

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

you also need to enable lighting by calling

glEnable(GL_LIGHTING);

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 nehe.gamedev.net for nehe OpenGL tutorials.

Hope this helps

Fastian