2017年3月6日 星期一

Week 02 林憶蓮上課筆記

hw1:

複習上週在Codeblock中
(1)File>New>Project. 選OpenGL專案
(2)File>New>Project. 選GLUT專案
(小心:Facebook 下載檔案freeglut)

hw2: 畫茶壺
(3)把Glut 專案刪減成10行
--------------------------------------------------------------------------------------------------------------------
#include <GL/glut.h>

static void display(void)
{
    glutSolidTeapot(0.3);
    glutSwapBuffers();
}


int main(int argc, char *argv[])
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);

    glutCreateWindow("GLUT Shapes");
    glutDisplayFunc(display);

    glutMainLoop();
}
---------------------------------------------------------------------------------------------------------------------



(4)茶壺塗色
-------------------------------------------------------------------------------------------------------------------------
#include <GL/glut.h>

static void display(void)
{
    glColor3f(0,0,0);      /*三原色(R,G,B)*/
    glutSolidTeapot(0.3);
    glutSwapBuffers();
}


int main(int argc, char *argv[])
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);

    glutCreateWindow("GLUT Shapes");
    glutDisplayFunc(display);

    glutMainLoop();
}

------------------------------------------------------------------------------------------------------------------------

white↓


black↓


yellow↓


(5)三角型塗色

◎ 請打網址《http://jsyeh.org/3dcg10》下載 data.zip / window.zip / glut32.dll 此三個檔案為輔助範例


------------------------------------------------------------------------------------------------------------------------
#include <GL/glut.h>
static void display(void)
{
    glBegin(GL_TRIANGLES);      /*做出三角形座標及塗色*/
    glColor3f(1,0,0);
    glVertex3f(0,0,0);
    glColor3f(0,1,0);
    glVertex3f(1,1,0);
    glColor3f(0,0,1);
    glVertex3f(1,-1,0);
    glEnd();
    glutSwapBuffers();
}


int main(int argc, char *argv[])
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("GLUT Shapes");
    glutDisplayFunc(display);
    glutMainLoop();
}
-------------------------------------------------------------------------------------------------------------------------


彩色三角形↓


若去掉兩頂點顏色↓


沒有留言:

張貼留言