PDA

View Full Version : Obtaining the modelview matrix



martinjy
05-29-2001, 07:31 AM
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?

DaViper
05-29-2001, 07:51 AM
could u poast some more code you are using around the glGetDoublev


Chris

Merlin257
05-29-2001, 08:37 AM
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.

glPushMatrix();
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.

martinjy
05-29-2001, 09:08 AM
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).]

Deiussum
05-29-2001, 10:36 AM
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.