storing the modelview matrix?


I am trying to make my 3D world rotate using the ‘crystal sphere’ method, using a mouse drag… and it works just fine except that when I’m done with the mouse drag the modelview matrix I transformed is not stored for the next draw and I can’t work out why!

The final part of my transform is;

rot = (float)((180/PI)sqrt(dxdx+dydy+dz*dz)/sqrt(R2));

*w1 = m[0]*a1 + m[1]*a2 + m[2]*a3;
*w2 = m[4]*a1 + m[5]*a2 + m[6]*a3;
*w3 = m[8]*a1 + m[9]*a2 + m[10]*a3;

After doing the glLoadIdentity(); in the draw loop I assumed glRotatef(rot, w1, w2, w3); would alter the matrix so that the next drag would alter it further yet it doesn’t seem to work.

I know the maths is right but how do I make the new matrix my curent modelview matrix? Cheers.

Ummm… Something like this?

GLfloat m[16]; // your custom MW matrix

glLoadMatrixf( m ); // use ‘m’ as MW matrix
glMultMatrixf( m ); // multiply current MW with ‘m’