moving camera around in opengl

Started by
0 comments, last by register 22 years, 4 months ago
This is propably a dumb question from a dumb person, but I would like to know how to move ''camera'' around in opengl? Or at least where to find explanation to that. I have studied some tutorials and sample code, but have learned (only) rotating and texture mapping. Thanks.
Advertisement
The first thing you need to understand is that there is no movable camera in OpenGL. Instead, there is a something that I call a cursor. The transformation functions like glRotate, glTranslate and glScale act upon the cursor, and the rendering functions, like glVertex3f(), take place at the cursor.

For example, to move the scene 100 units away from you on the z axis, you''d do glTranslatef(0.0, 0.0, -100.0f). Now, it is important to understand that the cursor has moved and not the camera. If you now do a glRotate, it is not the camera that rotates: instead the cursor rotates. That''s why, if you translate, rotate 180 degrees, and then draw an object, you can still see it: the object has rotated 180 degrees, not you.

Once you understand how transformation functions do their stuff, things should become clearer. The functions of immediate interest are the glRotate, glTranslate and glScale family of functions.

You also need to know about the matrices: glMatrixMode, glLoadIdentity and gluPerspective need to be used to set up the viewing and modelling matrices correctly.

Just Plain Wrong
CoV

This topic is closed to new replies.

Advertisement