week 09
##week09-0_sample
0. 安裝 freeglut,將lib\libfreeglut.a複製成libglut32.a
1.File-New-Project,GLUT專案,week09-0_sample
##程式碼重新再利用
0.安裝git軟體
1.將GitHub上周的程式clone下來(先有程式碼)
-在小黑Git Bash裡指令:
-cd desktop
-git clone https://github.com/.../2022cce
-cd 2024graphicsb
-start .
2.確定環境沒問題(OpenCV有沒有裝好?)
-安裝OpenCV 要勾Add PATH,裝在預設目錄
Setting Compiler裡,要把3個設定設好
-Compiler 加入C:\OpenCV2.1\include
-Linker加入C:\OpenCV2.1\lib
-Linker setting裡,加入3個 cv210 cxcore210 highgui210
重新開啟CodeBlocks
3.專案的設定是否需要修改(專案的右鍵,properties)
##開啟上週專案 week07-2_ojb_gundam_opencv_texture
1.File-open,點選剛剛git下載的week07-2_ojb_gundam_opencv_texture
2.選week07-2_ojb_gundam_opencv_texture.cbp(codeblocks project檔)
3.Build & run 執行成功
##week09-1_gundam_texture_lighting_rotates
0.前一個目錄 week07-2_obj_gundam_opencv_texture整個複製到新的目錄week09-1_obj_gundam_opencv_texture_lighting
1.再用Notepad++開啟 目錄裡的.cbd檔,改內容
2.把打光的8行陣列,貼在int main()之前
3.把打光的12+2行函式,貼到glutMainLoop()之前
4.glmDraw(pmodel,GLM_SMOOTH|GLM_TEXTURE)要刪掉中間的GLM_MATERIAL
為了讓畫面好看一點,打光漂亮,模型旋轉,我們做幾個修改
1.改變光的位置(改陣列的值
...
const GLfloat light_position[] = { 2.0f, 5.0f, 5.0f, 0.0f };
變成
const GLfloat light_position[] = { 2.0f, 5.0f, -5.0f, 0.0f };
...
2.在display() 加入旋轉
...
float angle=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(angle++,0,1,0);
drawmodel(); ///glutSolidTeapot( 0.3 );
glPopMatrix();
glutSwapBuffers();
}
...
int main(...)
{...
glutIdleFunc(display);
}
##week09-2_glutSolidCube_glutSolidTeapot_glutSolidSphere
1.File-New-Project,GLUT專案,week09-2_glutSolidCube_glutSolidTeapot_glutSolidSphere
2.貼入11行GLUT程式
3.加入glutSolidTeapot(0.3);///茶壺 glutSolidCube(0.3);///方塊 glutSolidSphere(0.3,30,30);///圓球
4.配合glPushMatrix() glTranslatef() glPopMatrix() 來移動
##week09-3_glutWireCube_glutWireTeapot_glutWire_Sphere
1.File-New-Project,GLUT專案,week09-3_glutWireCube_glutWireTeapot_glutWire_Sphere
2.直接貼上09-2程式碼
3.剛display()裡有三段實心程式碼
##上傳github注意事項
1.小黑關掉
2.codeblocks關掉(都要按YES存檔)
3.把每個專案的兩個目錄(BIN OBJ)刪掉
4.把 .depend .layout 刪掉
5.把今天的4個程式的專案目錄,上傳到github
沒有留言:
張貼留言