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

Binds a TextureObject to a uniform sampler location and texture unit. More...

#include <spk_sampler_object.hpp>

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

Public Member Functions

 SamplerObject (GLint p_uniformLocation, GLuint p_textureUnitIndex=0)
 Builds a sampler targeting a uniform location and texture unit.
 SamplerObject (const SamplerObject &p_other)
 Copies sampler binding state from another sampler.
SamplerObjectoperator= (const SamplerObject &p_other)
 Copies sampler binding state from another sampler.
void bind (const TextureObject *p_texture)
 Binds a texture to this sampler.
void unbind ()
 Unbinds any texture from this sampler.
const TextureObjecttexture () const
 Returns the currently bound texture.
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.

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

Binds a TextureObject to a uniform sampler location and texture unit.

Constructor & Destructor Documentation

◆ SamplerObject() [1/2]

spk::OpenGL::SamplerObject::SamplerObject ( GLint p_uniformLocation,
GLuint p_textureUnitIndex = 0 )
explicit

Builds a sampler targeting a uniform location and texture unit.

Parameters
p_uniformLocationGLSL uniform location, or -1 if the shader uses layout(binding).
p_textureUnitIndexTexture unit index (default 0).
Here is the caller graph for this function:

◆ SamplerObject() [2/2]

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

Copies sampler binding state from another sampler.

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

Member Function Documentation

◆ bind()

void spk::OpenGL::SamplerObject::bind ( const TextureObject * p_texture)

Binds a texture to this sampler.

Parameters
p_textureTexture to bind.

◆ operator=()

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

Copies sampler binding state from another sampler.

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

◆ texture()

const TextureObject * spk::OpenGL::SamplerObject::texture ( ) const

Returns the currently bound texture.

Returns
Texture pointer or nullptr.

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