Jump to content

  • Log In with Google      Sign In   
  • Create Account

moving camera around in opengl


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 register   Members   -  Reputation: 122

Like
Likes
Like

Posted 28 November 2001 - 06:24 AM

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.

Sponsor:

#2 Mayrel   Members   -  Reputation: 348

Like
Likes
Like

Posted 28 November 2001 - 06:31 AM

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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS