directly retrieving modelview matrix?

Hello.
I have a ready code where I manipulate a 3D body - rotate/translate with mouse/keys. it looks like that:

void My DrawCallBack()
{
if (first_time)
glLoadIdentity();
else
glPopMatrix();
retrieve_transformation_delta(parameters…);
delta_transform(parameters…);
draw_body();
glPushMatrix();
}

so with each key pressed or mouse movement/event - the body moves along.

The problem is that the first transformation applied is the delta_transform, then the rest (inherited by glPopMatrx), resulting in body rotating around its own axes, and not around the screen axes.

as a solution I’m trying to retrtieve the delta_transform matrix and reverse the order:


glLoadIdentity();
retrieve_delta(…);
delta_transform(…)
glGetDoublev(GL_MODELVIEW_MATRIX,mymatrix_pointer);
glPopMatrix();
reverse_multiply(current and mymatrix);
draw_body();
glPushMatrix();

I get access violation error ;
Am I allowed to retrieve and manipulate the matrix directly?
Is there a more elegant way of reversing the order?

Thanks in advance.
Runner.

hm…what type is mymatrix_pointer?
it should be

GLdouble mymatrix_pointer[4][4];

or

GLdouble mymatrix_pointer[16];

Thanks for the reply.

I tried both :
GLDouble * current_matrix[4][4];
or
GLDouble * current_matrix[16];

then
glMultMatrix(current_matrix[0][0])
or
glMultMatrix(current_matrix[0])
( void glMultMatrix(GLDouble * param)
but I still get access violation error.

the compiler generates no errors, the violation error appers after the program starts.

Thanks again.

I see my mistake now.
Instead of creating a pointer to the glmatrix ( which I can not modify) I create my own matrix:
GLDouble matrix[16] ;

Now the access violation error is gone.

Thanks for the help.