# GL Rotate problem

• 12-13-2001
Eber Kain
GL Rotate problem
I consider myself fluent in OpenGL. But I have hit a problem with a little demo I am working up to show how to do First Person with my GLH library.

I define a matrix for the transposed view.

m[16];

then i setup a routine to modify the matrix.

glTranslatef(x,0,speed);
glRotatef(pitch,1,0,0);
glRotatef(yaw,0,1,0);
glGetFloatv(GL_MODELVIEW_MATRIX,m);

then the draw code.

glMultMatrix(m);
//Draw terrain

the problem is that the pitch plane dose not move, so when i turn to the side, and try to look down the screen just spins, cause the pitch plane is focused to my side. It shouldn't do that when i load the matrix, rotate it, then save it back.

the order of the glRotatef()'s makes no difference.
• 12-14-2001
VirtualAce
I don't do OpenGL (don't have a OpenGL card) but are you transforming all of your vertices into aligned space?

The way I do it is to translate and rotate the object according to local space and then transform to world space. Then I clear the transformation matrix. Here is where I rotate, translate the viewer. Any rotations called after the initial transform and prior to the second transform affect the viewer's rotation and not the object's rotation.

But, I'm assuming you have done this already since you are very knowledgeable concerning 3D.

Are you absolutely sure the order does not make a diff? In my code, the order does make a diff. If you rotate on X before you rotate on Y it will not work. But again one call to rotate takes care of this in my code (Rotate(ax,ay,az)). Also the order in which the matrices are multiplied matters to (MatMult(mat1,mat2,result) is not the same as MatMult(mat2,mat1, result)), but since you are using OpenGL, this should already be correct.

I have had this happen to me before but I don't remember what was wrong.