Query about Selection example in the Redbook

Dear All,

U can access the Redbook Chapter 12 (Selection) online at: http://fly.cc.fer.hr/~unreal/theredbook/chapter12.html

The selection example 12-2 has following code:

glPushMatrix ();
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glOrtho (0.0, 5.0, 0.0, 5.0, 0.0, 10.0);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity ();
//code for drawing objects
glPopMatrix ();
glFlush ();

My question is: If both GL_PROJECTION and GL_MODELVIEW are loaded with identity matrix
why the code is inside a glPush and glPop Matrix pair

Hope this question is understandable,

  • Chetan

As I can see from the code PushMatrix and PopMatrix contains modelview matrix. MatrixMode(PROJECTION) is called after PushMatrix so that means that the last was MODELVIEW. Doesn’t matter both of matrices are cleared. The modelview matrix is staying the same after PopMatrix when it was before PushMatrix.