Docsity

OpenGL Programming II: Lecture 34 - Matrix Transformations and Clear Buffer, Slides of Computer Graphics

Partial preview of the text

Download OpenGL Programming II: Lecture 34 - Matrix Transformations and Clear Buffer and more Slides Computer Graphics in PDF only on Docsity!

Computer

Graphics

Lecture 34

OpenGL

Programming II

This program first sets

perspective projection

matrix and then renders

a triangle in the โ€œidleโ€

function.

glMatrixMode

Value Meaning GL_MODELVIEW Applies subsequent matrix GL_PROJECTION Applies subsequent matrix operations to the projection matrix stack. GL_TEXTURE Applies subsequent matrix operations to the texture matrix stack.

glMatrixMode function sets the current matrix mode.

The following function retrieves information related to glMatrixMode:

glLoadIdentity

void glLoadIdentity( void );

glLoadIdentity function replaces the current matrix with the identity matrix. It is semantically equivalent to calling glLoadMatrix with the identity matrix.

Error code Condition GL_INVALID_OPE RATION

glLoadIdentity was called between a call to glBegin and the corresponding call to glEnd.

glTranslated,

glTranslatef

glTranslate function produces the translation specified by ( x , y , z ). The translation vector is used to compute a 4x translation matrix:

If the matrix mode is either GL_MODELVIEW or GL_PROJECTION, all objects drawn after glTranslate is called are translated.

Use glPushMatrix and glPopMatrix to save and restore the untranslated coordinate system.

The following is the error code and its condition.

Error code Condition GL_INVALID_O PERATION

glTranslate was called between a call to glBegin and the corresponding call to glEnd.