Cinder  0.9.1
Public Member Functions | List of all members
cinder::gl::ShaderPreprocessor Class Reference

#include <ShaderPreprocessor.h>

Public Member Functions

 ShaderPreprocessor ()
 
std::string parse (const fs::path &sourcePath, std::set< fs::path > *includedFiles=nullptr)
 
std::string parse (const std::string &source, const fs::path &sourcePath, std::set< fs::path > *includedFiles=nullptr)
 
void addSearchDirectory (const fs::path &directory)
 
void removeSearchDirectory (const fs::path &directory)
 
void addDefine (const std::string &define)
 
void addDefine (const std::string &define, const std::string &value)
 
void setDefineDirectives (const std::vector< std::string > &defines)
 
void setVersion (int version)
 

Detailed Description

Class for parsing and processing GLSL preprocessor directives.

Detected files that need to be included, via the #include directive, are first searched for relative to the directory of the provided source path (if provided), and then relative to the search directories list. By default, the Platform's default assets path is added to this list, and you can add custom search directories with addSearchDirectory().

If a recursive #include is detected, a ShaderPreprocessorExc will be thrown.

Adding #define statements are also supported, and you can set the #version via setVersion( int ). If you are on OpenGL ES, then " es" will be appended to the version string.

Constructor & Destructor Documentation

cinder::gl::ShaderPreprocessor::ShaderPreprocessor ( )

Member Function Documentation

string cinder::gl::ShaderPreprocessor::parse ( const fs::path &  sourcePath,
std::set< fs::path > *  includedFiles = nullptr 
)

Parses and processes the shader source at sourcePath. If includedFiles is provided, this will be filled with paths to any files detected as #includeed.

Returns
a preprocessed source string.
string cinder::gl::ShaderPreprocessor::parse ( const std::string &  source,
const fs::path &  sourcePath,
std::set< fs::path > *  includedFiles = nullptr 
)

Parses and processes the shader source source, which can be found at sourcePath. If includedFiles is provided, this will be filled with paths to any files detected as #includeed.

Returns
a preprocessed source string.
void cinder::gl::ShaderPreprocessor::addSearchDirectory ( const fs::path &  directory)

Adds a custom search directory to the search list. The last directory added will be searched first.

void cinder::gl::ShaderPreprocessor::removeSearchDirectory ( const fs::path &  directory)

Removes a custom search directory from the search list.

void cinder::gl::ShaderPreprocessor::addDefine ( const std::string &  define)

Adds a define directive.

void cinder::gl::ShaderPreprocessor::addDefine ( const std::string &  define,
const std::string &  value 
)

Adds a define directive.

void cinder::gl::ShaderPreprocessor::setDefineDirectives ( const std::vector< std::string > &  defines)

Specifies a series of define directives to add to the shader sources.

void cinder::gl::ShaderPreprocessor::setVersion ( int  version)

Specifies the #version directive to add to the shader sources.


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