Jump to content
  • Advertisement
Sign in to follow this  

glGetFloatv(GL_MODELVIEW_MATRIX, mat) returns always the same matrix

This topic is 3317 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, strange problem, and i am not the first with it. I have the following code:
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glRotatef(orientation[ 1 ], 0, 1, 0);

float mvm[16];
glGetFloatv(GL_MODELVIEW_MATRIX, mvm);

if (debugCounter++ %100 == 0) {
	printf("player:orientation: %f\n", orientation[1]);
	printf("player:mvm: \n"); matrix_dump(mvm); printf("\n\n"); fflush(NULL);
}

renderChildren();

glMatrixMode(GL_MODELVIEW);
glPopMatrix();

resulting in the following output:
player:orientation: -13.000000
player:mvm:
     -0.00      0.37     -0.93      0.00
      0.00      0.93      0.37      0.00
      1.00      0.00     -0.00      0.00
      0.00     -0.05    -10.02      1.00


player:orientation: -83.300011
player:mvm:
      0.00      0.37     -0.93      0.00
      0.00      0.93      0.37      0.00
      1.00     -0.00      0.00      0.00
     -0.00     -0.06    -10.03      1.00

How can this be? Two different rotations, that should lead to different modelview matrices, but dont. (best thing is, that the rendered scene is affected by the roation!) What could be the problem? Any workaround? BR, Janosch

Share this post


Link to post
Share on other sites
Advertisement
Ok, reading my post, i think i found the problem:
I have to call glLoadIdentity before any modifications of the matrix.

Doing this however, destroys my rendering, but thats an other problem i guess :)

Share this post


Link to post
Share on other sites
Oh no, using glLoadIdentity is not a feasible solution. I need the information of the current matrix combined with the modifications at the time i call glGetFloatv.

Share this post


Link to post
Share on other sites
Wow, now that was a nice problem. I shot myself through my knee in my chest!
I am positioning the camera always behind my player, looking in the direction, my player is looking. So in the end, turning the player wont change the modelview matrix. (i think it only changes the projection matrix)
Not that my problem is solved now, but i am a step further.

I leave this thread for everyones amusement here :D

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!