# glGetFloatv(GL_MODELVIEW_MATRIX, mat) returns always the same matrix

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

## 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 on other sites
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 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 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

1. 1
2. 2
frob
15
3. 3
4. 4
Rutin
12
5. 5

• 13
• 12
• 58
• 14
• 15
• ### Forum Statistics

• Total Topics
632120
• Total Posts
3004220

×