更新时间:2024-08-21 03:19
这个函数描述了一个平行修剪空间。这种投影意味着离观察者较远的对象看上去不会变小(与透视投影相反)。在3D笛卡尔坐标中想象这个修剪空间,左边和右边是最小和最大的X值,下边和上边是最小和最大的Y值,近处和远处是最小和最大的Z值。 正射投影,又叫平行投影。这种投影的视景体是一个矩形的平行管道,也就是一个长方体。正射投影的最大一个特点是无论物体距离相机多远,投影后的物体大小尺寸不变。这种投影通常用在建筑蓝图绘制和计算机辅助设计等方面,这些行业要求投影后的物体尺寸及相互间的角度不变,以便施工或制造时物体比例大小正确。
使用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都为正值。
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.