Right now I'm panning by glRotating before rendering everything, and i'm moving the camera by gltranslating. I feel as if this is wrong since im essentially moving the scene, not the camera. What is the proper way to move the camera?
Thanks
Right now I'm panning by glRotating before rendering everything, and i'm moving the camera by gltranslating. I feel as if this is wrong since im essentially moving the scene, not the camera. What is the proper way to move the camera?
Thanks
Actually 'moving the scene around the camera' is the proper way in OpenGL.
This is due to the fact that OpenGL combines the view and model matrices into the modelview matrix. (look here for more details)
Obvious the lookat function (as mentioned above) is an easy way to move a (virtual) camera but i found that it doesn't work for OpenGL3.
I'd suggest to use the excellent glm library to setup the transformation matrices for OpenGL3.
Kind Regards, Florian
Moving the scene and the camera is essentially the same thing. One being the negative of the other. The usual way of implementing it is to have a camera class with absolute coordinates and direction, then you just put
glTranslate(-camera)
glRotate(-camera)
at the top in your display function.