Magnum::GL::Renderbuffer class

Renderbuffer.

Attachable to framebuffer as render target, see Framebuffer documentation for more information.

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 either ARB_direct_state_access (part of OpenGL 4.5) or EXT_direct_state_access desktop extension 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() -> std::string
Renderbuffer label.
auto setLabel(const std::string& label) -> Renderbuffer&
Set renderbuffer label.
template<std::size_t size>
auto setLabel(const char(&label)[size]) -> Renderbuffer&
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.

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.

std::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(const std::string& 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.

template<std::size_t size>
Renderbuffer& Magnum::GL::Renderbuffer::setLabel(const char(&label)[size])

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

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

Set renderbuffer storage.

Parameters
internalFormat Internal format
size Renderbuffer size

If neither ARB_direct_state_access (part of OpenGL 4.5) nor EXT_direct_state_access desktop extension 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 neither ARB_direct_state_access (part of OpenGL 4.5) nor EXT_direct_state_access desktop extension is available, the renderbuffer is bound before the operation (if not already).