Jump to content
  • Advertisement
Sign in to follow this  
Mad_Koder

OpenGL Transformations Help

This topic is 4360 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

I have some questions. (1)I am verry confused about the transformations, I understand first Opengl Sets where the camera is for the Projection Transformation and then uses Modeling transformation to move the trasformed coordinate system before everytime you draw something, I know about as much on ModelView transformation as George Bush knows what he is doing being president in the first place, I dont even know the different between ModelView and Modeling transformation. I know Projection transformation sets either Orthoview or Perspective as projection , and last viewport maps the scene to a window. Can someone tell me a good article on just How the insiside of this works , Or explain it (2) Can someone explain in depth from the begining about glMatrixMode( GL_MODELVIEW && GL_PROJECTION) , and how glLoad_Identity() loads the current martix? (3) Lastly ( duh duh duh ), Can someone verry in depth explain glPopMatrix() && glPushMatrix() work or give me a link to a tutorial. I couldn't find in depth on this subject. Thanks, I know its a lot to answer but by answering three questions , you could save a poor kids life, its not like you dont wanna answer , you just would rather do it later, but pick up the mouse and start typing now, a poor kid you see on the comercials from poor countries needs your help... ( dont take that seriously, I dont wnt the Children Christian Fund Association to sue me) Really, Thanks a ton ~Mad_Koder

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Mad_Koder
I have some questions.

(1)I am verry confused about the transformations, I understand first Opengl Sets where the camera is for the Projection Transformation and then uses Modeling transformation to move the trasformed coordinate system before everytime you draw something, I know about as much on ModelView transformation as George Bush knows what he is doing being president in the first place, I dont even know the different between ModelView and Modeling transformation. I know Projection transformation sets either Orthoview or Perspective as projection , and last viewport maps the scene to a window. Can someone tell me a good article on just How the insiside of this works , Or explain it


Modelview represets both the camera and the object position. It defines the relationship between them; the transform between model space and view space. Remember that in opengl, the transform functions are called in the opposite order that you want them to be applied to the vertex data. This means that you first define the world to view part of the modelview transform. One common method is to use the gluLookAt function for this.

Next you apply the model to world portion of the transform. This is usually done using the glTranslate, glRotate, and glScale functions. Usually you want to apply them to the vertex data in the following order: scale, rotate, translate. Since you must call the opengl calls in the reverse order you would call glTranslate, glRotate, and then glScale.

The projection matrix controls how the view space is projected into a unit cube. With ortho projection, a rectangular region of view space is projected into the cube. This does not have the perspective distortion. A perspective projection projects a frustum (a flat topped pyramid) into the cube. This results in a distortion that makes objects closer to the view point appear larger. The viewport function maps this 3d post projection space to a 2d portion of the screen. (I simplified this a little bit, if you want more details you may want to do a search on the rendering pipeline and take a look at the opengl spec).


Quote:

(2) Can someone explain in depth from the begining about glMatrixMode( GL_MODELVIEW && GL_PROJECTION) , and how glLoad_Identity() loads the current martix?


Opengl maintains several seperate matrices (modelview, projection, texture, etc.) glMatrixMode selects the one you want to modify. Modelview is the default. Once you set the matrix mode, all matrix functions will modify the selected matrix until you change the mode to something else.

glLoadIdentity resets the selected matrix to the identity matrix. The identity matrix will have no effect on the vertices. Since many other matrix functions concatenate a new transformation onto the existing matrix, reseting it will remove the old transformations and let you start over.

Quote:

(3) Lastly ( duh duh duh ), Can someone verry in depth explain glPopMatrix() && glPushMatrix() work or give me a link to a tutorial. I couldn't find in depth on this subject.


Check the redbook at opengl.org or the opengl spec. There has also been at least one thread on this topic recently in this forum, so you might want to check that. In short, push saves a copy of the matrix onto the matrix stack. Pop lets you restore this matrix. This means you can set up the world to view transform and then save it on the stack before you add the model to world transform for an object. Then, after drawing the object, you can use pop to restore the camera transform without haveing to regenerate it from scratch.

This can also be useful when implementing a scene graph (check google if you want, lots on scene graphs out there). You simply do a depth first traversal and push when you go down the tree and pop when you come back up.

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!