Direct State AccessGL 4.5

glNamedFramebufferRenderbuffer

Attaches a renderbuffer to a framebuffer, usually as its depth-stencil buffer.

Signature

void glNamedFramebufferRenderbuffer(GLuint framebuffer, GLenum attachment,
                                    GLenum renderbuffertarget, GLuint renderbuffer);

How it works

The renderbuffer counterpart of glNamedFramebufferTexture. A post-processing framebuffer typically has a colour texture (read later) and a depth-stencil renderbuffer (only needed while drawing).

Parameters

framebufferGLuint

The framebuffer.

attachmentGLenum

Where to attach.

Common values

GL_COLOR_ATTACHMENTi
Colour output number i (GL_COLOR_ATTACHMENT0, 1, …).
GL_DEPTH_ATTACHMENT
The depth buffer.
GL_STENCIL_ATTACHMENT
The stencil buffer.
GL_DEPTH_STENCIL_ATTACHMENT
Both at once, for a GL_DEPTH24_STENCIL8 image.
renderbuffertargetGLenum

Always GL_RENDERBUFFER.

renderbufferGLuint

The renderbuffer, or 0 to detach.

Tips & pitfalls

  • Direct State Access (GL 4.5): the object is passed as a parameter, so nothing needs to be bound and no global state is disturbed.

Errors

When the call is invalid it does nothing and sets an error, which glGetError returns:

GL_INVALID_ENUM
renderbuffertarget is not GL_RENDERBUFFER.

Example

example.cpp
1glNamedFramebufferRenderbuffer(fbo, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo);
Official Khronos documentation