2018年3月5日 星期一

Week 02 X+7 的筆記 (點線面)

點線面.顏色
老師買的網址2010年
http://www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10/

1.下載[data][win32]glut32.dll 
2.將[win32]解壓縮
3.將glut32.dll 放入window資料夾



考試重點點


用Codeblocks用177行程式碼縮減為10行程式碼
1.OPENGL

2.GLUT
記得去moodle下載glut
http://moodle-26.mcu.edu.tw/course/view.php?id=2609
然後要將lib的 複製一個 打libglut32

3.自己寫程式做茶壺

4.了解 點 跟 顏色 的搭配


#include <GL/glut.h>
void display()
{
    glClear(GL_COLOR_BUFFER_BIT);
    glBegin(GL_POLYGON);

    glColor3f(1.0f, 0.0f, 0.0f);   glVertex2f(0.0f,   1.0f);
    glColor3f(0.0f, 1.0f, 0.0f);   glVertex2f(0.87f,  -0.5f);
    glColor3f(0.0f, 0.0f, 1.0f);   glVertex2f(-0.87f, -0.5f);

    glEnd();
    //glutSolidTeapot(0.3);
    glutSwapBuffers();
}

int main(int argc, char**argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE);
    glutCreateWindow("05160133_week02 good goood!");

    glutDisplayFunc(display);
    glutMainLoop();
}


5.了解 點 跟 顏色 的搭配
自製草


#include <GL/glut.h>
void display()
{
    glClear(GL_COLOR_BUFFER_BIT);
    glBegin(GL_POLYGON);

    glColor3ub(110, 171, 15);
    glVertex2f((149-150)/150.0,-(111-150)/150.0);
    glVertex2f((243-150)/150.0,-(298-150)/150.0);
    glVertex2f((260-150)/150.0,-(298-150)/150.0);
    glVertex2f((204-150)/150.0,-(194-150)/150.0);

    glEnd();
    //glutSolidTeapot(0.3);
    glutSwapBuffers();
}

int main(int argc, char**argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE);
    glutCreateWindow("05160133_week02 good goood!");

    glutDisplayFunc(display);
    glutMainLoop();
}

0306
自行回家打程式
作業2


#include <GL/glut.h>
void display()
{
    glClear(GL_COLOR_BUFFER_BIT);
    glBegin(GL_POLYGON);


    glColor3ub(179, 254, 1);//亮綠
    glVertex2f((158-150)/150.0,-(181-150)/150.0);

    glColor3ub(250, 244, 158);//暗黃
    glVertex2f((141-150)/150.0,-(180-150)/150.0);
    glVertex2f((122-150)/150.0,-(160-150)/150.0);
    glVertex2f((115-150)/150.0,-(145-150)/150.0);
    glVertex2f((92-150)/150.0,-(84-150)/150.0);
    glColor3ub(255, 239, 68);//亮黃
    glVertex2f((86-150)/150.0,-(74-150)/150.0);
    glVertex2f((86-150)/150.0,-(65-150)/150.0);
    glVertex2f((100-150)/150.0,-(59-150)/150.0);
    glColor3ub(250, 244, 158);//暗黃
    glVertex2f((116-150)/150.0,-(64-150)/150.0);
    glVertex2f((119-150)/150.0,-(53-150)/150.0);
    glColor3ub(250, 244, 158);//暗黃
    glVertex2f((133-150)/150.0,-(54-150)/150.0);
    glColor3ub(255, 239, 68);//亮黃
    glVertex2f((148-150)/150.0,-(47-150)/150.0);
    glVertex2f((152-150)/150.0,-(50-150)/150.0);
    glVertex2f((162-150)/150.0,-(45-150)/150.0);
    glColor3ub(250, 244, 158);//暗黃
    glVertex2f((176-150)/150.0,-(51-150)/150.0);
    glVertex2f((185-150)/150.0,-(49-150)/150.0);
    glColor3ub(255, 239, 68);//亮黃
    glVertex2f((189-150)/150.0,-(44-150)/150.0);
    glVertex2f((199-150)/150.0,-(53-150)/150.0);
    glColor3ub(250, 244, 158);//暗黃
    glVertex2f((200-150)/150.0,-(67-150)/150.0);
    glVertex2f((202-150)/150.0,-(90-150)/150.0);
    glColor3ub(255, 239, 68);//亮黃
    glVertex2f((192-150)/150.0,-(149-150)/150.0);
    glColor3ub(180, 140, 42);//咖啡
    glVertex2f((184-150)/150.0,-(171-150)/150.0);

    glColor3ub(106, 144, 87);//軍綠
    glVertex2f((167-150)/150.0,-(179-150)/150.0);
    glColor3ub(0, 128, 64);//綠
    glVertex2f((177-150)/150.0,-(277-150)/150.0);
    glColor3ub(0, 64, 64);//軍綠
    glVertex2f((177-150)/150.0,-(600-150)/150.0);


    glEnd();
    //glutSolidTeapot(0.3);
    glutSwapBuffers();
}

int main(int argc, char**argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE);
    glutCreateWindow("05160133_week02 good goood!");

    glutDisplayFunc(display);
    glutMainLoop();
}




沒有留言:

張貼留言