词条 | glViewport |
释义 | 功能glViewport是OpenGL中的一个函数。计算机图形学中,在屏幕上打开窗口的任务是由窗口系统,而不是OpenGL负责的。在默认情况下,视口被设置为占据打开窗口的整个像素矩形,如图1,窗口大小和设置视口大小相同,所以为了选择一个更小的绘图区域,就可以用glViewport函数来实现这一变换,在窗口中定义一个像素矩形,最终将图像映射到这个矩形中。例如可以对窗口区域进行划分,在同一个窗口中显示分割屏幕的效果,以显示多个视图。 参数glViewport(GLint x,GLint y,GLsizei width,GLsizei height)为其函数原型。 X,Y————以像素为单位,指定了视口的左下角位置。 width,height————表示这个视口矩形的宽度和高度,根据窗口的实时变化重绘窗口。 英文描述glViewport specifies the affine transformation of x and y from normalized device coordinates to window coordinates. Let (xnd, ynd) be normalized device coordinates. Then the window coordinates (xw, yw) are computed as follows: Viewport width and height are silently clamped to a range that depends on the implementation. This range is queried by calling glGet with argument GL_MAX_VIEWPORT_DIMS. Errors: GL_INVALID_VALUE is generated if either width or height is negative. GL_INVALID_OPERATION is generated if glViewport is executed between the execution of glBegin and the corresponding execution of glEnd. |
随便看 |
百科全书收录4421916条中文百科知识,基本涵盖了大多数领域的百科知识,是一部内容开放、自由的电子版百科全书。