*moodle 下載3DExplorer
*下載http://www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10/ (source/data/win32/glut32.dll)
-

*開啟3DExplor
-

-尋找data
-
*打開Code Blocks
-建立GLUT Project (記得載 freeglut . 更改libglut32.a)
-抓取source.zip的程式碼 (glm.h(關鍵)/glm.c(關鍵)/transformation.c(範例)),放到上面所建立的Project中
-

-更改glm.c -> glm.cpp / transformation.c -> transformation.cpp
-

-把glm.h/glm.cpp/transformation.cpp放進專案內
-

-Add two files in Project (glm.cpp / transformation.cpp)
-

-在settings 的 compiler取消一個勾勾,然後把main.cpp清空(不能有兩個main())
-

-build -> rebuild (ctrl-F11),檔案裡會跑出bin和obj,把data丟到freeglut的bin裡面
-跑跑看
*自己寫程式
-#include "glm.h" ///要放在同一目錄下
-GLMmodel * pmodel=NULL;///指標
-從transformation中擷取得程式
-

-

-要把transformation.cpp的程式碼全部刪掉,因為同一個專案中不能有兩個main()函式
*顯示小車車
-

-#include "glm.h"///呼叫glm外掛
GLMmodel * pmodel=NULL;///指標
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);///清畫面
if (!pmodel) {
pmodel = glmReadOBJ("data/porsche.obj");///data要放在freeglut/bin的裡面
if (!pmodel) exit(0);
glmUnitize(pmodel);
glmFacetNormals(pmodel);
glmVertexNormals(pmodel, 90.0);
}
glmDraw(pmodel, GLM_SMOOTH | GLM_MATERIAL);
glutSwapBuffers();///畫出來
}
int main(int argc,char** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("05160965");
glutDisplayFunc(display);
glutMainLoop();
}
沒有留言:
張貼留言