Jump to content
  • Advertisement


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


i'm lost rotating a light source...

This topic is 5401 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

I''m trying to have a light on an object, but when I rotate the object the light moves because it isn''t rotating. I know this must seem simple for you guys, but can somebody show me how to pass a light source through the rotation matrix so it stays on the same spot of my model? Thanks

Share this post

Link to post
Share on other sites
when you call glLightfv(GL_LIGHTx,GL_POSITION,...); the position you pass in will be multiplied by the current modelview matrix. So the place where you call glLight is critical (and therefor you must call it at least once a frame. So. the best place to make the call is usually right after you setup your camera. But if you want to move around with your model, then you should set the lights position either right after you do the glMultMatrix/glRotate/glWhatever for setting your model position (and then just set the light pos as if it were a vertex on the model) - but this means everything rendererd before the model will have a potentially wrong light position (out by one frame) - so, it''s better in this case to manually mult the light position you want by the matrix of the model (or just do the rotations again) and set the position after you set the camera.
The same thing applies to pretty much everything you can set a position/direction to in GL.

I have 999 posts. hmm.

| - My project website - | - email me - |

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!