I\'m implementing a simple camera system in OpenGL. I set up gluPerspective under the projection matrix and then use gluLookAt on the ModelView matrix. After this I have my main
glRotate()
rotates the ModelView Matrix around the World Origin, so to rotate around some arbitrary point, you need to translate your matrix to have that point at the origin, rotate and then translate back to where you started.
I think what you need is this
float x, y, z;//point you want to rotate around
glTranslatef(0,0,view.forwardSpeed*deltaTime); //move forwards
glTranslatef(x,y,z); //translate to origin
glRotatef(view.angularSpeed*deltaTime,0,1,0); //rotate
glTranslatef(-x,-y,-z); //translate back
//draw our vertices
draw();
//swap buffers
Swap_Buffers();
I think you first have to translate your camera to point (0,0,0) then rotate, then translate it back.
Swap your rotate and translate calls around :)
Since they post-multiply the matrix stack the last the be called is the 'first' to be applied conceptually, if you care about that sort of thing.