應用Projection.exe來看看參數
gluPerspective()中的設定
fovy: Y方向的視野
aspect : 長寬比例
zNear:z方向,近的面
zFar:z方向,遠的面
更改glFrustum()中的設定
接下來開GLUT專案,改resize()函式裡面的glFrustum()變成gluPerspective()
gluPerspective(60,1,0.001,1000);
可以看到畫面中的圖形會隨著視窗改變
///glFrustum(-ar, ar, -1.0, 1.0, 2.0, 100.0);
gluPerspective(60,ar,0.001,1000);
將這個值改成ar就能看到他就算改變視窗,他還是會在置中的位置
再來我們改用glOrtho();來看
之後我們要來顯示茶壺
然後我們要+motion的函式來讓他用滑鼠移動
void motion(int x,int y)
{
eyeX = (x-320)/320.0;
eyeY = (y-240)/240.0;
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(eyeX,eyeY,eyeZ,centerX,centerY,centerZ,0,1,0);
}
main中加入
glutMotionFunc(motion);







沒有留言:
張貼留言