nCine::GLFramebuffer class

Wraps an OpenGL framebuffer object.

Manages the lifetime of a single OpenGL framebuffer object (FBO) and its attachments. Renderbuffers are owned by the framebuffer and attached or detached as color, depth or stencil targets; textures can be attached as well. Binding is cached separately for the read and draw targets so that redundant glBindFramebuffer() calls are skipped. Also configures the draw buffers and checks completeness.

Public static variables

static const std::uint32_t MaxDrawbuffers
Maximum number of color draw buffers.
static const std::uint32_t MaxRenderbuffers
Maximum number of attached renderbuffers.

Public static functions

static auto Unbind() -> bool
Unbinds any framebuffer from both the read and draw targets.
static auto Unbind(GLenum target) -> bool
Unbinds any framebuffer from the specified target (read, draw or both).

Constructors, destructors, conversion operators

GLFramebuffer() explicit
~GLFramebuffer()
GLFramebuffer(const GLFramebuffer&) deleted

Public functions

auto operator=(const GLFramebuffer&) -> GLFramebuffer& deleted
auto GetGLHandle() const -> GLuint
Returns the OpenGL handle of the framebuffer object.
auto Bind() const -> bool
Binds the framebuffer to both the read and draw targets.
auto Bind(GLenum target) const -> bool
Binds the framebuffer to the specified target (read, draw or both).
auto GetDrawbufferCount() const -> std::uint32_t
Returns the number of active color draw buffers.
auto DrawBuffers(std::uint32_t numDrawBuffers) -> bool
Sets the number of color attachments enabled as draw buffers.
auto GetRenderbufferCount() const -> std::uint32_t
Returns the number of attached renderbuffers.
auto AttachRenderbuffer(const char* label, GLenum internalFormat, GLsizei width, GLsizei height, GLenum attachment) -> bool
Creates a renderbuffer with a debug label and attaches it to the given attachment point.
auto AttachRenderbuffer(GLenum internalFormat, GLsizei width, GLsizei height, GLenum attachment) -> bool
Creates a renderbuffer and attaches it to the given attachment point.
auto DetachRenderbuffer(GLenum internalFormat) -> bool
Detaches and destroys the renderbuffer at the given attachment point.
void AttachTexture(GLTexture& texture, GLenum attachment)
Attaches a texture to the given attachment point.
void DetachTexture(GLenum attachment)
Detaches any texture from the given attachment point.
void Invalidate(GLsizei numAttachments, const GLenum* attachments)
Hints that the contents of the listed attachments are no longer needed.
auto IsStatusComplete() -> bool
Returns true if the framebuffer is complete and ready for rendering.
void SetObjectLabel(StringView label)
Sets an OpenGL object label for the framebuffer, for debugging.