Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Frame buffer object, Render buffer object and texture?

what is the Difference between Frame buffer object, Render buffer object and texture? In what context they will be used?

like image 582
Megharaj Avatar asked Apr 12 '12 04:04

Megharaj


People also ask

What is a render buffer?

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.

What is the different between Renderbuffer and framebuffer?

Creating a renderbuffer object is similar to texture objects, the difference being that this object is specifically designed to be used as a framebuffer attachment, instead of a general purpose data buffer like a texture.

What are frame buffers in OpenGL?

A Framebuffer is a collection of buffers that can be used as the destination for rendering. OpenGL has two kinds of framebuffers: the Default Framebuffer, which is provided by the OpenGL Context; and user-created framebuffers called Framebuffer Objects (FBOs).

When should I use Renderbuffer?

Renderbuffer Objects are OpenGL Objects that contain images. They are created and used specifically with Framebuffer Objects. They are optimized for use as render targets, while Textures may not be, and are the logical choice when you do not need to sample (i.e. in a post-pass shader) from the produced image.


2 Answers

Framebuffer

A framebuffer is not actually a buffer. It's an abstraction for an object that defines parameters for a draw operation. It's a small object that holds one or more attachments, which are themselves the actual buffers. Understand the framebuffer as a C struct with many fields. Each field (each attachment in OpenGL terms) can be a pointer to a render buffer, texture, depth buffer, etc.

Texture

An array of standard pixels. This is an actual buffer and can be attached to a framebuffer as the destination of pixels being drawn. Each pixel in a texture typically contains color components and an alpha value (a pixel in the texture can be translated from and into an RGBA quad with 4 floats).

After drawing to the framebuffer that contains a texture attached, it's possible to read pixels from the texture to use in another draw operation. This allows, for instance, multi-pass drawing or drawing a scene inside another scene.

Textures can be attached to a shader program and used as samplers.

Renderbuffer

An array of native pixels. The renderbuffer is just like a texture, but stores pixels using an internal format. It's optimized for pixel transfer operations. It can be attached to a framebuffer as the destination of pixels being drawn, then quickly copied to the viewport or another framebuffer. This allows implementing of double buffer algorithms, where the next scene is drawn while the previous scene is exhibited.

A renderbuffer can also be used to store depth and stencil information that is used just for a single draw procedure. This is possible because only the implementation itself needs to read renderbuffer data, and tends to be faster than textures, because uses a native format.

Because this uses a native format, a renderbuffer cannot be attached to a shader program and used as a sampler.

like image 191
fernacolo Avatar answered Sep 17 '22 17:09

fernacolo


A framebuffer object is more or less just a managing construct. It manages a complete framebuffer at a whole with all its sub-buffers, like the color buffers, the depth buffer and the stencil buffer.

The textures or renderbuffers comprise the actual storage for the individual sub-buffers. This way you can have multiple color buffers, a depth buffer and a stencil buffer, all stored in different textures/renderbuffers. But they all together make up a single logical framebuffer into which you render.

So a final fragment (you may call it pixel, but actually isn't one yet) written to the framebuffer has one or more color values, a depth value and a stencil value and they all end up in different sub-buffers of the framebuffer.

like image 24
Christian Rau Avatar answered Sep 17 '22 17:09

Christian Rau