(Windows98, DevStudio, nVidia TNT2)
I am using this snippet of code (taken from a FAQ) to translate clicks on the screen/window to world coordinates:
GLdouble mvmatrix, projmatrix;
GLdouble wx, wy, wz;
glGetIntegerv (GL_VIEWPORT, viewport);
glGetDoublev (GL_MODELVIEW_MATRIX, mvmatrix);
glGetDoublev (GL_PROJECTION_MATRIX, projmatrix);
realy = viewport - (GLint) ScrY - 1;
gluUnProject( (GLdouble)ScrX, (GLdouble) realy, 1.0, mvmatrix, projmatrix, viewport, &wx, &wy, &wz);
I do initialize the float arrays (code not shown here) for the matrices to set values and, after tracing through the calls which attempt to get the various matrices in the debugger, their values have NOT changed. I get zero, zip, nada results from any of the glGet calls.
This code is in a function that is called on a WM_TIMER message to the WndProc, is there a restriction of some sort on where the glGet* functions can be called from? Is there a particular pitfall to using the glGet* calls to get matrices? Do I have to activate a rendering context or something similar before they will work? Is there perhaps other code that can be called immediately before this that will cause the calls to not return a result?
I am not calling the glGet’s from within a glBegin/glEnd pair either.
Thanks for any help.