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

Stores a uniform value and applies it on synchronization. More...

#include <spk_uniform_object.hpp>

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

Public Member Functions

 UniformObject (GLint p_uniformLocation=-1)
 Creates a uniform wrapper for a specific location.
 UniformObject (const UniformObject &p_other)
 Copies uniform location and stored value.
UniformObjectoperator= (const UniformObject &p_other)
 Copies uniform location and stored value.
template<typename TType>
void set (TType &&p_value)
 Sets the uniform value and schedules synchronization.
template<typename TType>
const TType & get () const
 Retrieves the stored uniform value.
bool hasValue () const
 Indicates if a value is currently set.
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

Stores a uniform value and applies it on synchronization.

Constructor & Destructor Documentation

◆ UniformObject() [1/2]

spk::OpenGL::UniformObject::UniformObject ( GLint p_uniformLocation = -1)
explicit

Creates a uniform wrapper for a specific location.

Parameters
p_uniformLocationGLSL uniform location or -1 when unbound.
Here is the caller graph for this function:

◆ UniformObject() [2/2]

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

Copies uniform location and stored value.

Parameters
p_otherSource uniform wrapper.
Here is the call graph for this function:

Member Function Documentation

◆ get()

template<typename TType>
const TType & spk::OpenGL::UniformObject::get ( ) const
inline

Retrieves the stored uniform value.

Template Parameters
TTypeStored uniform type.
Returns
Const reference to the value.

◆ hasValue()

bool spk::OpenGL::UniformObject::hasValue ( ) const

Indicates if a value is currently set.

Returns
true when the variant is not monostate.

◆ operator=()

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

Copies uniform location and stored value.

Parameters
p_otherSource uniform wrapper.
Returns
Reference to this.
Here is the call graph for this function:

◆ set()

template<typename TType>
void spk::OpenGL::UniformObject::set ( TType && p_value)
inline

Sets the uniform value and schedules synchronization.

Template Parameters
TTypeSupported uniform type.
Parameters
p_valueValue to store.
Here is the call graph for this function:

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