OpenWalnut
1.5.0dev
|
Base class for each preprocessing possible to shader code. More...
#include <WGEShaderPreprocessor.h>
Public Types | |
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 | |
WGEShaderPreprocessor () | |
Default constructor. More... | |
virtual | ~WGEShaderPreprocessor () |
Destructor. More... | |
virtual WCondition::SPtr | getChangeCondition () const |
Returns the condition denoting a change in this preprocessor filter. More... | |
virtual std::string | process (const std::string &file, const std::string &code) const =0 |
Process the whole code. 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 | |
virtual void | updated () |
Fires m_updateCondition which should denote an update in the preprocessor filter. More... | |
Private Attributes | |
WCondition::SPtr | m_updateCondition |
The condition fires on every call of updated(). More... | |
bool | m_active |
If true the preprocessor is active. More... | |
Base class for each preprocessing possible to shader code.
This is useful to derive your own preprocessor which might be able to implement some tricky "metaprogramming" for GLSL or similar. Another possibility are defines. In addition, it implements an update notification mechanism which forces associated WGEShader to reload. This is useful for preprocessors that can be modified dynamically.
Definition at line 41 of file WGEShaderPreprocessor.h.
typedef std::shared_ptr< const WGEShaderPreprocessor > WGEShaderPreprocessor::ConstSPtr |
A const shared pointer for this class.
Definition at line 52 of file WGEShaderPreprocessor.h.
typedef std::shared_ptr< WGEShaderPreprocessor > WGEShaderPreprocessor::SPtr |
Shared pointer for this class.
Definition at line 47 of file WGEShaderPreprocessor.h.
WGEShaderPreprocessor::WGEShaderPreprocessor | ( | ) |
Default constructor.
Definition at line 27 of file WGEShaderPreprocessor.cpp.
|
virtual |
Destructor.
Definition at line 34 of file WGEShaderPreprocessor.cpp.
bool WGEShaderPreprocessor::getActive | ( | ) | const |
If the preprocessor is active, this returns true.
Definition at line 59 of file WGEShaderPreprocessor.cpp.
References m_active.
Referenced by WGEShaderCodeInjector::process(), WGEShaderDefineOptions::process(), and WGEShaderVersionPreprocessor::process().
|
virtual |
Returns the condition denoting a change in this preprocessor filter.
WGEShader subscribes this and rebuilds all related shaders if needed.
Definition at line 39 of file WGEShaderPreprocessor.cpp.
References m_updateCondition.
|
pure 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. |
Implemented in WGEShaderVersionPreprocessor, WGEShaderDefineOptions, WGEShaderDefine< ValueType >, WGEShaderDefine< PropertyType::element_type::ValueType >, and WGEShaderCodeInjector.
void WGEShaderPreprocessor::setActive | ( | bool | active = true | ) |
(De-)activates the preprocessor.
An inactive preprocessor does not modify the shader code.
active | true if preprocessor should be active |
Definition at line 49 of file WGEShaderPreprocessor.cpp.
References m_active, and updated().
Referenced by WMDirectVolumeRendering::moduleMain().
|
protectedvirtual |
Fires m_updateCondition which should denote an update in the preprocessor filter.
Definition at line 44 of file WGEShaderPreprocessor.cpp.
References m_updateCondition.
Referenced by WGEShaderDefineOptions::activateAllOptions(), WGEShaderDefineOptions::activateOption(), WGEShaderDefineOptions::addOption(), WGEShaderDefineOptions::deactivateAllOptions(), WGEShaderDefineOptions::deactivateOption(), WGEShaderDefineOptions::setActivationList(), setActive(), and WGEShaderCodeInjector::setCode().
|
private |
If true the preprocessor is active.
Definition at line 110 of file WGEShaderPreprocessor.h.
Referenced by getActive(), and setActive().
|
private |
The condition fires on every call of updated().
Definition at line 105 of file WGEShaderPreprocessor.h.
Referenced by getChangeCondition(), and updated().