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

孤人 提交于 2019-12-24 05:16:09

问题


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.

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)

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?


回答1:


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. 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.



来源:https://stackoverflow.com/questions/34118291/is-it-possible-to-determine-the-size-of-the-default-framebuffer-using-opengl-onl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!