Reputation: 2279
I gather that I can create a Framebuffer with Renderbuffer and Texture attachments in whatever size I want (that's supported by the card). However, how can I actually draw to the whole thing when glViewport
is limited by the GL_MAX_VIEWPORT_DIMS
, which needs to be at least as large as the window, and in my case, is no larger. https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGet.xml
In my use case I'm looking to create a shadow cubemap for a point light that's a nice big sexy size. My window is 1600x900. Due to some post-processing affects that render to quads, which are downsampled, I have previous calls to glViewport
that's setting the size to various things.
But I can't make it any larger than the window, so I can't ever draw to the outside areas of my Framebuffer?
Or do games never exceed the size of the window when creating framebuffers?
Upvotes: 1
Views: 3725
Reputation: 54592
The language in the spec talking about the screen size is only part of the guaranteed minimum that needs to be supported by an implementation. The spec says:
The maximum viewport dimensions must be greater than or equal to the larger of the visible dimensions of the display being rendered to (if a display exists), and the largest renderbuffer image which can be successfully created and attached to a framebuffer object [..]
This means that GL_MAX_VIEWPORT_DIMS
will also be at least as large as GL_MAX_RENDERBUFFER_SIZE
. The guaranteed minimum for that limit is version dependent. It's for example 1024 in OpenGL 3.3, and 16,384 in OpenGL 4.5.
If you query GL_MAX_VIEWPORT_DIMS
, you will mostly find it to be considerably larger than the screen size. It's common for it to be the same as the maximum texture size. So it shouldn't normally stop you from rendering to any texture/renderbuffer you can create.
Before rendering to the FBO, you need to make sure that you call glViewport()
with the size of the render targets in your FBO. Note that the viewport size is not part of the FBO state, so you have to do this each time before starting to render to a different framebuffer (FBO or default framebuffer).
If you have the scissor test enabled, you will also need to make sure that you either disable it, or update the scissor rectangle, when switching to a FBO that is larger than your default framebuffer.
Upvotes: 3