Why use glMatrixMode and what is GL_PROJECTION and GL_MODELVIEW? When should I use it?

glMatrixMode is used to specify which matrix mode you are currently using. You have the selection of GL_PROJECTION, GL_MODELVIEW, and GL_TEXTURE.

The projection matrix is used to specify how vertices are projected onto the viewport. Typicaly setup with gluPerspective. N.B. The projection matrix should NOT be used to store camera transformations in!

The modelview matrix is where you store your object and camera manipulations in.

The texture matrix is used for applying matrix operations upon the orientation of textures. If you’re not really using this, you want to make sure it’s always set to the Identity (default)