OpenWalnut  1.4.0
Public Types | Public Member Functions | Protected Member Functions | Private Attributes | List of all members
WGEShaderPreprocessor Class Referenceabstract

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

#include <WGEShaderPreprocessor.h>

+ Inheritance diagram for WGEShaderPreprocessor:

Public Types

typedef boost::shared_ptr< WGEShaderPreprocessorSPtr
 Shared pointer for this class. More...
 
typedef boost::shared_ptr< const WGEShaderPreprocessorConstSPtr
 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...
 

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 43 of file WGEShaderPreprocessor.h.

Member Typedef Documentation

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

A const shared pointer for this class.

Definition at line 54 of file WGEShaderPreprocessor.h.

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

Shared pointer for this class.

Definition at line 49 of file WGEShaderPreprocessor.h.

Constructor & Destructor Documentation

WGEShaderPreprocessor::WGEShaderPreprocessor ( )

Default constructor.

Definition at line 27 of file WGEShaderPreprocessor.cpp.

WGEShaderPreprocessor::~WGEShaderPreprocessor ( )
virtual

Destructor.

Definition at line 34 of file WGEShaderPreprocessor.cpp.

Member Function Documentation

bool WGEShaderPreprocessor::getActive ( ) const

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().

WCondition::SPtr WGEShaderPreprocessor::getChangeCondition ( ) const
virtual

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 ( )
protectedvirtual

Member Data Documentation

bool WGEShaderPreprocessor::m_active
private

If true the preprocessor is active.

Definition at line 112 of file WGEShaderPreprocessor.h.

Referenced by getActive(), and setActive().

WCondition::SPtr WGEShaderPreprocessor::m_updateCondition
private

The condition fires on every call of updated().

Definition at line 107 of file WGEShaderPreprocessor.h.

Referenced by getChangeCondition(), and updated().


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