1

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?

NeomerArcana
  • 1,978
  • 3
  • 23
  • 50
  • 1
    `glGet()` for `GL_MAX_VIEWPORT_DIMS` gives you 1600x900? What kind of device is this? It seems rather unusual. It's typically similar to the maximum texture size. Something like 4096x4096 or 8192x8192 on newer devices. – Reto Koradi Apr 13 '15 at 05:02
  • @RetoKoradi It's almost certainly not my card. I'm using an AMD Radeon HD 7980 with the most recent drivers. I'm running OpenGL 4 in my application. Max tex size for this card (querying OpenGL) is 16384 – NeomerArcana Apr 13 '15 at 05:10
  • 1
    And you are really getting 1600x900 when you query `GL_MAX_VIEWPORT_DIMS`? – Reto Koradi Apr 13 '15 at 05:16
  • You know, I made an assumption. No, `glGetIntergerv` is giving me 16384 as well. But I've double checked, and there's no other glViewport calls being made after I set it to the size of my framebuffer... – NeomerArcana Apr 13 '15 at 05:18
  • And it's not rendering to the entire FBO? Not sure what exactly is going on in your case. I explained how it's supposed to behave in the answer below. – Reto Koradi Apr 13 '15 at 05:47

1 Answers1

3

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.

Reto Koradi
  • 53,228
  • 8
  • 93
  • 133
  • 2
    Bam, `glScissor` was the problem. In my class that sets up my OpenGL context etc, I was `glEnable`ing `GL_SCISSOR_TEST` and setting it to my viewport size. Thanks for your help again @RetoKoradi , I'm sure you've answered previous questions of mine. – NeomerArcana Apr 13 '15 at 06:00