Sparkle 0.0.1
Loading...
Searching...
No Matches
spk::OpenGL::FrameBufferObject Class Reference

RAII wrapper for an OpenGL framebuffer with typed attachments. More...

#include <spk_frame_buffer_object.hpp>

Inheritance diagram for spk::OpenGL::FrameBufferObject:
Inheritance graph
Collaboration diagram for spk::OpenGL::FrameBufferObject:
Collaboration graph

Classes

class  Attachment
 Texture attachment with basic format presets for FBOs. More...

Public Member Functions

 FrameBufferObject ()
 Constructs an empty framebuffer.
 FrameBufferObject (const FrameBufferObject &p_other)
 Copies framebuffer state, attachments, and size from another instance.
FrameBufferObjectoperator= (const FrameBufferObject &p_other)
 Assigns framebuffer content from another instance.
void addAttachment (const GLuint &p_index, Attachment::Type p_type)
 Adds an attachment at the given color index.
Attachmentattachment (const GLuint &p_index)
 Accesses an attachment by index.
const Attachmentattachment (const GLuint &p_index) const
 Accesses an attachment by index.
bool hasAttachment (const GLuint &p_index) const
 Checks if an attachment exists.
void resize (const spk::Vector2UInt &p_size)
 Resizes all attachments and viewport to the given size.
const spk::Vector2UIntsize () const
 Returns current framebuffer size.
const spk::OpenGL::ViewRegionviewRegion () const
 Returns the view region associated with this framebuffer.
void clear (const spk::Color &p_color, const ViewRegion::ClearMask &p_clearMask)
 Clears the framebuffer with the given color and mask.
spk::OpenGL::TextureObject exportAttachmentTexture (GLuint p_index)
 Exports an attachment texture by value (copy).
Public Member Functions inherited from spk::ActivableObject
 ActivableObject ()
 Builds a deactivated object.
 ActivableObject (ActivationStatus p_initial)
 Builds with a custom initial activation state.
void activate ()
 Sets the state to Activated.
void deactivate ()
 Sets the state to Deactivated.
void toggle ()
 Toggles between activated and deactivated states.
bool isActive () const
 Checks whether the object is currently activated.
Contract addActivationCallback (const Job &p_callback)
 Registers a callback executed when the object activates.
Contract addDeactivationCallback (const Job &p_callback)
 Registers a callback executed when the object deactivates.
Public Member Functions inherited from spk::StatefulObject< ActivationStatus >
 StatefulObject (const ActivationStatus &p_initialState)
 Builds with an initial state.
StatefulObjectoperator= (const StatefulObject &p_other)=delete
void setState (const ActivationStatus &p_newState)
 Sets a new state and triggers callbacks registered for it.
ActivationStatus state () const
 Returns the current state.
Contract addCallback (const ActivationStatus &p_state, const Job &p_callback)
 Subscribes a callback for a specific state.
Public Member Functions inherited from spk::SynchronizableObject
void requestSynchronization () noexcept
 Marks the object as needing synchronization.
bool needsSynchronization () const noexcept
 Checks if synchronization is pending.
void synchronize ()
 Performs synchronization if requested.
void forceSynchronization ()
 Forces synchronization regardless of current flag.

Additional Inherited Members

Public Types inherited from spk::ActivableObject
using Contract = StatefulObject<ActivationStatus>::Contract
 Subscription handle controlling callback lifetime.
using Job = StatefulObject<ActivationStatus>::Job
 Callback signature executed on activation state changes.
Public Types inherited from spk::StatefulObject< ActivationStatus >
using Contract
 Handle allowing subscribers to manage callback lifetimes.
using Job
 Callable invoked when the object transitions to a state.

Detailed Description

RAII wrapper for an OpenGL framebuffer with typed attachments.

Constructor & Destructor Documentation

◆ FrameBufferObject()

spk::OpenGL::FrameBufferObject::FrameBufferObject ( const FrameBufferObject & p_other)

Copies framebuffer state, attachments, and size from another instance.

Parameters
p_otherFramebuffer to duplicate.
Here is the call graph for this function:

Member Function Documentation

◆ addAttachment()

void spk::OpenGL::FrameBufferObject::addAttachment ( const GLuint & p_index,
Attachment::Type p_type )

Adds an attachment at the given color index.

Parameters
p_indexAttachment index (color slot).
p_typeAttachment type/format.
Here is the call graph for this function:

◆ attachment() [1/2]

FrameBufferObject::Attachment & spk::OpenGL::FrameBufferObject::attachment ( const GLuint & p_index)

Accesses an attachment by index.

Parameters
p_indexAttachment index.
Returns
Mutable attachment.
Here is the caller graph for this function:

◆ attachment() [2/2]

const FrameBufferObject::Attachment & spk::OpenGL::FrameBufferObject::attachment ( const GLuint & p_index) const

Accesses an attachment by index.

Parameters
p_indexAttachment index.
Returns
Const attachment.

◆ clear()

void spk::OpenGL::FrameBufferObject::clear ( const spk::Color & p_color,
const ViewRegion::ClearMask & p_clearMask )

Clears the framebuffer with the given color and mask.

Parameters
p_colorClear color.
p_clearMaskBuffer mask.
Here is the call graph for this function:

◆ exportAttachmentTexture()

spk::OpenGL::TextureObject spk::OpenGL::FrameBufferObject::exportAttachmentTexture ( GLuint p_index)

Exports an attachment texture by value (copy).

Parameters
p_indexAttachment index.
Returns
Texture copy.
Here is the call graph for this function:

◆ hasAttachment()

bool spk::OpenGL::FrameBufferObject::hasAttachment ( const GLuint & p_index) const

Checks if an attachment exists.

Parameters
p_indexAttachment index.
Returns
true when present.

◆ operator=()

FrameBufferObject & spk::OpenGL::FrameBufferObject::operator= ( const FrameBufferObject & p_other)

Assigns framebuffer content from another instance.

Parameters
p_otherFramebuffer to copy from.
Returns
Reference to this framebuffer.
Here is the call graph for this function:

◆ resize()

void spk::OpenGL::FrameBufferObject::resize ( const spk::Vector2UInt & p_size)

Resizes all attachments and viewport to the given size.

Parameters
p_sizeNew dimensions.
Here is the call graph for this function:

◆ size()

const spk::Vector2UInt & spk::OpenGL::FrameBufferObject::size ( ) const

Returns current framebuffer size.

Returns
Dimensions.

◆ viewRegion()

const spk::OpenGL::ViewRegion & spk::OpenGL::FrameBufferObject::viewRegion ( ) const

Returns the view region associated with this framebuffer.

Returns
Const reference to the view region.

The documentation for this class was generated from the following files: