#include <GL/glut.h>
void display()
{
glutSolidTeapot(0.3);///畫出一個實心的茶壺 大小0.3
glutSwapBuffers();///GLUT把畫面swap送到顯示的地方
}
int main(int argc, char *argv[])
{ ///上面是特別的main函式,有很多參數
glutInit(&argc, argv);///把GLUT開起來
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);//把顯示的模式設定好
glutCreateWindow("GLUT Shapes");///要開視窗
glutDisplayFunc(display);///要顯示的對應函式
glutMainLoop();///最後用main迴圈,壓在最後面
}
glColor3f(0,1,0);///換綠色
glutSolidTeapot(0.5);///更改大小
將綠色茶壺刪掉
glColor3f(1,0,0); glVertex2f(0,1);///紅色頂點
glColor3f(0,1,0); glVertex2f(-1,-1);///綠色頂點
glColor3f(0,0,1); glVertex2f(+1,-1);///藍色頂點
glColor3f(247/255.0,247/255.0,247/255.0);
glBegin(GL_POLYGON);
glVertex2f(1,1);
glVertex2f(-1,1);
glVertex2f(-1,-1);
glVertex2f(1,-1);
glEnd();
換上皮卡丘肚肚
glColor3f(244/255.0,209/255.0,33/255.0);
glBegin(GL_POLYGON);
glVertex2f( (45-100)/100.0,-(134-100)/100.0 );
glVertex2f( (36-100)/100.0,-(171-100)/100.0);
glVertex2f( (108-100)/100.0,-(179-100)/100.0);
glVertex2f( (104-100)/100.0,-(117-100)/100.0);
///座標減一半,除一半,y變負號
glEnd();
加上#include <math.h>///cos和sin要用
for(float a=0;a<2*3.141592653589793238462632383279; a+=0.01){
glVertex2f(cos(a),sin(a));
}
畫出一個大圓
glColor3f(1,0,1); myCircle(0.6,0,0);///正中間
glColor3f(1,0,0); myCircle(0.3,0.5,0.5);左上
glColor3f(0,1,0); myCircle(0.3,-0.5,0.5);右上
glColor3f(1,1,0); myCircle(0.3,-0.5,-0.5);左下
glColor3f(0,0,1); myCircle(0.3,0.5,-0.5);右下









沒有留言:
張貼留言