I implement a simple camera system in OpenGL. I set up gluPerspective under the projection matrix and then used gluLookAt in the ModelView matrix. After that, I have my main rendering cycle, which checks for keyboard events and, if any arrow key is pressed, changes angular and forward speeds (I just rotate through the y axis and move through z (forward)). Then I move the view using the following code (deltaTime is the time elapsed since the last frame was displayed in seconds to separate the movement from the frame rate):
newTime = RunTime();
deltaTime = newTime - time;
time = newTime;
glRotatef(view.angularSpeed*deltaTime,0,1,0);
glTranslatef(0,0,view.forwardSpeed*deltaTime);
draw();
Swap_Buffers();
Then the code repeats again. My drawing algorithm starts with glPushMatrix()and ends with glPopMatrix().
glRotatef() glTranslatef() .
, , , , (0,0,0 - Z) ( ), , (0,0,0), .
(0,0,0) .
glLoadIdentity() , , Matrix GL_MODELVIEW .
- glLoadIdentity() draw() ( PushMatrix PopMatrix, , , , .
- , , (0,0,0) , ?