Obtaining the modelview matrix

What structure do I have to use to get the modelview matrix by glGetDoublev. I have tried this one:

 GLdouble *mat;

 mat = new GLdouble[16];
 glGetDoublev(GL_MODELVIEW_MATRIX, mat);

but it didn’t work, then I also tried this:

 GLdouble mat[16];

 glGetDoublev(GL_MODELVIEW_MATRIX, mat);

What do I have to do?

could u poast some more code you are using around the glGetDoublev


I hope this helps with your program. I am working with the same call on my program right now. This is what I am using, so maybe if would work for you also.

GLdouble modelMatrix[15];
for (int i = 0; i < 16; i++)
modelMatrix[i] = 0;
glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix);

A couple of things: before you get the matrix you need to push it, because getting it takes the top matrix off the stack (not just copies it), also, I think you need to initialize the variable that you are passing it into. Good luck, I hope this helps.

Hi folks.

I found out what it was. You have to call the glutCreateWindow() first. What is this function does that makes it work?

Besides, you don’t need to initialize your variable, nor do need to push the matrix.

Thanx, anyway.

[This message has been edited by martinjy (edited 05-29-2001).]

Before any openGL function can be used, the pixelformat of the window has to be setup to use OpenGL. glutCreateWindow does that for you, thus, you have to do that before any of your gl* calls will be valid.