OpenWalnut
1.5.0dev
|
This GLSL preprocessor is able to set one define from a list of defines depending on the active option. More...
#include <WGEShaderDefineOptions.h>
Public Types | |
typedef std::shared_ptr< WGEShaderDefineOptions > | SPtr |
Shared pointer for this class. More... | |
typedef std::shared_ptr< const WGEShaderDefineOptions > | ConstSPtr |
A const shared pointer for this class. More... | |
typedef std::vector< size_t > | IdxList |
The type of the index list. More... | |
Public Types inherited from WGEShaderPreprocessor | |
typedef std::shared_ptr< WGEShaderPreprocessor > | SPtr |
Shared pointer for this class. More... | |
typedef std::shared_ptr< const WGEShaderPreprocessor > | ConstSPtr |
A const shared pointer for this class. More... | |
Public Member Functions | |
WGEShaderDefineOptions (std::string first, std::string option2="", std::string option3="", std::string option4="", std::string option5="", std::string option6="", std::string option7="", std::string option8="", std::string option9="", std::string option10="") | |
Create a new instance of this class. More... | |
WGEShaderDefineOptions (std::vector< std::string > options) | |
Create a new instance of this class. More... | |
virtual | ~WGEShaderDefineOptions () |
Destructor. More... | |
virtual std::string | process (const std::string &file, const std::string &code) const |
Process the whole code. More... | |
const IdxList & | getActiveOptions () const |
Returns the currently active option as index. More... | |
std::string | getOptionName (size_t idx) const |
Returns the name of the specified option. More... | |
void | activateOption (size_t idx, bool exclusive=true) |
Activates the option specified. More... | |
void | deactivateOption (size_t idx) |
De-activates the specified option. More... | |
void | activateAllOptions () |
Activates all the options. More... | |
void | deactivateAllOptions () |
De-activates all the options. More... | |
void | addOption (std::string opt) |
Adds the specified string as option which is inserted to the code as "#define NAME" if active. More... | |
Public Member Functions inherited from WGEShaderPreprocessor | |
WGEShaderPreprocessor () | |
Default constructor. More... | |
virtual | ~WGEShaderPreprocessor () |
Destructor. More... | |
virtual WCondition::SPtr | getChangeCondition () const |
Returns the condition denoting a change in this preprocessor filter. More... | |
void | setActive (bool active=true) |
(De-)activates the preprocessor. More... | |
bool | getActive () const |
If the preprocessor is active, this returns true. More... | |
Protected Member Functions | |
void | setActivationList (const IdxList &newList) |
Sets the specified index list as the new activation list. More... | |
Protected Member Functions inherited from WGEShaderPreprocessor | |
virtual void | updated () |
Fires m_updateCondition which should denote an update in the preprocessor filter. More... | |
Private Attributes | |
std::vector< std::string > | m_options |
The list of options. More... | |
IdxList | m_idx |
The currently selected options. More... | |
This GLSL preprocessor is able to set one define from a list of defines depending on the active option.
You should prefer this class instead of WGEShaderDefine if many mutual exclusive options should be handled comfortably.
Definition at line 43 of file WGEShaderDefineOptions.h.
typedef std::shared_ptr< const WGEShaderDefineOptions > WGEShaderDefineOptions::ConstSPtr |
A const shared pointer for this class.
Definition at line 54 of file WGEShaderDefineOptions.h.
typedef std::vector< size_t > WGEShaderDefineOptions::IdxList |
The type of the index list.
Definition at line 59 of file WGEShaderDefineOptions.h.
typedef std::shared_ptr< WGEShaderDefineOptions > WGEShaderDefineOptions::SPtr |
Shared pointer for this class.
Definition at line 49 of file WGEShaderDefineOptions.h.
WGEShaderDefineOptions::WGEShaderDefineOptions | ( | std::string | first, |
std::string | option2 = "" , |
||
std::string | option3 = "" , |
||
std::string | option4 = "" , |
||
std::string | option5 = "" , |
||
std::string | option6 = "" , |
||
std::string | option7 = "" , |
||
std::string | option8 = "" , |
||
std::string | option9 = "" , |
||
std::string | option10 = "" |
||
) |
Create a new instance of this class.
The first option is mandatory and is set as default.
first | fist option. Is default. |
option2 | another option |
option3 | another option |
option4 | another option |
option5 | another option |
option6 | another option |
option7 | another option |
option8 | another option |
option9 | another option |
option10 | another option |
Definition at line 34 of file WGEShaderDefineOptions.cpp.
References m_options.
|
explicit |
Create a new instance of this class.
The first option is mandatory and is set as default.
options | the list of options. Must have a size greater 0. |
Definition at line 81 of file WGEShaderDefineOptions.cpp.
|
virtual |
Destructor.
Definition at line 89 of file WGEShaderDefineOptions.cpp.
void WGEShaderDefineOptions::activateAllOptions | ( | ) |
Activates all the options.
Definition at line 157 of file WGEShaderDefineOptions.cpp.
References m_idx, m_options, and WGEShaderPreprocessor::updated().
void WGEShaderDefineOptions::activateOption | ( | size_t | idx, |
bool | exclusive = true |
||
) |
Activates the option specified.
idx | the option index to activate |
exclusive | if true, all active options get deactivated and the specified one will be the only active one afterwards |
Definition at line 124 of file WGEShaderDefineOptions.cpp.
References m_idx, m_options, and WGEShaderPreprocessor::updated().
void WGEShaderDefineOptions::addOption | ( | std::string | opt | ) |
Adds the specified string as option which is inserted to the code as "#define NAME" if active.
Must be a unique name. If it already exists in the list, nothing happens.
opt | the option name. |
Definition at line 175 of file WGEShaderDefineOptions.cpp.
References m_options, and WGEShaderPreprocessor::updated().
void WGEShaderDefineOptions::deactivateAllOptions | ( | ) |
De-activates all the options.
Definition at line 168 of file WGEShaderDefineOptions.cpp.
References m_idx, and WGEShaderPreprocessor::updated().
void WGEShaderDefineOptions::deactivateOption | ( | size_t | idx | ) |
De-activates the specified option.
If it is not activated, nothing happens.
idx | the option to deactivate |
Definition at line 147 of file WGEShaderDefineOptions.cpp.
References m_idx, and WGEShaderPreprocessor::updated().
const WGEShaderDefineOptions::IdxList & WGEShaderDefineOptions::getActiveOptions | ( | ) | const |
Returns the currently active option as index.
Definition at line 113 of file WGEShaderDefineOptions.cpp.
References m_idx.
std::string WGEShaderDefineOptions::getOptionName | ( | size_t | idx | ) | const |
Returns the name of the specified option.
idx | the index |
Definition at line 118 of file WGEShaderDefineOptions.cpp.
References m_options.
Referenced by process().
|
virtual |
Process the whole code.
It is not allowed to modify some internal state in this function because it might be called by several shaders.
code | the code to process |
file | the filename of the shader currently processed. Should be used for debugging output. |
Implements WGEShaderPreprocessor.
Definition at line 94 of file WGEShaderDefineOptions.cpp.
References WGEShaderPreprocessor::getActive(), getOptionName(), and m_idx.
|
protected |
Sets the specified index list as the new activation list.
Triggers an update.
newList | the ne list getting copied to the internal activation list. |
Definition at line 187 of file WGEShaderDefineOptions.cpp.
References m_idx, and WGEShaderPreprocessor::updated().
|
private |
The currently selected options.
Definition at line 168 of file WGEShaderDefineOptions.h.
Referenced by activateAllOptions(), activateOption(), deactivateAllOptions(), deactivateOption(), getActiveOptions(), process(), and setActivationList().
|
private |
The list of options.
Definition at line 163 of file WGEShaderDefineOptions.h.
Referenced by activateAllOptions(), activateOption(), addOption(), getOptionName(), and WGEShaderDefineOptions().