Model View Matrix Value when using MFC

I am developing opengl application using MFC.
I am having a problem while getting the value (array) of model view matrix.
In opengl window, i dont see any problem.

but in MFC window when i execute following command i get garbage values.

glGetDoublev( GL_MODELVIEW_MATRIX,m_dmodelview);

It doesnt return the actual modelview matrix array ( that is changed when scene is drawn)

Is it because i am rendering my scene in picture box of MFC dialog.
If yes, please let me know what should i do.


The OpenGL calls assume a certain context when running so if you’re calling glGetDouble, you need to make sure it’s being called in the context of the correct OpenGL state.

For example, if an app has two OpenGL windows, it will have two contexts and each call to glGetDouble will depend on which window you’re calling it from.

I would recommend calling glGetDoublev in your display call and saving it off somewhere. Then when you want it, you can just read from that location instead of actually querying from OpenGL when you’re outside of an OpenGL context.

thanks a lot… that was the problem… i fixed it.