Getting the modelview matrix

Hi there,
I’m absolutely a beginner, so sorry if the question is silly. What I’m trying to

do is quite simple: I’m trying to get the modelview matrix into an array of

doubles. After the following lines:

GLdouble matrix[4][4];
glGetDoublev(GL_MODELVIEW_MATRIX, &matrix[0][0]);

matrix should contain the identity matrix, but it will only contain garbage.

What am I doing wrong? The documentation states quite explicitly that glGet…()

returns the modelview matrix with the above parameter.


Very strange! I simply dumped this right after I reset
my MODELVIEW matrix to the identity and I get the
correct results

GLdouble matrix[4][4];
glGetDoublev(GL_MODELVIEW_MATRIX, &matrix[0][0]);
printf("%f, %f, %f, %f
printf("%f, %f, %f, %f
printf("%f, %f, %f, %f
printf("%f, %f, %f, %f

My setup: GNU/Linux (Slackware) 2.4.18, DRI MESA on Voodoo 3 for XFree86 4.2.

Why don’t you try to get an error code (errno) right
after the glGetDoublev ? This might help.

Define “garbage” and how are you accessing the members of the matrix array?

Also, life can be made a little simpler by just using a one dimensional 16 element array to store matrices for interaction with OGL.