2015年3月12日 星期四

02160056簡瑜萱WEEK3

week3
1)點線面顏色
2)五行程式
3)glut範例
4)電腦圖學之父


1)到jsyeh.org/3dcg10 載data  win35 glut32.all
2)window.zip ->桌面\window\範例exe
3)glut32.dll->桌面\window\glut32.all
4)data.zip->桌面\window\data\3d模型











#include<GL/glut.h>

void display()
{
    glColor3f(1,1,0);
    glutSolidTeapot(0.4);
    glFlush();
}
int main(int argc,char **argv)
{
    glutInit(&argc, argv);
    glutCreateWindow("02160056簡瑜萱");
    glutDisplayFunc(display);
    glutMainLoop();
}

今天第一個作業是茶壺
到http://www.transmissionzero.co.uk/software/freeglut-devel/載MinGW檔



接著加了程式碼改茶壺顏色及大小


#include<GL/glut.h>

void display()
{
    glColor3f(1,1,0);
    glutSolidTeapot(0.4);
    glColor3f(1,0,1);
    glutSolidTeapot(0.3);
    glColor3f(0,1,1);
    glutSolidTeapot(0.2);
    glFlush();
}
int main(int argc,char **argv)
{
    glutInit(&argc, argv);
    glutCreateWindow("02160056簡瑜萱");
    glutDisplayFunc(display);
    glutMainLoop();
}





第二個作業是加入程式碼 glClearColor(0.6,1,0.8,1);
                                                                                  glClear(GL_COLOR_BUFFER_BIT);
                                                    改背景顏色


#include<GL/glut.h>

void display()
{
    glClearColor(0.6,1,0.8,1);
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3f(1,1,0);
    glutSolidTeapot(0.4);
    glColor3f(0,0,1);
    glutSolidTeapot(0.3);
    glColor3f(0,1,0);
    glutSolidTeapot(0.2);


    glFlush();
}
int main(int argc,char **argv)
{
    glutInit(&argc, argv);
    glutCreateWindow("02160056簡瑜萱");
    glutDisplayFunc(display);
    glutMainLoop();
}

第三個作業是畫出多邊形並且上色

#include<GL/glut.h> include 外掛的GLUT的工具

void display()用來畫東西的顯示函示
{
    glClearColor(0.6,1,0.8,1);今天重點3:用來clear清的顏色是甚麼
    glClear(GL_COLOR_BUFFER_BIT);今天重點2:clear而且要說明你清哪個buffer

    glBegin(GL_POLYGON);
    glColor3f(1,1,0);今天重點1:color
    glVertex2f(0,0);
    glVertex2f(1,0);
    glVertex2f(0,1);
    glEnd();
    glBegin(GL_POLYGON);
    glColor3f(1, 1, 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("02160056簡瑜萱");
    glutDisplayFunc(display);
    glutMainLoop();
}






沒有留言:

張貼留言