我做了一个比赛场地,它会旋转180度。 不幸的是,你看不到它变得越来越慢。 我只看到最后的“扭曲”。如何制作一个OpenGl(GLUT)旋转动画?
/**
@brief Rotates the Gamefield 180° with an turn animaion
*/
void flipGamefield180degree(){
for (int i = 0; i < 180; i++){
glRotatef(1, 0, 1, 0);
glutPostRedisplay();
Sleep(20);
}
}
void display(void)
{
// Löscht den Bildschirm
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Zeichenfarbe setzen
glColor3f (1.0, 1.0, 1.0);
glLoadIdentity();
// _,_,_ wo steht die Kamera, _,_,_ wo hin, wo ist oben?
gluLookAt (0.0, 0.0, 10, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
// Rotation X-Achse
rotating(0);
// Rotation Y-Achse
rotating(1);
// Rotation Z-Achse
rotating(2);
if (flip180degree){
flipGamefield180degree();
}
/*glRotatef(15,0,1,0);
glRotatef(-15,1,0,0);
*/
glTranslatef(-5.5, -6 ,0);
glPushMatrix();
drawGameField(false, 10);
glPopMatrix();
glPushMatrix();
glTranslatef(11, 0 ,0);
glPushMatrix();
drawGameField(true, 10);
glPopMatrix();
glPopMatrix();
//drawShipOnField(s1, feldSpieler);
drawShipOnField(s1, feldSpieler);
//glDisable(GL_LIGHTING);
/*glColor3f(0, 0, 1);
glutSolidCube(1);
glEnable(GL_LIGHTING);*/
/* glTranslatef(5, 0, 0);
drawGameField(true, 10);*/
//glutSolidTeapot(1.0);
//glRotatef(30,1.0,0.0,0.0);
glFlush();
}
一个类似的问题,它为我工作[stackoverflow.com/questions/20396485/how-to-animate-a-rotation-triggered-by-a-key-in-opengl-and-glut](http:/ /stackoverflow.com/questions/20396485/how-to-animate-a-rotation-triggered-by-a-key-in-opengl-and-glut#) – 2017-05-08 10:11:09