Jump to content
  • Advertisement


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


Everyframe light position updation

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

In my engine i have camera and light classes. Light class has function like this
void Light::SetPosition(Vector3& v)
  mPosition = v;
  if (mbEnabled)
    glLightfv(GL_LIGHT0 + mID, GL_POSITION, v);
And I have function Camera::UpdateView, wich loads view matrix to OpenGL. Well, I change position of my camera every frame - it moves, but all light are also moves with the camera. Heh, this is itresting effect, but I don''t want to get it. So I need update my Camera::UpdateView and add lines like this
for each light in scene
  if it enabled
I think that this is not fastest and optimal way. Have anybody any ideas?

Share this post

Link to post
Share on other sites
When you use glLightfv(GL_LIGHT0 + mID, GL_POSITION, v);
the lights position is calculated with actual modelview matrix.
I wonder of useing only vector3 for light pos. What is 4. corrdinate?

Share this post

Link to post
Share on other sites
This was sample, actualy I use 4D vectors with w=1 (point light).
And I want OpenGL automaticly multiplies light''s position with modelview matrix every frame. This was my question.

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!