Sign in to follow this  
Dr_Asik

OpenGL Understanding the camera and projection

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
"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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this