OpenWalnut  1.5.0dev
Public Types | Public Member Functions | Private Attributes | List of all members
WGEShaderCodeInjector Class Reference

This preprocessor is able to inject code into a shader. More...

#include <WGEShaderCodeInjector.h>

+ Inheritance diagram for WGEShaderCodeInjector:
+ Collaboration diagram for WGEShaderCodeInjector:

Public Types

typedef std::shared_ptr< WGEShaderCodeInjectorSPtr
 Shortcut for a shared_ptr. More...
 
typedef std::shared_ptr< WGEShaderCodeInjectorConstSPtr
 Shortcut for a const shared_ptr. More...
 
- Public Types inherited from WGEShaderPreprocessor
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

 WGEShaderCodeInjector (std::string keyword)
 Default constructor. More...
 
virtual ~WGEShaderCodeInjector ()
 Destructor. More...
 
virtual std::string process (const std::string &file, const std::string &code) const
 Process the whole code. More...
 
void setCode (std::string code)
 Define the code that replaces the keyword. 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...
 

Private Attributes

std::string m_code
 the custom code. More...
 
std::string m_keyword
 What to replace. More...
 

Additional Inherited Members

- Protected Member Functions inherited from WGEShaderPreprocessor
virtual void updated ()
 Fires m_updateCondition which should denote an update in the preprocessor filter. More...
 

Detailed Description

This preprocessor is able to inject code into a shader.

It therefore replaces a specified keyword with code.

Definition at line 38 of file WGEShaderCodeInjector.h.

Member Typedef Documentation

◆ ConstSPtr

Shortcut for a const shared_ptr.

Definition at line 49 of file WGEShaderCodeInjector.h.

◆ SPtr

Shortcut for a shared_ptr.

Definition at line 44 of file WGEShaderCodeInjector.h.

Constructor & Destructor Documentation

◆ WGEShaderCodeInjector()

WGEShaderCodeInjector::WGEShaderCodeInjector ( std::string  keyword)
explicit

Default constructor.

Parameters
keywordthis is replaced by the custom code if existing.

Definition at line 35 of file WGEShaderCodeInjector.cpp.

◆ ~WGEShaderCodeInjector()

WGEShaderCodeInjector::~WGEShaderCodeInjector ( )
virtual

Destructor.

Definition at line 41 of file WGEShaderCodeInjector.cpp.

Member Function Documentation

◆ process()

std::string WGEShaderCodeInjector::process ( const std::string &  file,
const std::string &  code 
) const
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

Implements WGEShaderPreprocessor.

Definition at line 46 of file WGEShaderCodeInjector.cpp.

References WGEShaderPreprocessor::getActive(), m_code, and m_keyword.

+ Here is the call graph for this function:

◆ setCode()

void WGEShaderCodeInjector::setCode ( std::string  code)

Define the code that replaces the keyword.

Parameters
codethe code.

Definition at line 74 of file WGEShaderCodeInjector.cpp.

References m_code, and WGEShaderPreprocessor::updated().

+ Here is the call graph for this function:

Member Data Documentation

◆ m_code

std::string WGEShaderCodeInjector::m_code
private

the custom code.

Definition at line 84 of file WGEShaderCodeInjector.h.

Referenced by process(), and setCode().

◆ m_keyword

std::string WGEShaderCodeInjector::m_keyword
private

What to replace.

Definition at line 89 of file WGEShaderCodeInjector.h.

Referenced by process().


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