keeping modelview matrix constant ????


I displayed a 3D object in a MFC window.In my application, i am getting the x,y and z point of the object at the mouse clicked point in the initial stage.But when i rotate the object then the z value is changing.In the display function i push and pop the model view matrix and in mouse left button down i read the model view matrix.If any way to get the initial model view matrix when i click on the object ??

where is the chance for problem ??


If you want the model view matrix after you rotate, you’ll have to do a glGet before you do a glPopMatrix(). If not then the matrix should be where you want it and you can get it any time.

If you’re going to be doing this alot, you should consider keeping your own copy of the modelview matrix and doing your own matrix transformations mirroring what you do in OpenGL. This will avoid expensive calls to glGet() because you can just read your own copy of the matrix.