PDA

View Full Version : glGetFloatv(GL_MODELVIEW_MATRIX, m)



starman
06-19-2003, 04:09 AM
Which matrix is put in m, the one that was pushed on the matrix stack, or the one with the translation and rotation applied to it:

glPushMatrix();
glRotatef(30.0f, 0., 1., 0.);
glTranslatef(100.0f, 0., 0.);
float m[16];
glGetFloatv(GL_MODELVIEW_MATRIX, m);
glPopMatrix();

I have code similar to this and m contains all zeros except for m[15], which contains 1.0. Any ideas?

Deiussum
06-19-2003, 04:16 AM
The current one. In this case, the one with the Rotate and translate.

M/\dm/\n
06-19-2003, 04:41 AM
& if you had trans & rot's before pushing they are in the m too!

starman
06-19-2003, 06:07 AM
I think I figured out my problem (unfortunately, I'm at work and my code is at home :< ). This is a planet/moon system, and my camera orbits along with one of the moons. Well, the "eye" and "look" parameters to gluLookAt are calculated from the moon and planet positions, which aren't initialized (and that's the bug). So eye and look are both zero vectors, making the initial modelview matrix after gluLookAt() all zeros. Thus, subsequent transformations don't do anything, and when I get the planet and moon's new positions after the translate/rotate, they're still zero vectors and the cycle continues. All I need to do is intialize the planet and moon positions.

Learning the hard way is still learning, right? ;-)


[This message has been edited by starman (edited 06-19-2003).]