Radium Engine  1.5.20
Loading...
Searching...
No Matches
Ra::Engine::Data::RenderParameters Class Referencefinal

Management of shader parameters with automatic binding of a named parameter to the corresponding glsl uniform. More...

#include <Engine/Data/RenderParameters.hpp>

+ Inheritance diagram for Ra::Engine::Data::RenderParameters:
+ Collaboration diagram for Ra::Engine::Data::RenderParameters:

Public Types

using TextureInfo = std::pair<Data::Texture*, int>
 Special type for Texture parameter.
 
using BindableTypes
 List of bindable types, to be used with static visitors.
 
- Public Types inherited from Ra::Core::VariableSet
template<typename T >
using VariableContainer = std::map<std::string, T>
 Container type for the mapping name->value of variables with type T.
 
template<typename T >
using Variable = typename VariableContainer<T>::value_type
 Variable type as stored in the VariableSet.
 
template<typename T >
using VariableType = typename Variable<T>::second_type
 Type of the variable value.
 
template<typename T >
using VariableHandle = typename VariableContainer<T>::iterator
 Handle of a variable A handle on a variable with type T is an iterator into the BaseContainer. De-referencing the handle give access to a non const pair <const std::string, T> (BaseContainer<T>::value_type). VariableHandle validity follows the rules of BaseContainer<T>::iterator validity.
 
template<typename H >
using VariableTypeFromHandle = typename std::iterator_traits<H>::value_type::second_type
 Type of the variable referenced by a VariableHandle.
 

Public Member Functions

template<typename T , typename std::enable_if< std::is_base_of< Data::Texture, T >::value, bool >::type = true>
void setTexture (const std::string &name, T *tex, int texUnit=-1)
 Adding a texture parameter.
 
void setVariable (const std::string &name, RenderParameters &rp)
 overload create ref wrapper for RenderParameters variable
 
void setVariable (const std::string &name, const RenderParameters &rp)
 
void bind (const Data::ShaderProgram *shader) const
 Bind the parameter uniform on the shader program.
 
template<typename T >
auto setVariable (const std::string &name, const T &value) -> std::pair< VariableHandle< T >, bool >
 reset (or set if the variable does not exist yet) the value of the variable.
 
- Public Member Functions inherited from Ra::Core::VariableSet
template<typename F , typename U >
void visitStatic (F &&visitor, U &userParams) const
 
template<typename F , typename U >
void visitStatic (F &&visitor, U &&userParams) const
 
 VariableSet ()
 
 VariableSet (const VariableSet &other) noexcept
 A VariableSet is copyable.
 
 VariableSet (VariableSet &&other) noexcept
 A VariableSet is movable.
 
auto operator= (const VariableSet &other) -> VariableSet &
 Copy assignment operator.
 
auto operator= (VariableSet &&other) noexcept -> VariableSet &
 Move assignment operator.
 
void clear ()
 remove all elements from the container
 
void mergeKeepVariables (const VariableSet &from)
 Merge the VariableSet from into this.
 
void mergeReplaceVariables (const VariableSet &from)
 Merge the VariableSet from into this.
 
size_t size () const
 Gets the total number of variables (of any type)
 
auto getStoredTypes () const -> const std::vector< std::type_index > &
 Gets the stored data type.
 
template<typename T >
auto insertVariable (const std::string &name, const T &value) -> std::pair< VariableHandle< T >, bool >
 Add a variable, i.e. an association name->value, into the container.
 
template<typename T >
auto getVariable (const std::string &name) const -> const T &
 get the value of the given variable
 
template<typename T >
auto getVariable (const std::string &name) -> T &
 
template<typename T >
auto getVariableHandle (const std::string &name) const -> const VariableHandle< T >
 get the handle on the variable with the given name
 
template<typename H >
bool isHandleValid (const H &handle) const
 Test the validity of a handle.
 
template<typename T >
auto setVariable (const std::string &name, const T &value) -> std::pair< VariableHandle< T >, bool >
 reset (or set if the variable does not exist yet) the value of the variable.
 
template<typename T >
bool deleteVariable (const std::string &name)
 Remove a variable, i.e. a name->value association.
 
template<typename H >
bool deleteVariable (H &handle)
 delete a variable from its handle
 
template<typename T >
auto existsVariable (const std::string &name) const -> Utils::optional< VariableHandle< T > >
 test the existence of the given variable
 
template<typename T >
auto existsVariableType () const -> Utils::optional< VariableContainer< T > * >
 Test if the storage supports a given variable type.
 
template<typename T >
bool deleteAllVariables ()
 Removes all variables of the given type.
 
template<typename T >
auto getAllVariables () const -> VariableContainer< T > &
 Get the whole container for variables of a given type.
 
template<typename H >
auto getAllVariablesFromHandle (const H &handle) -> VariableContainer< VariableTypeFromHandle< H > > &
 Get the whole container for variables of the same type than the given handled variable.
 
template<typename T >
size_t numberOf () const
 Get the number of variables of the given type.
 
template<typename F >
void visit (F &&visitor) const
 Visit the container using a user defined visitor.
 
template<typename F , typename T >
void visit (F &&visitor, T &userParams) const
 overload of the static visit method to allow a parameter pass by reference
 
template<typename F , typename T >
void visit (F &&visitor, T &&userParams) const
 overload of the static visit method to allow a parameter pass by rvalue reference
 

Detailed Description

Management of shader parameters with automatic binding of a named parameter to the corresponding glsl uniform.

Note
Automatic binding is only available for supported type described in BindableTypes.
Enums are stored according to their underlying_type. Enum management is automatic except when requesting for the associated uniformBindableSet. To access bindable set containing a given enum with type Enum, use getAllVariable<typename std::underlying_type<typename Enum>::type>

Definition at line 34 of file RenderParameters.hpp.

Member Typedef Documentation

◆ BindableTypes

Initial value:
Core::Utils::TypeList<bool,
Core::Utils::Color,
int,
uint,
Scalar,
Core::Vector2,
Core::Vector3,
Core::Vector4,
Core::Matrix2,
Core::Matrix3,
Core::Matrix4,
std::pair< Data::Texture *, int > TextureInfo
Special type for Texture parameter.

List of bindable types, to be used with static visitors.

Definition at line 43 of file RenderParameters.hpp.

◆ TextureInfo

Special type for Texture parameter.

Definition at line 40 of file RenderParameters.hpp.

Member Function Documentation

◆ bind()

void Ra::Engine::Data::RenderParameters::bind ( const Data::ShaderProgram * shader) const
inline

Bind the parameter uniform on the shader program.

Note
, this will only bind the supported parameter types.
Parameters
shaderThe shader to bind to.

Definition at line 92 of file RenderParameters.hpp.

◆ setTexture()

template<typename T , typename std::enable_if< std::is_base_of< Data::Texture, T >::value, bool >::type = true>
void Ra::Engine::Data::RenderParameters::setTexture ( const std::string & name,
T * tex,
int texUnit = -1 )
inline

Adding a texture parameter.

Template Parameters
TThe type of parameter to add. Must be derived from Texture for this overload.
Parameters
nameName of the parameter
texTexture to add in the parameterSet
texUnitTexture unit associated with the texture object. The default (-1) for the texUnit parameter implies automatic uniform binding for the texture unit associated with the named sampler. If texUnit is given, then uniform binding will be made at this explicit location.

Definition at line 73 of file RenderParameters.hpp.

◆ setVariable() [1/3]

void Ra::Engine::Data::RenderParameters::setVariable ( const std::string & name,
const RenderParameters & rp )
inline

Definition at line 83 of file RenderParameters.hpp.

◆ setVariable() [2/3]

template<typename T >
auto Ra::Core::VariableSet::setVariable ( const std::string & name,
const T & value ) -> std::pair<VariableHandle<T>, bool>

reset (or set if the variable does not exist yet) the value of the variable.

Returns
a pair with the variable handle and a bool : true if the variable value was reset, false if the variable value was set.

Definition at line 191 of file VariableSet.hpp.

◆ setVariable() [3/3]

void Ra::Engine::Data::RenderParameters::setVariable ( const std::string & name,
RenderParameters & rp )
inline

overload create ref wrapper for RenderParameters variable

Definition at line 80 of file RenderParameters.hpp.

+ Here is the call graph for this function:

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