What's the concept of and differences between Framebuffer and Renderbuffer in OpenGL?

OpenglRenderingFramebuffer

Opengl Problem Overview


I'm confused about concept of Framebuffer and Renderbuffer. I know that they're required to render, but I want to understand them before use.

I know some bitmap buffer is required to store the temporary drawing result. The back buffer. And the other buffer is required to be seen on screen when those drawings are in progress. The front buffer. And flip them, and draw again. I know this concept, but it's hard to connect those objects to this concept.

What's the concept of and differences of them?

Opengl Solutions


Solution 1 - Opengl

The Framebuffer object is not actually a buffer, but an aggregator object that contains one or more attachments, which by their turn, are the actual buffers. You can understand the Framebuffer as C structure where every member is a pointer to a buffer. Without any attachment, a Framebuffer object has very low footprint.

Now each buffer attached to a Framebuffer can be a Renderbuffer or a texture.

The Renderbuffer is an actual buffer (an array of bytes, or integers, or pixels). The Renderbuffer stores pixel values in native format, so it's optimized for offscreen rendering. In other words, drawing to a Renderbuffer can be much faster than drawing to a texture. The drawback is that pixels uses a native, implementation-dependent format, so that reading from a Renderbuffer is much harder than reading from a texture. Nevertheless, once a Renderbuffer has been painted, one can copy its content directly to screen (or to other Renderbuffer, I guess), very quickly using pixel transfer operations. This means that a Renderbuffer can be used to efficiently implement the double buffer pattern that you mentioned.

Renderbuffers are a relatively new concept. Before them, a Framebuffer was used to render to a texture, which can be slower because a texture uses a standard format. It is still possible to render to a texture, and that's quite useful when one needs to perform multiple passes over each pixel to build a scene, or to draw a scene on a surface of another scene!

The OpenGL wiki has [this page][1] that shows more details and links.

[1]: http://www.opengl.org/wiki/Renderbuffer_Object "this page"

Solution 2 - Opengl

This page has some details which I think explain the difference quite nicely. Firstly:

> The final rendering destination of the OpenGL pipeline is called [the] framebuffer.

Whereas:

> Renderbuffer Object
In addition, renderbuffer object is newly introduced for offscreen rendering. It allows to render a scene directly to a renderbuffer object, instead of rendering to a texture object. Renderbuffer is simply a data storage object containing a single image of a renderable internal format. It is used to store OpenGL logical buffers that do not have corresponding texture format, such as stencil or depth buffer.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestioneonilView Question on Stackoverflow
Solution 1 - OpenglfernacoloView Answer on Stackoverflow
Solution 2 - OpenglChrisFView Answer on Stackoverflow