#include<GL/glut.h>
float angle;
void display()
{
glEnable(GL_DEPTH_TEST);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(angle,0,1,0);
glPushMatrix();
glTranslatef(0,0.3,0);//往上移動
glColor3f(0,0,1);//藍色
glutSolidSphere(0.3,30,30);//頭
glColor3f(1,1,1);//白色
glTranslatef(0,-0.1,0.1);
glutSolidSphere(0.25,30,30);//臉
glPopMatrix();
glPushMatrix();
glColor3f(1,1,1);
//glutSolidSphere(0.2,30,30);//身體
glPopMatrix();
glPopMatrix();
glutSwapBuffers();
}
void idle()
{
angle++;
glutPostRedisplay();
}
int main()
{
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("Week08");
glutDisplayFunc(display);
glutIdleFunc(idle);
glutMainLoop();
}
沒有留言:
張貼留言