OpenWalnut  1.4.0
Public Types | Public Member Functions | Protected Member Functions | Private Attributes
WGEShaderPreprocessor Class Reference

Base class for each preprocessing possible to shader code. More...

#include <WGEShaderPreprocessor.h>

+ Inheritance diagram for WGEShaderPreprocessor:

List of all members.

Public Types

typedef boost::shared_ptr
< WGEShaderPreprocessor
SPtr
 Shared pointer for this class.
typedef boost::shared_ptr
< const WGEShaderPreprocessor
ConstSPtr
 A const shared pointer for this class.

Public Member Functions

 WGEShaderPreprocessor ()
 Default constructor.
virtual ~WGEShaderPreprocessor ()
 Destructor.
virtual WCondition::SPtr getChangeCondition () const
 Returns the condition denoting a change in this preprocessor filter.
virtual std::string process (const std::string &file, const std::string &code) const =0
 Process the whole code.
void setActive (bool active=true)
 (De-)activates the preprocessor.
bool getActive () const
 If the preprocessor is active, this returns true.

Protected Member Functions

virtual void updated ()
 Fires m_updateCondition which should denote an update in the preprocessor filter.

Private Attributes

WCondition::SPtr m_updateCondition
 The condition fires on every call of updated().
bool m_active
 If true the preprocessor is active.

Detailed Description

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.


Member Typedef Documentation

typedef boost::shared_ptr< const WGEShaderPreprocessor > WGEShaderPreprocessor::ConstSPtr
typedef boost::shared_ptr< WGEShaderPreprocessor > WGEShaderPreprocessor::SPtr

Constructor & Destructor Documentation

Default constructor.

Definition at line 27 of file WGEShaderPreprocessor.cpp.

Destructor.

Definition at line 34 of file WGEShaderPreprocessor.cpp.


Member Function Documentation

If the preprocessor is active, this returns true.

Returns:
if active: true

Definition at line 59 of file WGEShaderPreprocessor.cpp.

References m_active.

Referenced by WGEShaderVersionPreprocessor::process(), WGEShaderCodeInjector::process(), and WGEShaderDefineOptions::process().

Returns the condition denoting a change in this preprocessor filter.

WGEShader subscribes this and rebuilds all related shaders if needed.

Returns:
the condition firing whenever the preprocessor updates.

Definition at line 39 of file WGEShaderPreprocessor.cpp.

References m_updateCondition.

virtual std::string WGEShaderPreprocessor::process ( const std::string &  file,
const std::string &  code 
) const [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.

Parameters:
codethe code to process
filethe filename of the shader currently processed. Should be used for debugging output.
Returns:
the resulting new code

Implemented in WGEShaderDefineOptions, WGEShaderDefine< ValueType >, WGEShaderDefine< PropertyType::element_type::ValueType >, WGEShaderCodeInjector, and WGEShaderVersionPreprocessor.

void WGEShaderPreprocessor::setActive ( bool  active = true)

(De-)activates the preprocessor.

An inactive preprocessor does not modify the shader code.

Parameters:
activetrue if preprocessor should be active

Definition at line 49 of file WGEShaderPreprocessor.cpp.

References m_active, and updated().

void WGEShaderPreprocessor::updated ( ) [protected, virtual]

Member Data Documentation

If true the preprocessor is active.

Definition at line 110 of file WGEShaderPreprocessor.h.

Referenced by getActive(), and setActive().

The condition fires on every call of updated().

Definition at line 105 of file WGEShaderPreprocessor.h.

Referenced by getChangeCondition(), and updated().


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