1.甜甜圈
#include<GL/glut.h>
void display()
{
glutWireTorus(0.3,0.7,30,30);
glFlush();
}
int main(int argc, char**argv)
{
glutInit(&argc,argv);
glutCreateWindow("02160615");
glutDisplayFunc(display);
glutMainLoop();
}
2.旋轉
#include<GL/glut.h>
float angle=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glTranslatef(-0.04,0,0);
glRotatef(angle,1,1,0); //轉動
glColor3f(0,0,0);
glutWireTorus(0.3,0.7,30,30);
glRotatef(angle-0.03,1,1,1);
glColor3f(0,0,0);
glutSolidTeapot(0.2);
glPopMatrix();
glFlush();
angle+=0.03;
}
int main(int argc, char**argv)
{
glutInit(&argc,argv);
glutCreateWindow("02160615");
glutDisplayFunc(display);
glutIdleFunc(display);
glutMainLoop();
}
沒有留言:
張貼留言