所有栏目

glViewport

作者:爱百科

glViewport是OpenGL中的一个函数,计算机图形学中,在屏幕上打开窗口的任务是由窗口系统,而不是OpenGL负责的。

glViewport详细介绍

glViewport是OpenGL中的一个函数,计算机图形学中,在屏幕上打开窗口的任务是由窗口系统,而不是OpenGL负责的。

glViewport功能

glViewport在默认情况下,视口被设置为占据打开窗口的整个像素矩形,窗口大小和设置视口大小相同,所以为了选择一个更小的绘图区域,就可以用glViewport函数来实现这一变换,在窗口中定义一个像素矩形,最终将图像映射到这个矩形中。例如可以对窗口区域进行划分,在同一个窗口中显示分割屏幕的效果,以显示多个视图。

glViewport参数

glViewport(GLint x,GLint y,GLsizei width,GLsizei height)为其函数原型。

X,Y————以像素为单位,指定了视口的左下角(在第一象限内,以(0,0)为原点的)位置。

width,height————表示这个视口矩形的宽度和高度,根据窗口的实时变化重绘窗口。

glViewport英文描述

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.

热点导航
教育资讯 知道问答 公考资讯 司法考试 建筑知识 工作范文 大学排名 报考专业 学习方法 句子美文 秒知回答 作业解答 精选答案 知途问学