Everyframe light position updation

Started by
2 comments, last by nail85 21 years ago
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
    UpdatePositionOfThisLight;
  
I think that this is not fastest and optimal way. Have anybody any ideas?
Advertisement
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?


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.
Than you have to multiple each frame every light with ogl matrix.


This topic is closed to new replies.

Advertisement