PDA

View Full Version : Query about Selection example in the Redbook



virtualchetan
08-22-2003, 06:24 AM
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

yaro_dup1
08-22-2003, 08:38 AM
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.