Magnum::GL::Renderbuffer class

Renderbuffer.

Attachable to a framebuffer as render target, see the Framebuffer class for a detailed usage example.

Performance optimizations

The engine tracks currently bound renderbuffer to avoid unnecessary calls to glBindRenderbuffer() in setStorage(). Renderbuffer limits and implementation-defined values (such as maxSize()) are cached, so repeated queries don't result in repeated glGet() calls.

If ARB_direct_state_access (part of OpenGL 4.5) is available, functions setStorage() and setStorageMultisample() use DSA to avoid unnecessary calls to glBindRenderbuffer(). See their respective documentation for more information.

Base classes

class AbstractObject
Base for all OpenGL objects.

Public static functions

static auto maxSize() -> Int
Max supported renderbuffer size.
static auto maxSamples() -> Int
Max supported sample count.
static auto wrap(GLuint id, ObjectFlags flags = {}) -> Renderbuffer
Wrap existing OpenGL renderbuffer object.

Constructors, destructors, conversion operators

Renderbuffer() explicit
Constructor.
Renderbuffer(NoCreateT) explicit noexcept
Construct without creating the underlying OpenGL object.
Renderbuffer(const Renderbuffer&) deleted
Copying is not allowed.
Renderbuffer(Renderbuffer&& other) noexcept
Move constructor.
~Renderbuffer()
Destructor.

Public functions

auto operator=(const Renderbuffer&) -> Renderbuffer& deleted
Copying is not allowed.
auto operator=(Renderbuffer&& other) -> Renderbuffer& noexcept
Move assignment.
auto id() const -> GLuint
OpenGL renderbuffer ID.
auto release() -> GLuint
Release OpenGL object.
auto label() -> Containers::String
Renderbuffer label.
auto setLabel(Containers::StringView label) -> Renderbuffer&
Set renderbuffer label.
void setStorage(RenderbufferFormat internalFormat, const Vector2i& size)
Set renderbuffer storage.
void setStorageMultisample(Int samples, RenderbufferFormat internalFormat, const Vector2i& size)
Set multisample renderbuffer storage.

Function documentation

static Int Magnum::GL::Renderbuffer::maxSize()

Max supported renderbuffer size.

The result is cached, repeated queries don't result in repeated OpenGL calls.

static Int Magnum::GL::Renderbuffer::maxSamples()

Max supported sample count.

The result is cached, repeated queries don't result in repeated OpenGL calls. If neither OpenGL ES 3.0 nor ES extension ANGLE_framebuffer_multisample / NV_framebuffer_multisample is available, returns 0.

static Renderbuffer Magnum::GL::Renderbuffer::wrap(GLuint id, ObjectFlags flags = {})

Wrap existing OpenGL renderbuffer object.

Parameters
id OpenGL renderbuffer ID
flags Object creation flags

The id is expected to be of an existing OpenGL renderbuffer object. Unlike renderbuffer created using constructor, the OpenGL object is by default not deleted on destruction, use flags for different behavior.

Magnum::GL::Renderbuffer::Renderbuffer() explicit

Constructor.

Generates new OpenGL renderbuffer object. If ARB_direct_state_access (part of OpenGL 4.5) is not available, the renderbuffer is created on first use.

Magnum::GL::Renderbuffer::Renderbuffer(NoCreateT) explicit noexcept

Construct without creating the underlying OpenGL object.

The constructed instance is equivalent to moved-from state. Useful in cases where you will overwrite the instance later anyway. Move another object over it to make it useful.

This function can be safely used for constructing (and later destructing) objects even without any OpenGL context being active. However note that this is a low-level and a potentially dangerous API, see the documentation of NoCreate for alternatives.

Magnum::GL::Renderbuffer::~Renderbuffer()

Destructor.

Deletes associated OpenGL renderbuffer object.

GLuint Magnum::GL::Renderbuffer::release()

Release OpenGL object.

Releases ownership of OpenGL renderbuffer object and returns its ID so it is not deleted on destruction. The internal state is then equivalent to moved-from state.

Containers::String Magnum::GL::Renderbuffer::label()

Renderbuffer label.

The result is not cached, repeated queries will result in repeated OpenGL calls. If OpenGL 4.3 / OpenGL ES 3.2 is not supported and neither KHR_debug (covered also by ANDROID_extension_pack_es31a) nor EXT_debug_label desktop or ES extension is available, this function returns empty string.

Renderbuffer& Magnum::GL::Renderbuffer::setLabel(Containers::StringView label)

Set renderbuffer label.

Returns Reference to self (for method chaining)

Default is empty string. If OpenGL 4.3 / OpenGL ES 3.2 is not supported and neither KHR_debug (covered also by ANDROID_extension_pack_es31a) nor EXT_debug_label desktop or ES extension is available, this function does nothing.

void Magnum::GL::Renderbuffer::setStorage(RenderbufferFormat internalFormat, const Vector2i& size)

Set renderbuffer storage.

Parameters
internalFormat Internal format
size Renderbuffer size

If ARB_direct_state_access (part of OpenGL 4.5) is available, the renderbuffer is bound before the operation (if not already).

void Magnum::GL::Renderbuffer::setStorageMultisample(Int samples, RenderbufferFormat internalFormat, const Vector2i& size)

Set multisample renderbuffer storage.

Parameters
samples Sample count
internalFormat Internal format
size Renderbuffer size

If ARB_direct_state_access (part of OpenGL 4.5) is available, the renderbuffer is bound before the operation (if not already).