如何获取/设置默认帧缓冲区的宽度和高度? [英] How to get/set the width and height of the default framebuffer?

查看:203
本文介绍了如何获取/设置默认帧缓冲区的宽度和高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道默认帧缓冲区的尺寸. 我将设置视图端口读取为特定值不会影响/设置帧缓冲区的尺寸. 对此有任何GL要求吗?

I want to know the dimension of my default frame buffer. I read setting view port to a particular value does not affect/set the dimensions of frame buffer. Are there any GL calls for this?

推荐答案

您无法使用OpenGL调用设置默认帧缓冲区的大小.它是窗口的大小,由窗口系统界面(例如Android上的EGL)控制.如果要控制它,则必须在初始窗口/表面/上下文设置的一部分中进行,其中详细信息取决于平台.

You can't set the size of the default framebuffer with OpenGL calls. It is the size of the window, which is controlled by the window system interface (e.g. EGL on Android). If you want to control it, this has to happen as part of the initial window/surface/context setup, where the details are platform dependent.

我不知道有一个专门获取默认帧缓冲区大小的调用.但是您可以轻松地间接获得它.视口的默认值和剪刀矩形均与窗口的大小相对应.因此,如果您在修改它们之前得到了任何 ,它将为您提供窗口的大小.

I'm not aware of a call that specifically gets the size of the default framebuffer. But you can easily get it indirectly. Both the default values of the viewport and the scissor rectangle correspond to the size of the window. So if you get any of those before modifying them, it will give you the size of the window.

从规范中的2.12.1节控制视口"开始:

From section 2.12.1 "Controlling the Viewport" in the spec:

在初始状态下,将w和h分别设置为GL在其上进行渲染的窗口的宽度和高度.

In the initial state, w and h are set to the width and height, respectively, of the window into which the GL is to do its rendering.

根据规范中的4.1.2节剪刀测试":

From section 4.1.2 "Scissor Test" in the spec:

在初始状态下,left = bottom = 0;宽度和高度取决于总帐窗口的大小.

In the initial state left = bottom = 0; width and height are determined by the size of the GL window.

因此,您可以通过以下任一方式获取默认的帧缓冲区大小:

So you can get the default framebuffer size with either:

GLint dims[4] = {0};
glGetIntegerv(GL_VIEWPORT, dims);
GLint fbWidth = dims[2];
GLint fbHeight = dims[3];

或:

GLint dims[4] = {0};
glGetIntegerv(GL_SCISSOR_BOX, dims);
GLint fbWidth = dims[2];
GLint fbHeight = dims[3];

这篇关于如何获取/设置默认帧缓冲区的宽度和高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆