2015年3月12日 星期四

week03_翁子喻_02160022

到jsyeh.org/3dcg10 下載 windows,data,glut32.dll

將windows解壓縮開啟windows資料夾,再將data解壓縮,data資料夾和glut32.dll放入windows


開啟"shapes"。也可以再試其他的範例。


到freeglut-devel下載Download freeglut 2.8.1-1 for MinGW

將下載的檔案解壓縮,找到lib將libfreeglut.a複製檔名改成libglut.a


開始codeblocks建project點選glut

 寫程式內容並執行:
#include <GL/glut.h>
void display()
{
    glColor3f(1,1,0);
    glutSolidTeapot(0.4);
    glFlush();
}

int main(int argc,char**argv)
{
    glutInit(&argc,argv);
    glutCreateWindow("02160022翁子喻");
    glutDisplayFunc(display);
    glutMainLoop();
}

可再加入:
    glColor3f(1,0,0);
    glutSolidTeapot(0.5);
    glColor3f(0,1,0);
    glutSolidTeapot(0.6);
    glColor3f(0,0,1);
    glutSolidTeapot(0.7);
程式碼出現多個不同大小的茶壺及顏色


換背景顏色:加入兩行程式碼
glClearColor(0.7,0,1,6);
glClear(GL_COLOR_BUFFER_BIT);
加入新的程式碼:
#include <GL/glut.h>
void display()
{
    glClearColor(0.7,0,1,6);///重點3.用來Clear清的顏色是什麼
    glClear(GL_COLOR_BUFFER_BIT);///重點2.Clear說明你清哪一個Buffer

    glBegin(GL_POLYGON);
        glColor3f(1,1,0);///今天的重點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("02160022翁子喻");
    glutDisplayFunc(display);
    glutMainLoop();
}







沒有留言:

張貼留言