作業一
Step 1. 下載 Windows,data,glut32.dll , 以上三個Zip
Step 2. 建立一個資料夾,將window與data及glut都放入資料夾裡
Step 3. 將Windows裡的Transform拉到資料夾外,也就是資料夾內。data內的glm.h與glm.c同樣 的拉到資料夾外
作業 2
Step 1. 建立貝殼專案Step 2. 將"作業1"檔案中的Transform.c 和 glm.c 及 glm.h 複製下來,至專案資料夾中。
Step 3. 將剛剛以上的 .c 檔改成 .cpp 檔
Step 4. 到CodeBlock , 加 freeglut 的 include 和 lib 的 Path
Step 5. 加 (1) freeglut (2) opengl32 (3) glu32 (4)gui32 (5) winmm
Step 6. 將freeglut.dll 檔 ,加入到專案資料夾中
以下為專案檔案資料夾中,所有的檔案內容 :
Step 7. 執行成功 ( 如果在執行時發生顯示錯誤,將視窗拉到就會恢復正常)

作業 3
Step 1. 承作業2的檔案,將 Transfrom.cpp 刪除 , 然後新增一個New FileStep 2. 程式碼如下 :
#include "glm.h"GLMmodel *pmodel = NULL;void display (){glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);if (!pmodel){pmodel = glmReadOBJ("data/porsche.obj");if (!pmodel) exit (0);glmUnitize(pmodel) ;glmFacetNormals(pmodel);glmVertexNormals(pmodel,90.0);}glmDraw(pmodel,GLM_SMOOTH| GLM_MATERIAL);glutSwapBuffers();}GLfloat pos[] = {0.0 , 0.0,-1.0,0.0};int main (int argc ,char **argv){glutInit (&argc,argv);glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);glutCreateWindow ("3D Model");glutDisplayFunc (display);glLightfv (GL_LIGHT0,GL_POSITION,pos);glEnable (GL_LIGHT0);glEnable (GL_LIGHTING);glEnable (GL_DEPTH_TEST);glutMainLoop();}
Step 3 執行


沒有留言:
張貼留言