static int day = 20;void mydisplay(void){ int a = clock(); glEnable(GL_DEPTH_TEST); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);//清空颜色缓存与深度缓存 glMatrixMode(GL_PROJECTION);//接下来要进行的操作(投影) glLoadIdentity();//将当前矩阵设置为单位阵 gluPerspective(75, 1, 1, 400000000);//设置可视空间 glMatrixMode(GL_MODELVIEW);//设置为模型视图与变换 glLoadIdentity(); gluLookAt(0, -200000000, 200000000, 0, 0, 0, 0, 0, 1);//观察点 //绘制 glColor3f(0.0f, 0.0f, 1.0f); glRotatef(day / 360.0*360.0, 0.0f, 0.0f, -1.0f); glTranslatef(150000000, 0.0f, 0.0f); glutSolidSphere(15945000, 20, 20); glutSwapBuffers();}void myidle(int v){ ++day; if (day >= 360)day = 0; mydisplay(); glutTimerFunc(10, myidle, 0);}int main(int argc, char *argv[]){ glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); glutInitWindowPosition(100, 100); glutInitWindowSize(400, 400); glutCreateWindow("旋转"); glutDisplayFunc(mydisplay); glutTimerFunc(10,myidle,0); glutMainLoop(); return 0;}