2015年3月12日 星期四

02163015 week3 -江世光

1. 把茶壺加上顏色
#include <gl/glut.h>
void play()
{
    glutWireTeapot(0.3);
    glColor3f(1,1,0);     //加上黃色

    glFlush();
}
int main(int argc,char *argv[])
{
    glutInit(&argc,argv);

    glutCreateWindow("02163015江世光");
    glutDisplayFunc(play);
    glutMainLoop();
    return 0;
}



2. 加上不同大小的茶壺
#include <gl/glut.h>
void play()
{
    glutWireTeapot(0.3); //邊長最大茶壺
    glColor3f(1,0,0);     //加上紅色
    glutWireTeapot(0.2);//邊長中等茶壺
    glColor3f(0,1,0);//加上綠色
    glutWireTeapot(0.1);//邊長最小茶壺
    glColor3f(0,0,1);//加上藍色
    glFlush();
}
int main(int argc,char *argv[])
{
    glutInit(&argc,argv);

    glutCreateWindow("02163015江世光");
    glutDisplayFunc(play);
    glutMainLoop();
    return 0;
4.自己畫一個形狀
#include <gl/glut.h>
void play()
{
    glClearColor(0.5,0.4,0.9,0.8); //加入清理顏色
    glClear(GL_COLOR_BUFFER_BIT);  //要清理BUFFER_選擇

    glBegin(GL_POLYGON);
        glColor3f(1,1,1);
        glVertex2f(0,0);
        glVertex2f(1,0);
        glVertex2f(0,1);
    glEnd();
    glBegin(GL_POLYGON);
        glColor3f(1,0,0);
        glVertex2f(0,0);
        glColor3f(0,1,0);
        glVertex2f(-1,0);
        glColor3f(0,0,1);
        glVertex2f(0,-1);
    glEnd();

    glFlush();
}
int main(int argc,char *argv[])
{
    glutInit(&argc,argv);

    glutCreateWindow("02163015江世光");
    glutDisplayFunc(play);
    glutMainLoop();
    return 0;
}

沒有留言:

張貼留言