#include <ShaderLoader.h>
|
| IE_CORE_DECLAREMEMBERPTR (ShaderLoader) |
|
| ShaderLoader (const IECore::SearchPath &searchPaths, const IECore::SearchPath *preprocessorSearchPaths=nullptr) |
|
void | loadSource (const std::string &name, std::string &vertexSource, std::string &geometrySource, std::string &fragmentSource) |
|
ShaderPtr | create (const std::string &vertexSource, const std::string &geometrySource, const std::string &fragmentSource) |
|
ShaderPtr | load (const std::string &name) |
|
void | clearUnused () |
|
void | clear () |
|
| IE_CORE_DECLAREMEMBERPTR (RefCounted) |
|
void | addRef () const |
| Add a reference to the current object.
|
|
void | removeRef () const |
| Remove a reference from the current object.
|
|
RefCount | refCount () const |
| Returns the current reference count.
|
|
This class provides loading and preprocessing of GLSL shaders, and manages a cache of Shader objects compiled from that source.
Creates a ShaderLoader which will search for source files on the given search paths. If preprocessorSearchPaths is specified, then source preprocessing will be performed using boost::wave.
void IECoreGL::ShaderLoader::clearUnused |
( |
| ) |
|
Frees unused shaders. Automatically called by create() function.
ShaderPtr IECoreGL::ShaderLoader::create |
( |
const std::string & |
vertexSource, |
|
|
const std::string & |
geometrySource, |
|
|
const std::string & |
fragmentSource |
|
) |
| |
Creates a new Shader if necessary or returns a previously compiled shader from the cache. In case the given shader was not in the cache it will do preprocessing (adding include files) and then return a new instance of the Shader class. This function will also eliminate any shader from the cache that is not being used.
static ShaderLoader* IECoreGL::ShaderLoader::defaultShaderLoader |
( |
| ) |
|
|
static |
Returns a static ShaderLoader instance that everyone can use. This has searchpaths set using the IECOREGL_SHADER_PATHS environment variable, and preprocessor searchpaths set using the IECOREGL_SHADER_INCLUDE_PATHS environment variable.
ShaderPtr IECoreGL::ShaderLoader::load |
( |
const std::string & |
name | ) |
|
Loads the shader code and creates the Shader object. This function can only be called when the OpenGL context is defined.
void IECoreGL::ShaderLoader::loadSource |
( |
const std::string & |
name, |
|
|
std::string & |
vertexSource, |
|
|
std::string & |
geometrySource, |
|
|
std::string & |
fragmentSource |
|
) |
| |
Loads the GLSL source code for a shader of the specified name, by locating and loading files named "name.vert". "name.geom" and "name.frag". If any file is missing then the empty string will be returned, signifying that the default shader source for that component should be used.
The documentation for this class was generated from the following file: