Lighting w/ OpenGL

Started by
2 comments, last by GameDev.net 24 years, 6 months ago
Hello DavidM

First of all you have to enable lighting with a call to "glEnable(GL_LIGHTING)".

Then you should set up your light/s with calls to "glLight".

To enable a light you have to call "glEnable(GL_LIGHT0)" to enable light 0.

VirtualNext

Advertisement
Okay, I have figured it out roughly, and I know I need to call glLight, but I don't know what the w value of a vector is for. If you set GL_LIGHT_POSITION for a light to

(x, y, z, 0) then it will be at which I understand, and it will be directional (since w=0) What does w do if w != 0?

Thanks, .... David

I've been using OpenGL a bit in my free time, but I haven't been able to figure out how the lighting system works. I have looked at some sample code, and at the Win32 API Help file, but I can't figure it out.

Thanks.

Hello DavidM

If the w component of the position is 0.0, the light is treated as a directional source. Diffuse and specular lighting calculations take the lights direction, but not its actual position, into account, and attenuation is disabled. Otherwise, diffuse and specular lighting calculations are based on the actual location of the light in eye coordinates, and attenuation is enabled.


P.S.: This is from the OpenGL online documentation.

VirtualNext

This topic is closed to new replies.

Advertisement