Contents / Previous / Next


The Texture Matrix Stack

Just as your model coordinates are transformed by a matrix before being rendered, texture coordinates are multiplied by a 4x4 matrix before any texture mapping occurs.

By default, the texture matrix is the identity, so the texture coordinates you explicitly assign or those that are automatically generated remain unchanged. By modifying the texture matrix while redrawing an object, however, you can make the texture slide over the surface, rotate around it, stretch and shrink, or any combination of the three. In fact, since the texture matrix is a completely general 4x4 matrix, effects such as perspective can be achieved.

All the standard matrix-manipulation commands such as glPushMatrix(), glPopMatrix(), glMultMatrix(), and glRotate*() can be applied to the texture matrix. To modify the current texture matrix, you need to set the matrix mode to GL_TEXTURE, as follows:

  glMatrixMode( GL_TEXTURE ); // enter texture matrix mode
  glRotated(...); 
  // ... other matrix manipulations ...
  glMatrixMode( GL_MODELVIEW ); // back to modelview mode