What is going on in the background with the pop and push operations?
when i do:
//viewing transformation glLoadIdentity(); glTranslatef(0,0,-7); glPushMatrix(); glScalef(1.5,1.5,1.5); glutWireTeapot(1); glPopMatrix(); glFlush(); //sends all pending information directly to the GPU
I know that it is taking the current modelview matrix and saving it in the stack of 32 matricies, and pop loads back the pushed matrix to be the current matrix.
But,lets say i had that tea pot, and the current model view matrix was translated(M). Then i pushed the matrix and then i scaled the matrix by 1.5 and drew my tea pot(S).
so my coordinates for the teapot are ©: one coordinate could be(1,2,3,1)
So my current matrix is right now is (MS)
So my teapot has been mapped to this matrix…MSc so the coordinate is now (2,4,6,1)
But then i pop and restore back to my old matrix…(M)
what happens to the coordinate? Why does it not pop back as well…
Or does it just take the current matrix
then save it into memory when i call glPush()
then does everything i want to do to the matrix, like glTranslatef(), or glRotatef()?
then when i gall glPopMatrix, it will multiply by the inverses of the matrices that glTranslatef(), or glRotatef() created and keep all of my coordinates the same?
Okay, the real question is! how does OpenGL restore matrices, and how does OpenGL find the new coordinate, in the ‘world plane’, for the coordinate that was within glPush and glPop?