OpenWalnut  1.3.1
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:

Public Types

typedef boost::shared_ptr
< WGEShaderCodeInjector
SPtr
 Shortcut for a shared_ptr.
typedef boost::shared_ptr
< WGEShaderCodeInjector
ConstSPtr
 Shortcut for a const shared_ptr.
- Public Types inherited from WGEShaderPreprocessor
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

 WGEShaderCodeInjector (std::string keyword)
 Default constructor.
virtual ~WGEShaderCodeInjector ()
 Destructor.
virtual std::string process (const std::string &file, const std::string &code) const
 Process the whole code.
void setCode (std::string code)
 Define the code that replaces the keyword.
- Public Member Functions inherited from WGEShaderPreprocessor
 WGEShaderPreprocessor ()
 Default constructor.
virtual ~WGEShaderPreprocessor ()
 Destructor.
virtual WCondition::SPtr getChangeCondition () const
 Returns the condition denoting a change in this preprocessor filter.
void setActive (bool active=true)
 (De-)activates the preprocessor.
bool getActive () const
 If the preprocessor is active, this returns true.

Private Attributes

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

Additional Inherited Members

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

Detailed Description

This preprocessor is able to inject code into a shader.

It therefore replaces a specified keyword with code.

Definition at line 37 of file WGEShaderCodeInjector.h.

Member Typedef Documentation

Shortcut for a const shared_ptr.

Definition at line 48 of file WGEShaderCodeInjector.h.

typedef boost::shared_ptr< WGEShaderCodeInjector > WGEShaderCodeInjector::SPtr

Shortcut for a shared_ptr.

Definition at line 43 of file WGEShaderCodeInjector.h.

Constructor & Destructor Documentation

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

Destructor.

Definition at line 41 of file WGEShaderCodeInjector.cpp.

Member Function Documentation

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.

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

Member Data Documentation

std::string WGEShaderCodeInjector::m_code
private

the custom code.

Definition at line 83 of file WGEShaderCodeInjector.h.

Referenced by process(), and setCode().

std::string WGEShaderCodeInjector::m_keyword
private

What to replace.

Definition at line 88 of file WGEShaderCodeInjector.h.

Referenced by process().


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