2.實作:gluLookAt()、glutReshapeFunc()
*下載
-freeglut (記得載 freeglut . 更改libglut32.a)
-http://www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10/ (source/data/win32/glut32.dll)
-抓取source.zip的程式碼 (glm.c(關鍵)/glm.c(關鍵)/transformation.c(範例)),放到上面所建立的Project中
-更改glm.c -> glm.cpp / transformation.c -> 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裡面
*測試鏡頭-

-

-

-

-

-

*認識glutReshapeFunc(resize);
-static void resize(int width, int height)
{
const float ar = (float) width / (float) height;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-ar, ar, -1.0, 1.0, 2.0, 100.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity() ;
}
-

-這個透視影很怪,camera投影在中心(0 , 0 , 0),但是茶壺也在(0 , 0 , 0),所以看不到
-gluperspective()也投影在(0 , 0 , 0)
-

-新增gluLookAt(0 , 0 , 2 , 0 , 0 , 0 , 0 , 1 , 0) ; ,在glMatrizMode() ; 之後
-

-try gluLookAt();
-

-

-

*總結
-

-

-

-

-

-
沒有留言:
張貼留言