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?