Radium Engine  1.5.0
Ra::Engine::Data::RenderParameters Class Referencefinal

#include <Engine/Data/RenderParameters.hpp>

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

Public Types

using TextureInfo = std::pair< Data::Texture *, int >
 Special type for Texture parameter.
 
using BindableTypes = Core::Utils::TypeList< bool, Core::Utils::Color, int, uint, Scalar, TextureInfo, std::vector< int >, std::vector< uint >, std::vector< Scalar >, Core::Vector2, Core::Vector3, Core::Vector4, Core::Matrix2, Core::Matrix3, Core::Matrix4, std::reference_wrapper< RenderParameters >, std::reference_wrapper< const RenderParameters > >
 Aliases for bindable parameter types. More...
 
template<typename T >
using UniformBindableSet = Core::VariableSet::VariableContainer< T >
 
template<typename T >
using UniformVariable = Core::VariableSet::VariableHandle< T >
 

Public Member Functions

template<typename EnumBaseType >
void addEnumConverter (const std::string &name, std::shared_ptr< Core::Utils::EnumConverter< EnumBaseType >> converter)
 Associate a converter for enumerated type to the given parameter name. More...
 
template<typename EnumBaseType >
Core::Utils::optional< std::shared_ptr< Core::Utils::EnumConverter< EnumBaseType > > > getEnumConverter (const std::string &name)
 Search for a converter associated with an enumeration parameter. More...
 
template<typename Enum , typename std::enable_if< std::is_enum< Enum > {}, bool >::type = true>
std::string getEnumString (const std::string &name, Enum value)
 Return the string associated to the actual value of a parameter. More...
 
template<typename EnumBaseType >
std::string getEnumString (const std::string &name, EnumBaseType value, typename std::enable_if<!std::is_enum< EnumBaseType > {}, bool >::type=true)
 (overload) Return the string associated to the actual value of a parameter, from a value with underlying_type<Enum>. More...
 
template<typename T >
bool removeParameter (const std::string &name)
 Remove the given parameter from the parameterSet. More...
 
void mergeKeepParameters (const RenderParameters &params)
 
void mergeReplaceParameters (const RenderParameters &params)
 
void bind (const Data::ShaderProgram *shader) const
 
template<typename T >
Core::Utils::optional< UniformBindableSet< T > * > hasParameterSet () const
 Test if parameters of type T are stored. More...
 
template<typename T >
Core::Utils::optional< UniformVariable< T > > containsParameter (const std::string &name) const
 
template<typename V >
void visit (V &&visitor) const
 
template<typename V , typename T >
void visit (V &&visitor, T &userParams) const
 
template<typename V , typename T >
void visit (V &&visitor, T &&userParams) const
 
template<typename T >
void addParameter (const std::string &name, T value, typename std::enable_if<!std::is_class< T > {}, bool >::type=true)
 Add a parameter by value. More...
 
template<typename T , typename std::enable_if< std::is_class< T > {}, bool >::type = true>
void addParameter (const std::string &name, const T &value)
 Add a parameter by const ref. More...
 
template<typename T , typename std::enable_if< std::is_base_of< Data::Texture, T >::value, bool >::type = true>
void addParameter (const std::string &name, T *tex, int texUnit=-1)
 Adding a texture parameter. More...
 
void addParameter (const std::string &name, const std::string &value)
 set the value of the given parameter, according to a string representation of an enum. More...
 
void addParameter (const std::string &name, const char *value)
 
void addParameter (const std::string &name, RenderParameters &value)
 add a render parameter variable More...
 
void addParameter (const std::string &name, const RenderParameters &value)
 
template<typename T >
const UniformBindableSet< T > & getParameterSet () const
 Get a typed parameter set. More...
 
template<typename T >
UniformBindableSet< T > & getParameterSet ()
 
template<typename T >
const T & getParameter (const std::string &name) const
 Get a typed parameter. More...
 
template<typename T >
T & getParameter (const std::string &name)
 
const Core::VariableSetgetStorage () const
 Get access to the parameter storage. More...
 
Core::VariableSetgetStorage ()
 

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 getParameterSet<typename std::underlying_type<typename Enum>::type>

Definition at line 35 of file RenderParameters.hpp.

Member Typedef Documentation

◆ BindableTypes

using Ra::Engine::Data::RenderParameters::BindableTypes = Core::Utils::TypeList<bool, Core::Utils::Color, int, uint, Scalar, TextureInfo, std::vector<int>, std::vector<uint>, std::vector<Scalar>, Core::Vector2, Core::Vector3, Core::Vector4, Core::Matrix2, Core::Matrix3, Core::Matrix4, std::reference_wrapper<RenderParameters>, std::reference_wrapper<const RenderParameters> >

Aliases for bindable parameter types.

List of bindable types, to be used with static visitors

Definition at line 47 of file RenderParameters.hpp.

◆ UniformBindableSet

Set of typed parameters For a given shader Program, all the parameters are stored by type, using Core::VariableSet as container.

Template Parameters
TThe type of parameters in the set.

Definition at line 72 of file RenderParameters.hpp.

◆ UniformVariable

Handle to a bindable parameters. A handle is an iterator on a pair <name, value> such that the value is of type T

Template Parameters
TThe type of parameter in the set.

Definition at line 80 of file RenderParameters.hpp.

Member Function Documentation

◆ addEnumConverter()

template<typename EnumBaseType >
void Ra::Engine::Data::RenderParameters::addEnumConverter ( const std::string &  name,
std::shared_ptr< Core::Utils::EnumConverter< EnumBaseType >>  converter 
)

Associate a converter for enumerated type to the given parameter name.

Template Parameters
EnumBaseTypeThe enum base type to manage (
See also
Ra::Core::Utils::EnumConverter)
Parameters
name
converter

Definition at line 408 of file RenderParameters.hpp.

+ Here is the call graph for this function:

◆ addParameter() [1/5]

void Ra::Engine::Data::RenderParameters::addParameter ( const std::string &  name,
const std::string &  value 
)

set the value of the given parameter, according to a string representation of an enum.

Note
If there is no EnumConverter associated with the parameter name, the string is registered in the RenderParameter set.
Parameters
nameName of the parameter
valuevalue of the parameter

Definition at line 17 of file RenderParameters.cpp.

+ Here is the call graph for this function:

◆ addParameter() [2/5]

template<typename T , typename std::enable_if< std::is_class< T > {}, bool >::type >
void Ra::Engine::Data::RenderParameters::addParameter ( const std::string &  name,
const T &  value 
)
inline

Add a parameter by const ref.

Template Parameters
TThe type of parameter to add. Must be a class type for this overload to be chosen.
Parameters
nameName of the parameter.
valueValue of the parameter.

Definition at line 466 of file RenderParameters.hpp.

+ Here is the call graph for this function:

◆ addParameter() [3/5]

void Ra::Engine::Data::RenderParameters::addParameter ( const std::string &  name,
RenderParameters value 
)
inline

add a render parameter variable

Parameters
name
value

Definition at line 475 of file RenderParameters.hpp.

+ Here is the call graph for this function:

◆ addParameter() [4/5]

template<typename T , typename std::enable_if< std::is_base_of< Data::Texture, T >::value, bool >::type >
void Ra::Engine::Data::RenderParameters::addParameter ( 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 471 of file RenderParameters.hpp.

+ Here is the call graph for this function:

◆ addParameter() [5/5]

template<typename T >
void Ra::Engine::Data::RenderParameters::addParameter ( const std::string &  name,
value,
typename std::enable_if<!std::is_class< T > {}, bool >::type  = true 
)
inline

Add a parameter by value.

Overloaded operators to set shader parameters

Template Parameters
TThe type of parameter to add. Must be a non class type for this overload to be chosen.
Parameters
nameName of the parameter.
valueValue of the parameter.

Definition at line 455 of file RenderParameters.hpp.

◆ bind()

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

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 13 of file RenderParameters.cpp.

+ Here is the call graph for this function:

◆ containsParameter()

template<typename T >
Core::Utils::optional< RenderParameters::UniformVariable< T > > Ra::Engine::Data::RenderParameters::containsParameter ( const std::string &  name) const
inline

Check if a typed parameter exists

Template Parameters
Tthe type of the parameter to get
Parameters
nameThe name of the parameter to get
Returns
true if the parameter exists

Definition at line 513 of file RenderParameters.hpp.

+ Here is the call graph for this function:

◆ getEnumConverter()

template<typename EnumBaseType >
Core::Utils::optional< std::shared_ptr< Core::Utils::EnumConverter< EnumBaseType > > > Ra::Engine::Data::RenderParameters::getEnumConverter ( const std::string &  name)

Search for a converter associated with an enumeration parameter.

Template Parameters
EnumBaseTypeThe enum base type to manage (
See also
Ra::Core::Utils::EnumConverter)
Parameters
namethe name of the parameter
Returns
an optional containing the converter or false if no converter is found.

Definition at line 423 of file RenderParameters.hpp.

+ Here is the call graph for this function:

◆ getEnumString() [1/2]

template<typename Enum , typename std::enable_if< std::is_enum< Enum > {}, bool >::type >
std::string Ra::Engine::Data::RenderParameters::getEnumString ( const std::string &  name,
Enum  value 
)

Return the string associated to the actual value of a parameter.

Template Parameters
EnumThe enum type (
See also
Ra::Core::Utils::EnumConverter)
Parameters
nameThe name of the enum variable
valueThe value to convert
Returns

Definition at line 446 of file RenderParameters.hpp.

◆ getEnumString() [2/2]

template<typename EnumBaseType >
std::string Ra::Engine::Data::RenderParameters::getEnumString ( const std::string &  name,
EnumBaseType  value,
typename std::enable_if<!std::is_enum< EnumBaseType > {}, bool >::type  = true 
)

(overload) Return the string associated to the actual value of a parameter, from a value with underlying_type<Enum>.

Template Parameters
EnumBaseTypeThe underlying enum type (
See also
Ra::Core::Utils::EnumConverter)
Parameters
nameThe name of the enum variable
valueThe value to convert
Returns

Definition at line 432 of file RenderParameters.hpp.

◆ getParameter()

template<typename T >
const T & Ra::Engine::Data::RenderParameters::getParameter ( const std::string &  name) const
inline

Get a typed parameter.

Template Parameters
Tthe type of the parameter to get
Parameters
nameThe name of the parameter to get
Returns
The corresponding parameter
Exceptions
std::out_of_rangeif the container does not have an parameter with the specified name

Definition at line 521 of file RenderParameters.hpp.

+ Here is the call graph for this function:

◆ getParameterSet()

template<typename T >
const RenderParameters::UniformBindableSet< T > & Ra::Engine::Data::RenderParameters::getParameterSet
inline

Get a typed parameter set.

Template Parameters
Tthe type of the parameter set to get
Returns
The corresponding set parameter

Definition at line 490 of file RenderParameters.hpp.

+ Here is the call graph for this function:

◆ getStorage()

const Core::VariableSet& Ra::Engine::Data::RenderParameters::getStorage ( ) const
inline

Get access to the parameter storage.

Returns
the Core::VariableSet storing the parameters

Definition at line 276 of file RenderParameters.hpp.

◆ hasParameterSet()

template<typename T >
Core::Utils::optional< RenderParameters::UniformBindableSet< T > * > Ra::Engine::Data::RenderParameters::hasParameterSet
inline

Test if parameters of type T are stored.

Template Parameters
T
Returns
an optional, empty if the ParameterSet does not exists or whose value is a non owning pointer to the ParameterSet collection if it exists. This non owning pointer remains valid as long as the RenderParameter exists and contains the given type.

Definition at line 501 of file RenderParameters.hpp.

+ Here is the call graph for this function:

◆ mergeKeepParameters()

void Ra::Engine::Data::RenderParameters::mergeKeepParameters ( const RenderParameters params)

Merges a RenderParameters params with this

Parameters
paramsthe render parameter to merge with the current. Existing parameter value are kept from this
See also
mergeReplaceParameters

Definition at line 34 of file RenderParameters.cpp.

+ Here is the call graph for this function:

◆ mergeReplaceParameters()

void Ra::Engine::Data::RenderParameters::mergeReplaceParameters ( const RenderParameters params)

Merges a RenderParameters params with this

Parameters
paramsthe render parameter to merge with the current. Existing parameter values are replaced by params's one.
See also
mergeKeepParameters

Definition at line 38 of file RenderParameters.cpp.

+ Here is the call graph for this function:

◆ removeParameter()

template<typename T >
bool Ra::Engine::Data::RenderParameters::removeParameter ( const std::string &  name)

Remove the given parameter from the parameterSet.

Template Parameters
TType of the parameter to remove
Parameters
nameName of the parameter to remove
Returns
true if the parameter was found and removed. false else.

Definition at line 485 of file RenderParameters.hpp.

+ Here is the call graph for this function:

◆ visit()

template<typename V >
void Ra::Engine::Data::RenderParameters::visit ( V &&  visitor) const
inline

Visit the parameter using any kind of visitor

Definition at line 536 of file RenderParameters.hpp.

+ Here is the call graph for this function:

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