2015年3月11日 星期三

02160145_方得榮 Week03

1.彩色茶壺
#include <GL/glut.h>
void display()
{
    glClearColor(0,0,1,1);///設定清畫面的顏色
    glClear(GL_COLOR_BUFFER_BIT);///CLEAR清畫面
    glColor3f(1,1,0);///顏色
    glutSolidTeapot(0.5);
     glColor3f(1,0,0);///顏色
    glutSolidTeapot(0.4);
     glColor3f(1,0,1);///顏色
    glutSolidTeapot(0.3);
    glFlush();
}
int main(int argc, char *argv[])
{
    glutInit(&argc, argv);
    glutCreateWindow("02160200");
    glutDisplayFunc(display);
    glutMainLoop();
}
2.
include <GL/glut.h>
void display()
{
    glClearColor(0,0,0.3,1);///設定清畫面的顏色
    glClear(GL_COLOR_BUFFER_BIT);///CLEAR清畫面
    glColor3f(1,1,0);///顏色

     glBegin(GL_POLYGON);
     glColor3f(1,0,0);///顏色
     glVertex2f(-1.0,-1.0);

     glColor3f(0,1,0);///顏色
     glVertex2f(1.0,0.0);

     glColor3f(0,0,1);///顏色
     glVertex2f(0.0,1.0);
   glEnd();

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


    glutCreateWindow("02160200");

    glutDisplayFunc(display);
    glutMainLoop();
}
3.
#include <GL/glut.h>
void display()
{
    glClearColor(0,0,0.3,1);///設定清畫面的顏色
    glClear(GL_COLOR_BUFFER_BIT);///CLEAR清畫面
    glColor3f(1,1,0);///顏色

     glBegin(GL_POLYGON);
     glColor3f(0.39,0.75,0.84);///顏色
     glVertex2f(0.6,0.3);
     glVertex2f(1.0,0.3);
     glVertex2f(0.2,0.15);
     glVertex2f(0.9,0.84);
   glEnd();

    glFlush();
}
int main(int argc, char *argv[])
{
    glutInit(&argc, argv);
    glutCreateWindow("02160200");
    glutDisplayFunc(display);
    glutMainLoop();
}


沒有留言:

張貼留言