easy-gl › Renderbuffer
Renderbuffer
Manages an OpenGL Renderbuffer Object (RBO). Renderbuffers are optimised storage for framebuffer attachments that do not need to be sampled in shaders — typically depth and stencil.
When to use Renderbuffer vs Texture
| Use | Renderbuffer | Texture |
|---|---|---|
| Sample in shader | No | Yes |
| Driver storage efficiency | Usually better | General purpose |
| MSAA storage | Yes | Yes (Texture2DMultisample) |
| Depth/stencil | Common choice | Needed for shadow maps |
Depth renderbuffer
easygl::Renderbuffer depthRbo;
depthRbo.create();
depthRbo.bind();
depthRbo.set_storage(easygl::InternalFormat::DepthComponent24, width, height);
Depth + stencil packed
depthStencilRbo.set_storage(
easygl::InternalFormat::Depth24Stencil8, width, height);
MSAA renderbuffer
easygl::Renderbuffer msColor;
msColor.create();
msColor.bind();
msColor.set_storage_multisample(
4, // 4× MSAA samples
easygl::InternalFormat::Rgba8,
width, height);
Attaching to a framebuffer
fbo.attach_renderbuffer(
easygl::FramebufferTarget::Framebuffer,
easygl::FramebufferAttachment::Depth,
depthRbo.native_handle());
Method reference
| Method | Description |
|---|---|
create() | Allocate GL RBO handle. |
destroy() | Free handle. Noexcept. |
bind() | Bind to GL_RENDERBUFFER target. |
unbind() [static] | Bind renderbuffer 0. |
set_storage(format, width, height) | Allocate storage for the renderbuffer. |
set_storage_multisample(samples, format, w, h) | Allocate MSAA storage. |
is_created() | True if GL handle allocated. |
native_handle() | Raw GL integer ID. |
reset_handle_no_gl() | Context-loss recovery. |