简体   繁体   English

是否可以仅使用OpenGL确定默认帧缓冲区的大小?

[英]Is it possible to determine the size of the default framebuffer using OpenGL only?

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. 理想情况下,我的目标是使每个子系统都不依赖于引擎的其他部分。

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 FrameBuffer,Direct3D RenderTarget或默认的后缓冲),而无需获取程序员可以跟踪它,而不必依赖于窗口子系统/另一个库,也不必编写与系统有关的代码。

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. 目前,我正在对渲染子系统的OpenGL实现进行编码,我想检查是否可以仅使用OpenGL 3.3函数调用来获得后缓冲区/默认帧缓冲区的大小。 I've written code using GLX/WGL previously to do this, though I'd like to avoid this. 我曾经使用GLX / WGL编写过代码,尽管我想避免这种情况。

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) 关于获取视口/剪刀区域的宽度/高度的答案仅在窗口永不更改的情况下才有效,这在我的应用程序中可能很好,而其他答案将不起作用,因为“默认”帧缓冲区不是实际的帧缓冲区对象,因此无法这样查询(如果注释器正确)

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? 因此,是否有任何方法可以单独使用OpenGL 3.3快速确定默认帧缓冲区/后缓冲区的大小,还是需要依赖于另一个子系统/写入平台相关的代码?

Conclusive answer desired? 想要确定的答案? Conclusive answer granted: No. 给出的结论性答案:否。

OpenGL 4.5, and all versions below it, does not provide a means to query the extents of the default framebuffer. OpenGL 4.5及其下面的所有版本均未提供查询默认帧缓冲区范围的方法。 Nor does it provide a means to control its size. 它也没有提供控制其大小的方法。

The default framebuffer is owned by the window; 窗口拥有默认的帧缓冲区。 the OpenGL default framebuffer object is merely a way to draw into it. OpenGL默认的framebuffer对象仅仅是一种吸收它的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM