是否可以仅使用OpenGL确定默认帧缓冲区的大小? [英] Is it possible to determine the size of the default framebuffer using OpenGL only?

查看:227
本文介绍了是否可以仅使用OpenGL确定默认帧缓冲区的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在为我打算开发的游戏开发游戏引擎/框架.我正在设计通过抽象类和依赖注入使系统尽可能分离的系统.理想情况下,我的目标是使每个子系统都不依赖于引擎的其他部分.

I'm currently developing a game engine/framework for a game I intend to develop. I'm designing the system to be as decoupled as possible via abstract classes and dependency injection. Ideally, I'm aiming for each sub-system to not depend on other parts of the engine.

在我的渲染系统中,我希望能够将视口和剪刀/剪切区域重置为当前绑定的目标大小以进行渲染(无论是OpenGL FrameBuffer,Direct3D RenderTarget还是默认的后缓冲),而无需必须让程序员跟踪它,而不必依赖于窗口子系统/另一个库,也不必编写与系统有关的代码.

In my rendering system, I'd like to provide the ability to reset the viewport and scissor/clipping area to the size of the currently bound target for rendering (Be it an OpenGL FrameBuffer, Direct3D RenderTarget or the default backbuffer) without having to get the programmer to keep track of it and without having to rely on the windowing sub-system/another library or having to write system dependant code.

当前,我正在对渲染子系统的OpenGL实现进行编码,我想检查是否可以单独使用OpenGL 3.3函数调用来获得后缓冲区/默认帧缓冲区的大小.我曾经使用GLX/WGL编写代码来做到这一点,尽管我想避免这种情况.

Currently I'm coding an OpenGL implementation of the render sub-system and I wanted to check if it was possible to get the size of the backbuffer/default framebuffer using OpenGL 3.3 function calls alone. I've written code using GLX/WGL previously to do this, though I'd like to avoid this.

我遇到了之前提出的这个问题: 如何获取/设置宽度和默认帧缓冲区的高度?

I came across this question that was asked previously: How to get/set the width and height of the default framebuffer?

但是,没有给出结论性的答案.关于获取视口/剪刀区域的宽度/高度的答案仅在窗口永不更改的情况下才有效,这在我的应用程序中可能很好,而其他答案将不起作用,因为默认"帧缓冲区不是实际的帧缓冲区对象,因此不能这样查询(如果注释者正确)

However, no conclusive answer was given. The answer talking about getting the width/height of the viewport/scissor area only works if the window never changes, which it very well may in my application, and the other answer won't work because the 'default' framebuffer isn't an actual framebuffer object and thus cannot be queried as such (if the commenters are correct)

那么,是否有任何方法可以单独使用OpenGL 3.3快速确定默认帧缓冲区/后缓冲区的大小,还是我需要依赖于另一子系统/写入平台相关的代码?

So, is there any method for determining the size of the default framebuffer/backbuffer on the fly using OpenGL 3.3 alone, or will I need to depend on another sub-system/write platform dependant code?

推荐答案

是否需要确定的答案?给出的结论性答案:不可以.

Conclusive answer desired? Conclusive answer granted: No.

OpenGL 4.5及其下面的所有版本均未提供查询默认帧缓冲区范围的方法.它也没有提供控制其大小的方法.

OpenGL 4.5, and all versions below it, does not provide a means to query the extents of the default framebuffer. Nor does it provide a means to control its size.

默认的帧缓冲区由窗口拥有; OpenGL默认的帧缓冲对象仅仅是一种绘制方法.

The default framebuffer is owned by the window; the OpenGL default framebuffer object is merely a way to draw into it.

这篇关于是否可以仅使用OpenGL确定默认帧缓冲区的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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