Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

PsyVision

Lighting

This topic is 6235 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hey, I was having a few problems with my lighting, i have included a light into my little scene. Although the problem is the light moves as the camera does even with a glPushMatrix/glPopMatrix. How can i stop this ?

Share this post


Link to post
Share on other sites
Advertisement
If you set the light location in your init code and does not change it later should it be fix. Treat the light position like a normal vertex position.

Share this post


Link to post
Share on other sites
info on whats happening can be found here http://www.frii.com/~martz/oglfaq/ section 18

http://members.xoom.com/myBollux

Share this post


Link to post
Share on other sites
You have to set your Light-Position every Frame !

Pseudo-Code:

DrawScene()
{
glRotatef(Cam.CamRotX,1.0f,0,0);
glRotatef(360.0f - Cam.CamRotY,0,1.0f,0);

glTranslatef(-Cam.CamXPos, -Cam.CamYPos, -Cam.CamZPos);

glLightfv(GL_LIGHT1, GL_POSITION, LightPosition); // Position The Light
}

In this Code the Light is Rotated and Tranlated too, and so
it has a "fix" position in the world.

Share this post


Link to post
Share on other sites
quote:
Original post by Crash_Kid
You have to set your Light-Position every Frame !


No, take a look at the faq.

quote:

Pseudo-Code:

DrawScene()
{
glRotatef(Cam.CamRotX,1.0f,0,0);
glRotatef(360.0f - Cam.CamRotY,0,1.0f,0);

glTranslatef(-Cam.CamXPos, -Cam.CamYPos, -Cam.CamZPos);

glLightfv(GL_LIGHT1, GL_POSITION, LightPosition); // Position The Light
}

In this Code the Light is Rotated and Tranlated too, and so
it has a "fix" position in the world.

Yes, but he did not want it to move with (be fix to) the camera. The desired result is a light that is fix relative to the absolute (global) coordinate system.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!