2022年3月1日 星期二

Ru的電腦圖學筆記>



Step01-1 跑別人的範例

1.到 https://jsyeh.org/3dcg10 下載範例檔案 data.zip、windows.zip、glut32.dll


2. windows.zip => 解壓縮至 windows =>下載/windows/Shapes.exe

    data.zip => 解壓縮至此 => 下載/丟進去 windows 的資料夾/data/模型

    glut32.dll => 複製 =>下載/丟進去 windows 的資料夾/glut32.dll

3.跑 Shape.exe 看範例試試看

    左邊按右鍵選單:大頂點、很多顏色

    右邊按右鍵選單:POIN......POLYGON



Step01-2 跑上週的範例

1.安裝 Git for windows

2.Git Bash:

    -cd desktop

    -git clone https://github.com/MCUYeeZhiHua/2022graphics1

    -cd 2022graphics1

3.安裝 freeglut 解壓縮至桌面

    -freeglut 裡的 lib 裡面的 libfreeglut.a 複製並改成libgult32.a

4.Codeblocks/File/Open/桌面/2022graphics1/Week01_GLUT 

Step02-1親手打造GLUT的程式

1.新增一個新的 GLUT 檔案

    -檔名:week02_color ,儲存至桌面

2.把 main.cpp 裡面的程式碼全部刪掉,重新打:

#include <GL/glut.h>
void display()
{
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glColor3d(1,1,0);
    glutSolidTeapot(0.3);
    glutSwapBuffers();
}
int main(int argc, char** argv)
{
    glutInit( &argc, argv );
    glutInitDisplayMode( GLUT_DOUBLE | GLUT_DEPTH );
    glutCreateWindow("第02週的程式哦!");
    glutDisplayFunc(display);
    glutMainLoop();
}

3.按執行會出現茶壺的圖案ヽ(✿゚▽゚)ノ



Step03-1彩色三角形
1.把 glutSolidTeapot(0.3); 這一行刪除
2.再將程式碼改成:
#include <GL/glut.h>
void display()
{
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glColor3f(1,1,0);
    ///glutSolidTeapot(0.3);
    glBegin(GL_POLYGON);
        glColor3f(1,0,0);
        glVertex2f(-1, -1);

        glColor3f(0,1,0);
        glVertex2f(+1, -1);

        glColor3f(0,0,1);
        glVertex2f(0, +1);
    glEnd();
    glutSwapBuffers();
}

int main(int argc, char** argv)
{
    glutInit( &argc, argv );
    glutInitDisplayMode( GLUT_DOUBLE | GLUT_DEPTH );
    glutCreateWindow("第02週的程式哦!");
    glutDisplayFunc(display);
    glutMainLoop();
}
3.按執行會出現紅藍綠的三角形(๑¯◡¯๑)


Step03-2上傳到 Github
1.把 README.md 說明檔,利用 Markdown MD語法編輯
    -# 一個井號,表示大標題
    -## 二個井號,表示小標題
    -```C++會秀出C++的程式
    -直接在 GitHub 上,登入後, 按 "筆" 修改
    -再按綠色的 Commit 確認你的修改
2.傳送上雲端
    -開啟 Git Bash
    -cd desktop 
    -git clone https://github.com/MCUYeeZhiHua/2022graphics1
    -cd 2022graphics1
    -把檔案加入桌面 2022graphics 的資料夾
    -git status
    -git add .
    -git status

    -git config --global user.email "09160501@me.mcu.edu.tw"
    -git config --global user.name "MCUYeeZhiHua"
    -git commit -m"add week01"
    -git push 推送上雲端 (預設瀏覽器要登入才行)


完成!💗💗💗💗💗💗💗

沒有留言:

張貼留言

VERY BEAUTIFUL, VERY POWERFUL

一.     一樣先安裝且設定好freeglut,OpecCV, 開啟CodeBlocks建立新專案 week11_gundam,                 把 MyGundam.zip下載解壓縮後的data資料夾放到freeglut/bin裡面 把week09_openc...