Lecture18-OpenGL-Misc

Lecture18-OpenGL-Misc - CS 455 Computer Graphics More...

Info iconThis preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 455 – Computer Graphics More OpenGL
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Matrix Operations   • OpenGL has 4 matrices it uses: GL_MODELVIEW - contains the composite modeling and viewing matrices GL_PROJECTION - contains a matrix for the projection transformation GL_TEXTURE - used for performing operations on the texture (stretching, moving,  rotating, etc.) GL_COLOR - used for color space conversions Make sure the appropriate matrix is current when you do modeling, viewing, or projections
Background image of page 2
Setting the Current Matrix   void glMatrixMode(Glenum mode); sets the current matrix to be mode mode is GL_MODELVIEW, GL_PROJECTION , GL_TEXTURE , or GL_COLOR
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Loading the Current Matrix   void glLoadMatrix{fd}( TYPE *m) loads the array m of TYPE GLfloat or GLdouble to the current matrix
Background image of page 4
Multiplying the Current Matrix   void glMultMatrix{fd}(TYPE *m) Postmultiplies the current matrix by m , which is of TYPE GLfloat or GLdouble
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Transformations   • Translation: void glTranslate{fd}( TYPE dx, TYPE dy, TYPE dz) TYPE is GLfloat or GLdouble The translation is applied to the current matrix – make sure the appropriate matrix is current, e.g., glMatrixMode(GL_MODELVIEW); glTranslate(0.3, 0.2, 1.5); Distances are in world coordinates
Background image of page 6
Transformations   • Rotation: void glRotate{fd}(TYPE angle, TYPE dx, TYPE dy, TYPE dz) rotates angle about the axis given by (dx, dy, dz) and the origin TYPE is GLfloat or GLdouble
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Transformations   • Scale: void glScale{fd}( TYPE sx, TYPE sy, TYPE sz) scales about the origin by (sx, sy, sz) TYPE is GLfloat or GLdouble
Background image of page 8
Viewing - parallel Setting an orthographic view glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar) produces a parallel projection with the clipping volume being [left, right]  in the x direction,  [bottom, top]  in the  y direction, and  [zNear, zFar]  in the z direction • Only objects falling in this region will be drawn • make sure you call  glMatrixMode (GL_PROJECTION); and usually   glLoadIdentity(); prior to calling glOrtho()
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Viewing - perspective Setting a perspective view gluPerspective (GLdouble fovy, GLdouble aspect GLdouble near, GLdouble far) fovy  is the angle of the field of view in the x-z plane,  and must be between 0 and 180. aspect  is the aspect ratio (width / height)  near  is the distance from the viewpoint to the near  clipping plane (always positive)  far  is the distance from the viewpoint to the far  clipping plane (always positive)  
Background image of page 10
Camera Set-Up   • Used to specify camera position and parameters void gluLookAt( GLdouble eyex, GLdouble eyey, GLdouble eyez, GLdouble atx, GLdouble aty, GLdouble atz, GLdouble upx, GLdouble upy, GLdouble upz) The eye point (eyex, eyey, eyez) is the lookFrom point The at point (atx, aty, atz)
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 41

Lecture18-OpenGL-Misc - CS 455 Computer Graphics More...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online