FramebuffersGL 3.0

glFramebufferRenderbuffer

Attaches a renderbuffer to the bound framebuffer.

Signature

void glFramebufferRenderbuffer(GLenum target, GLenum attachment,
                               GLenum renderbuffertarget, GLuint renderbuffer);

How it works

Connects a renderbuffer to one attachment point of the framebuffer bound to target. From then on, drawing into the framebuffer writes into it: depth values for GL_DEPTH_ATTACHMENT, depth and stencil for GL_DEPTH_STENCIL_ATTACHMENT.

The typical post-processing framebuffer pairs a colour texture (read in the next pass) with a depth-stencil renderbuffer (needed only for testing). Check the result with glCheckFramebufferStatus.

Parameters

targetGLenum

GL_FRAMEBUFFER.

attachmentGLenum

Which slot.

Common values

GL_COLOR_ATTACHMENT0 … n
Color outputs. The fragment shader's out variables write here (location 0 → attachment 0).
GL_DEPTH_ATTACHMENT
Depth buffer.
GL_STENCIL_ATTACHMENT
Stencil buffer.
GL_DEPTH_STENCIL_ATTACHMENT
Combined depth + stencil (e.g. GL_DEPTH24_STENCIL8).
renderbuffertargetGLenum

Must be GL_RENDERBUFFER.

renderbufferGLuint

The renderbuffer, already allocated.

Example

example.cpp
1glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo);
Official Khronos documentation