当前位置:首页 科普知识 glViewport

glViewport

发布时间:2023-09-06 08:08:36

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

glViewport详细介绍

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

glViewport

glViewport功能

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

glViewport参数

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

glViewport

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

glViewport

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.

温馨提示:
本文【glViewport】由作者 爱百科 转载提供。 该文观点仅代表作者本人, 自学教育网 信息发布平台,仅提供信息存储空间服务, 若存在侵权问题,请及时联系管理员或作者进行删除。
(c)2008-2025 自学教育网 All Rights Reserved 汕头市灵创科技有限公司
粤ICP备2024240640号-6