1 / 12

OpenGL Transformation

OpenGL Transformation. Jian-Liang Lin 2002. Transformation -1. Transformation -2. There are three matrix stacks in OpenGL architecture MODELVIEW, PROJECTION, TEXTURE glMatrixMode( GLenum mode ); mode: GL_MODELVIEW, GL_PROJECTION, GL_TEXTURE

jerica
Download Presentation

OpenGL Transformation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. OpenGL Transformation Jian-Liang Lin 2002

  2. Transformation -1

  3. Transformation -2 • There are three matrix stacks in OpenGL architecture • MODELVIEW, PROJECTION, TEXTURE • glMatrixMode( GLenum mode ); • mode: GL_MODELVIEW, GL_PROJECTION, GL_TEXTURE • Current matrix mode is also a OpenGL state variable.

  4. Transformation -3 • Matrix Manipulation • glLoadIdentity(); • glLoadMatrix{f,d}( const TYPE* m ); • glMultMatrix{f,d}( const TYPE* m ); • glPushMatrix(); • glPopMatrix(); • Stack operation of matrix is very useful for constructing a hierarchical structures. • Ex: Render a car with four wheels.

  5. Transformation -4 • OpenGL built-in transformation: • glTranslate{f,d}( TYPE x, TYPE, y, TYPE z ); • Multiply a translation matrix into current matrix stack • glRotate{f,d}( TYPE angle, TYPE x, TYPE y, TYPE z ); • Multiply a rotation matrix about an arbitrary axis into current matrix stack • glScale{f,d}( TYPE x, TYPE y, TYPE z ); • Multiply a scaling matrix into current matrix stack

  6. Transformation -5 • Viewing transformation • Choose your viewing system • Center-orientation-up system • Apply gluLookAt Utility routine. • gluLookAt( cx, cy, cz, cx+ox, cy+oy, cz+oz, upx, upy, upz ); • ( cx, cy, cz ) is the center of the camera • ( ox, oy, oz ) is the orientation vector of the camera • ( upx, upy, upz ) is the up vector of the camera • Polar coordinate system • Combine translation and two rotation. • …

  7. Transformation -6 • Projection transformation: Perspective projection • glFrustum( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far );

  8. Transformation -7 • gluPerspective( GLdouble fovy, GLdouble aspect, GLdouble near, GLdouble far );

  9. Transformation -8 • Projection transformation: Orthogonal projection • glOrtho( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far ); • gluOrtho2D( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top ); • A helper to create a 2D projection matrix

  10. Transformation -9 • Viewport transformation • glViewport( GLint x, GLint y, GLsizei w, GLsizei h ); • Initial viewport is as the same size as the window

  11. Transformation -10 • Note: • By default, the viewpoint as well as objects in the scene are originally situated at the origin, and is looking down the negative z-axis, and has the positive y-axis as straight up.

  12. Any Question? ?

More Related