Next: (Typically) Modelview Transformations:
Up: OpenGL Quick Reference Guide
Previous: Display lists:
Transformations and Perspective
OpenGL provides three different matrices: modelview,
projection, and texture (used in texture mapping). Actually,
these matrices are maintained in three stacks. This allows you to push
(save) the existing matrix on the stack, apply some new local
transformations, draw some vertices under this transformation, and then
pop the stack thus restoring the existing transformation. At any time
one of the three matrices is active and is set by glMatrixMode().
Note that the transformation that has been multiplied last is the one
that is applied first to the object vertices.
- glViewport(GLint x, GLint y, GLsizei width, GLsizei height):
Sets the current viewport, that is, the portion of the window
to which everything will be clipped. Typically this is the
entire window: glViewport(0, 0, win_width, win_height),
and hence this should be called whenever the window is reshaped.
- glMatrixMode(GLenum mode):
Set the current matrix mode to one of GL_MODELVIEW,
GL_PROJECTION, or GL_TEXTURE. The default is
- Set the current matrix to the identity.
- Make a copy of the current matrix and
push it onto the stack.
- Pop the top of the current matrix.
- glLoadMatrixf(const GLfloat *M):
- Sets the current matrix to
- glMultMatrixf(const GLfloat *M):
- Composes the current matrix
Note: The matrices in the last two calls are stored as 4 x 4
homogeneous matrices in column-major order. Thus, each matrix is an
array of 16 elements. The first 4 elements are the image of the
x-unit vector, the second 4 are the image of the y-unit vector and
Please report any errors or send comments to
Last updated: Sat, Feb 8, 2003.