What are the usage differences between multiple viewports vs multiple framebuffers?

Viewed 124

I'm quite new learn OpenGL and the topic of framebuffers is quite confusing to me. I read that some uses of it is to generate a second target to render to, allowing us to make mirrors etc. However, wouldn't the use of glViewport() be enough, where you can specify different rendering operations to different parts of the same framebuffer? What are the usage differences between the 2 and when should I prefer to use each one?

1 Answers

The two concepts are entirely orthogonal; they do not at all map to each other.

In theory, you can perform some forms of off-screen rendering by rendering to a non-visible part of the framebuffer's images. Assuming that there are non-visible parts of the framebuffer's images. Which, assuming we're talking about the default framebuffer, is entirely out of your control. You don't get to determine how big the backing image data is; that's controlled by the OS, typically through the size of the window you're rendering to.

With a proper framebuffer object, you don't have to try to make the OS give you more space than is visible in the window. You can just do whatever.

The viewport exists to allow you to pick where you render to within the renderable area of a framebuffer. A framebuffer object exists to allow you to allocate and manage the images you render to, thus giving you complete control over all aspects of the framebuffer. This includes using non-visible color formats (integer formats, floating-point formats, for example), using multiple render targets at once, having direct control over multisample usage, and being able to read from the render targets as textures without having to do a slow copy operation from the framebuffer.

The two really don't have anything to do with one another.

Related