Understanding the camera and projection

Started by
1 comment, last by deadstar 14 years, 5 months ago
My OpenGL class is nearing its end and there are still some concepts I am confused about. Mainly, the camera and projection matrices. I don't get the difference between the following functions: gluLookAt gluPerspective glFrustum glOrtho And I don't understand when one should call: glMatrixMode(GL_MODELVIEW) glMatrixMode(GL_PROJECTION) I'm quite confused about the camera. First, even if you leave all OpenGL's transformation matrices to their default, you still have a certain point of view into space. In our first examples, we drew some primitives without any prior call to any of the aforementioned functions, and we could see them, so we still have a "camera", an eye at a certain position looking into 3d space in a certain direction, even without any call to gluLookAt, isn't it? Thanks for your explanations.
Advertisement
When OpenGL starts, the camera is in vert(0, 0, 0) position, looking at vert(0, 0, 1), and the up side is vert(0, 1, 0). Then if you draw a cube at vert(0, 0, 0), it's possible you won't see anything, becouse the camera is "inside" the cube. So you'll have to call glTranslatef(0, 0, 10) for seeing the cube.

gluLookAt: It's an improved function to change the projection view position, so you won't have to change the projection matrix by "hand".

gluPerspective: It's too an improved function to make glFrustum easier.

glOrtho: That function make the things appears in ortho view (you should read about this).

Well, sorry if I am wrong.
"There is no spoon."

There is no camera. When you set these matrices/transforms/rotations before calling glVertex, it merely sets up a state with some parameters ready to do some additional transformation on these vertices before they get rasterised.

It's a difficult concept to grasp, since you can create the mental illusion that there is this 'camera object' which you can move around the scene, but in the end it's all just maths.

Food for thought.

"The right, man, in the wrong, place, can make all the dif-fer-rence in the world..." - GMan, Half-Life 2

A blog of my SEGA Megadrive development adventures: http://www.bigevilcorporation.co.uk

This topic is closed to new replies.

Advertisement