Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenGL FBO renderbuffer or texture attatchment

Tags:

In what cases would I want to have a renderbuffer attachment in an OpenGL FBO, instead of a texture attachment, besides for the default framebuffer? As, a texture attachment seems far more versatile.

like image 960
Skyler Saleh Avatar asked Mar 27 '11 04:03

Skyler Saleh


People also ask

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.

How do I render FBO?

Basically the steps are: Create FBO with depth renderbuffer and color texture attachment. To render to FBO unbind the target texture, bind FBO, render to FBO. Unbind FBO, bind texture, render. Show activity on this post.

What is the default framebuffer?

The Default Framebuffer is the Framebuffer that OpenGL is created with. It is created along with the OpenGL Context. Like Framebuffer Objects, the default framebuffer is a series of images. Unlike FBOs, one of these images usually represents what you actually see on some part of your screen.

What is frame buffer 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).


2 Answers

Textures provide more features to you (sampling!, formats variety) and hence are more likely subject to performance loss.

The answer is simple: use Textures wherever you have to sample from the surface (no alternatives).

Use Render buffers wherever you don't need to sample. The driver may or may not decide to store your pixel data more effectively based on your expressed intention of not doing sampling. You can use GL blitting afterwards to do something with the result.

like image 66
kvark Avatar answered Jan 04 '23 23:01

kvark


Extending the question to OpenGL|ES, another reason to use RenderBuffers instead of textures is also that textures may not be supported in some configurations and prevent you from building a valid FBO. I specifically think about depth textures, which are not natively supported on some hardware, for instance nVidia Tegra 2/3.

like image 29
gsourima Avatar answered Jan 04 '23 22:01

gsourima