課本範例:
#include <GL/glut.h>
float angle=0;
void display(){
glPushMatrix(); //備份
glTranslatef(-0.04,0,0);
glRotatef(angle, 1,1,0);
glColor3f(1,0,0);
glutWireTorus(0.2,0.7,100,50); //甜甜圈
glColor3f(0,0,1);
glutSolidTeapot(0.3);
glPopMatrix(); //還原
glFlush();
angle+=0.1; //轉角度
glClear(GL_COLOR_BUFFER_BIT); //清畫面
}
int main(int argc, char**argv){
glutInit(&argc,argv);
glutCreateWindow("資傳拉拉拉拉拉");
glutReshapeWindow(1000,1000);
glutDisplayFunc(display);
glutIdleFunc(display); //沒事時執行
glutMainLoop();
}
沒有留言:
張貼留言