Jump to content

  • Log In with Google      Sign In   
  • Create Account


Lighting w/ OpenGL


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 22 September 1999 - 09:27 PM

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.


Sponsor:

#2 VirtualNext   Members   -  Reputation: 122

Like
Likes
Like

Posted 22 September 1999 - 01:03 AM

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


#3 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 22 September 1999 - 06:53 PM

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


#4 VirtualNext   Members   -  Reputation: 122

Like
Likes
Like

Posted 22 September 1999 - 09:27 PM

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





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS