2024年4月18日 星期四

電腦圖學Week09

##week09-0_sample

1. 桌面有「葉正聖老師上課用軟體」 freeglut 安裝(拉到桌面),再把 lib的 libfreeglut.a 複製成 libglut32.a

2. CodeBlocks File-New-Project, GLUT專案, week09-0_sample


##複習上週的week08-3_glm_gundam_opencv_texture

1. 要把環境裝好:OpenCV0.

2.小心 :Add PATH

3.小心:不要改目錄

4.關閉重開 CodeBlocks(才會把PATH設定好。要記得存檔)


CodeBlocks:Setting-Compiler

1.C:\OpenCV2.1\include


2.C:\OpenCV2.1\lib


3.cv210 cxcore210 highgui210



要把上周的Github倉庫複製下來

0. 安裝 Git ,開啟 Git Bash小黑

1.cd desktop

2.git clone https://github.com/11160871mcu/2024grapihcsa

3.cd 2024graphicsa

4.start .



把上週的week08-3_glm_gundam_opencv_texture開起來

1.File-Open,到那個目錄,點開.cbp(CodeBlocks Project檔)

2.Build&Run就可以了


##把剛剛的專案,變成week09-1_glm_gundam_opencv_texture

0.把剛剛的專案,先關起來Close Project(這樣才不會被擠)

1.目錄:把整個week08-3_glm_gundam_opencv_texture複製到桌面的

week09-1_glm_gundam_opencv_texture_lighting再把week

2.檔案:week08-3_glm_gundam_opencv_texture_lighting.cbp改檔名成

week09-1_glm_gundam_opencv_texture_lighting.cbp

3.CodeBlocks File-Open 開啟 week09-1_glm_gundam_opencv_texture_lighting.cbp檔

4.再把專案的Title用Notepad++開啟week09-1_glm_gundam_opencv_texture_lighting檔,把裡面的week08-3都改成week09-1就好了,記得存檔


5.再用CodeBlocks File-Open開它,就好了

為了騙得更徹底,記得用main.cpp裡的glutCreateWindow("week08 Gundam")改成

glutCreateWindow("week09-1 Gundam")改的更徹底


##week09-2_glutSolidTeapot_guldSolidCube_glutSolidSphere

1. File-Project,GLUT檔案

week09-2_glutSolidTeapot_guldSolidCube_glutSolidSphere

2.貼上11行程式(再新增三行):

#include <GL/glut.h>

void display()

{

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

///glutSolidTeapot(0.3);

///glutSolidCube(0.3);

glutSolidSphere(0.3,30,30);

glutSwapBuffers();

}

int main(int argc, char*argv[])

{

glutInit(&argc, argv);

glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);

glutCreateWindow("week09 Microsoft Visual Studio");

glutDisplayFunc(display);

glutMainLoop();

}


3.畫另外3個,左上、上、右上,使用期中考教的程式碼:

#include <GL/glut.h>

void display()

{

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glPushMatrix();

        glTranslatef(-0.5,+0.3,0);

        glutSolidTeapot(0.3);

    glPopMatrix();


    glPushMatrix();

        glTranslatef(+0.0,+0.3,0);

        glutSolidCube(0.3);

    glPopMatrix();


    glPushMatrix();

        glTranslatef(+0.5,+0.3,0);

        glutSolidSphere(0.3,30,30);

    glPopMatrix();


glutSwapBuffers();

}

int main(int argc, char*argv[])

{

glutInit(&argc, argv);

glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);

glutCreateWindow("week09 Microsoft Visual Studio");

glutDisplayFunc(display);

glutMainLoop();

}


##week09-3_glutWireTeapot_guldWireCube_glutWireSphere

1. File-Project,GLUT檔案

week09-3_glutWireTeapot_guldWireCube_glutWireSphere

2.貼上week09-2程式

3.把三段再複製到下面,並把下面座標改成y是負的




沒有留言:

張貼留言