增加
glutSolidTorus(0.3,0.7,50,50);///畫甜甜圈形狀
#include <GL/glut.h>///呼叫外掛
void display()
{
glColor3f(1,0,0);///上色(紅)
glutSolidTorus(0.3,0.7,50,50);///畫甜甜圈形狀
glColor3f(1,1,1);///上色(白)
glutSolidTeapot(0.2);///畫茶壺
glFlush();
}
int main(int argc,char *argv[])
{
glutInit(&argc,argv);///初始化
glutCreateWindow("02160421");///畫視窗
glutReshapeWindow(500,500);///改變視窗大小
glutDisplayFunc(display);///呼叫函式
glutMainLoop();///持續跑主程式
}
增加
glPushMatrix();///備份matrix
glTranslatef(-0.03, 0, 0);///移動
glRotatef(angle,1,1,0);///旋轉,對(110)軸 轉動angle
glPopMatrix();
glutIdleFunc(display);///閒閒沒事時呼叫display
#include <GL/glut.h>///呼叫外掛
float angle=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT);///清畫面
glPushMatrix();///備份matrix
glTranslatef(-0.03, 0, 0);///移動
glRotatef(angle,1,1,0);///旋轉,對(110)軸 轉動angle
glColor3f(1,0,0);///上色(紅)
glutWireTorus(0.3,0.7,50,50);///畫空甜甜圈形狀
glColor3f(1,1,1);///上色(白)
glutSolidTeapot(0.2);///畫茶壺
glPopMatrix();
glFlush();
angle+=0.02;
}
int main(int argc,char *argv[])
{
glutInit(&argc,argv);///初始化
glutCreateWindow("02160421");///畫視窗
glutReshapeWindow(500,500);///改變視窗大小
glutDisplayFunc(display);///呼叫函式
glutIdleFunc(display);///閒閒沒事時呼叫display
glutMainLoop();///持續跑主程式
}
沒有留言:
張貼留言