Legacy (immediate mode)GL 1.0

glMatrixMode

Chose which built-in matrix stack (model-view or projection) the old matrix calls changed.

Removed from the core profile. Part of the legacy immediate mode, removed from the core profile in OpenGL 3.2. Shown here only so you can recognize it in old tutorials — use VBOs and VAOs instead.

Signature

void glMatrixMode(GLenum mode);

How it works

Old OpenGL kept the matrices itself. glMatrixMode(GL_PROJECTION) then glFrustum or glOrtho set the camera lens; glMatrixMode(GL_MODELVIEW) then glTranslatef, glRotatef and glScalef moved objects. Modern OpenGL has none of this: you build the matrices yourself (usually with GLM) and send them to the shader with glUniformMatrix4fv, where gl_Position = projection * view * model * position.

Parameters

modeGLenum

GL_MODELVIEW, GL_PROJECTION or GL_TEXTURE.

Example

example.cpp
1// Legacy
2glMatrixMode(GL_MODELVIEW);
3glLoadIdentity();
4glTranslatef(0.0f, 0.0f, -5.0f);
5glRotatef(angle, 0.0f, 1.0f, 0.0f);