ModelView Matrix

Modeling is controled by the ModelView Matrix. Each vertex is transformed(multiplied) by the current ModelView Matrix as it is entered into the system by glVertex*(). This operation results in the vertice's final position in 3D space. The ModelView Matrix, is in turn manipulated by the transformation functions (glScale, glRotate & glTranslate). The transformation functions simply muliply the Modelview Matix (if it is currently selected) by an appropriate matrix representing the transformation.

This application illustrates the relationship between model and view transformations

MatrixMode

OpenGL maintains a small number(3) of Matrices controlling various parts of the rendering pipeline. Only one of these matrices can be current. All matrix operations(e.g. transfomations) are applied to the current Matrix. Therefore is is important that the ModelView Matrix is selected as the current matrix before modeling transformations begin. It is also a good idea to reset the modelview matrix to the identity matrix.

Matrix Stack

The ModelView Matrix stack is used to save the current ModelView matrix. This is commonly used to 'undo' a sequence of transformations.

glPushMatrix() will copy the current ModelView matrix to the top of the stack ('saving' the sequence of trasformation so far).

glPopMatrix() removes the matrix off the top of the stack and and uses it to replace the current ModelView matrix. The effect is to restore the sate of the Modelview Matrix as it was at the last glPushMatrix().

The same effect can be accomlished by perfoming a sequence of transformations reversing the existing transformations, but this is slow and leads to rounding errors.