Transformations

Projection vs ModelView

The perspective or orthographic projection is also a transformation.

In theory, there are three basic transformations being applied:

OpenGL treats the View & Model transformations as one - the GL_MODELVIEW transformation.

The Projection and ModelView are stored separately. But, both of them can be affected by the same commands. So, you have to explicitly switch between the two.

/* Control the Projection */
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(50.0, 1.0, 1.0, 100.0);

/* Control the Model / View */
glMatrixMode(GL_MODELVIEW);

glLoadIdentity();
glTranslatef(0.0, 0.0, -8.0);
glRotatef(viewRotX, 1.0, 0.0, 0.0);
glRotatef(viewRotY, 0.0, 1.0, 0.0);





next