中文解釋
函式簡介
使用glOrtho 函式可以將當前的可視空間設定為正投影空間。基參數的意義如圖,如果繪製的圖空間本身就是二維的,可以使gluOrtho2D.他的使用類似於glOrtho.
函式用途
設定或修改修剪空間的範圍
句法
void glOrtho(GLdouble left,GLdouble right,GLdouble bottom,GLdouble top,GLdouble near,GLdouble far);
描述
glOrtho就是一個正射投影函式。它創建一個平行視景體。實際上這個函式的操作是創建一個正射投影矩陣,並且用這個矩陣乘以當前矩陣。其中近裁剪平面是一個矩形,矩形左下角點三維空間坐標是(left,bottom,-near),右上角點是(right,top,-near);遠裁剪平面也是一個矩形,左下角點空間坐標是(left,bottom,-far),右上角點是(right,top,-far)。所有的near和far值同時為正或同時為負。如果沒有其他變換,正射投影的方向平行於Z軸,且視點朝向Z負軸。這意味著物體在視點前面時far和near都為負值,物體在視點後面時far和near都為正值。
MSDN中的解釋
glOrtho
NAME
glOrtho -- multiply the current matrix by an orthographic matrix
C SPECIFICATION
void glOrtho(GLdouble left,
GLdouble right,
GLdouble bottom,
GLdouble top,
GLdouble near,
GLdouble far)
PARAMETERS
left, right
Specify the coordinates for the left and right vertical clipping planes.
bottom, top
Specify the coordinates for the bottom and top horizontal clipping planes.
near, far
Specify the distances to the nearer and farther depth clipping planes. These distances are negative if the plane is to be behind the viewer.
DESCRIPTION
glOrtho describes a matrix that produces a parallel projection. (left, bottom, -near) and (right, top, -near) specify the points on the near clipping plane that are mapped to the lower left and upper right corners of the window, respectively, assuming that the eye is located at (0, 0, 0). -far specifies the location of the far clipping plane. Both near and far can be either positive or negative.
The current matrix is multiplied by this matrix with the result replacing the current matrix. That is, if M is the current matrix and O is the ortho matrix, then M is replaced with M*O.
Use glPushMatrix and glPopMatrix to save and restore the current matrix stack.
ERRORS
GL_INVALID_OPERATION is generated if glOrtho is called between a call to glBegin and the corresponding call to glEnd.