简体   繁体   中英

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.

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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