tags:

views:

97

answers:

3

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

+1  A: 

gluLookAt is how you move the camera.

thyrgle
What about to pan?
Milo
@Milo: You can pan it with gluLookAt too.
thyrgle
That's a link to Python bindings doc. [Here are C API docs.](http://www.opengl.org/sdk/docs/man/xhtml/gluLookAt.xml)
Craig McQueen
@Craig McQueen: Thnx for the link.
thyrgle
+1  A: 

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

Florian
A: 

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.

takoi