OpenWalnut  1.5.0dev
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:
+ Collaboration diagram for WGEShaderPreprocessor:

Public Types

typedef std::shared_ptr< WGEShaderPreprocessorSPtr
 Shared pointer for this class. More...
 
typedef std::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 41 of file WGEShaderPreprocessor.h.

Member Typedef Documentation

◆ ConstSPtr

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

A const shared pointer for this class.

Definition at line 52 of file WGEShaderPreprocessor.h.

◆ SPtr

Shared pointer for this class.

Definition at line 47 of file WGEShaderPreprocessor.h.

Constructor & Destructor Documentation

◆ WGEShaderPreprocessor()

WGEShaderPreprocessor::WGEShaderPreprocessor ( )

Default constructor.

Definition at line 27 of file WGEShaderPreprocessor.cpp.

◆ ~WGEShaderPreprocessor()

WGEShaderPreprocessor::~WGEShaderPreprocessor ( )
virtual

Destructor.

Definition at line 34 of file WGEShaderPreprocessor.cpp.

Member Function Documentation

◆ getActive()

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 WGEShaderCodeInjector::process(), WGEShaderDefineOptions::process(), and WGEShaderVersionPreprocessor::process().

+ Here is the caller graph for this function:

◆ getChangeCondition()

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.

◆ process()

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 WGEShaderVersionPreprocessor, WGEShaderDefineOptions, WGEShaderDefine< ValueType >, WGEShaderDefine< PropertyType::element_type::ValueType >, and WGEShaderCodeInjector.

◆ setActive()

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

Referenced by WMDirectVolumeRendering::moduleMain().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updated()

void WGEShaderPreprocessor::updated ( )
protectedvirtual

Member Data Documentation

◆ m_active

bool WGEShaderPreprocessor::m_active
private

If true the preprocessor is active.

Definition at line 110 of file WGEShaderPreprocessor.h.

Referenced by getActive(), and setActive().

◆ m_updateCondition

WCondition::SPtr WGEShaderPreprocessor::m_updateCondition
private

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: