Direct State AccessGL 4.5
glNamedRenderbufferStorage
Allocates a renderbuffer's image: its format and size.
Signature
void glNamedRenderbufferStorage(GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height);
How it works
The DSA form of glRenderbufferStorage. The size must match the other attachments of the framebuffer, normally the window size, so call it again (or recreate the renderbuffer) when the window is resized.
Parameters
renderbufferGLuint
From glCreateRenderbuffers.
internalformatGLenum
Sized format of the image.
Common values
- GL_DEPTH24_STENCIL8
- 24-bit depth + 8-bit stencil: the usual choice.
- GL_DEPTH_COMPONENT32F
- Float depth, for reversed Z.
- GL_RGBA8 / GL_RGBA16F
- A colour image you will only blit, never sample.
widthGLsizei
Width in pixels.
heightGLsizei
Height in pixels.
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.
For MSAA use glNamedRenderbufferStorageMultisample, with the same sample count on every attachment.
Errors
When the call is invalid it does nothing and sets an error, which glGetError returns:
- GL_INVALID_VALUE
- width or height is larger than GL_MAX_RENDERBUFFER_SIZE.
- GL_INVALID_ENUM
- internalformat is not a renderable format.
Example
example.cpp
1glNamedRenderbufferStorage(rbo, GL_DEPTH24_STENCIL8, w, h);