Jump to content
  • Advertisement
Sign in to follow this  
Dr_Asik

OpenGL Understanding the camera and projection

This topic is 3177 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
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.

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!