I have the following code:
void setupCamera() {
// Clear the screen buffer
glClear(GL_COLOR_BUFFER_BIT);
// reset the projection matrix //
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
// and set the perspective with the current field of view,
// and the current height and width
gluPerspective(fov, ratio, objDepth - objRadius * 2,
objDepth + objRadius * 2);
glViewport(0, 0, WINDOW_SIZE, WINDOW_SIZE);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
if(first){
glMultMatrixf(rotMatrix);
}
first = true;
//translate everything to be in objDepth//
glTranslatef(initX * 0.01, initY * 0.01, (-1) * objDepth);
glRotatef(200 * angle, rotationVector[0], rotationVector[1],
rotationVector[2]);
glutWireTeapot(1.5);
glGetFloatv (GL_MODELVIEW_MATRIX, rotMatrix);
}
The rotation vector holds the rotation axis,
translate is used for moving all to the correct position.
the thing is, I am using glMultMatrixf
in order to use the last matrix saved,
do rotation and then translation, and then save the matrix again with glGetFloatv
.
this function is constantly called with timer, but for some reason
I can't figure out, the matrix wont save anything and always be initialized over and over,
meaning rotation is always used with small angles(because matrix isn't saved).
the saved matrix is not being used anywhere else in the code.
Any idea's?