#include <shader_system.h>
Public Member Functions | |
virtual void | addAcceptableGraphicCoreID (const std::string &GraphicCoreID)=0 |
Method for manual adding acceptable GraphicCore ID. | |
virtual void | bind (Shader *shader)=0 |
virtual Uniform * | create (Texture *texture)=0 |
Creates Uniform from texture. | |
virtual Uniform * | create (const Data &data)=0 |
creates Uniform variable. | |
virtual Shader * | create (const std::string &ShaderName)=0 |
Creates Shader object. | |
virtual void | destroy (Shader *shader)=0 |
Deletes Shader object. | |
virtual void | destroy (Uniform *uniform)=0 |
Deletes given Uniform. | |
virtual Shader * | getActiveShader () const =0 |
const std::string & | getClassName () const |
Returns name of class of our object. | |
virtual debugger::CodeInstructor * | getCodeInstructor () const =0 |
Returns CodeInstructor - special object, which allows to instruct shader with debugging symbols. | |
const std::string & | getObjectName () const |
Returns name of our object. | |
virtual Shader * | getShaderByName (const std::string &ShaderName) const =0 |
void | getSpecificParameter (const std::string &ParameterName, void *ParameterValue) |
Method for obtaining some specific parameters, such as texture specific params, and so on. | |
virtual Uniform * | getUniformByName (const std::string &UniformName) const =0 |
virtual bool | isAcceptCore (const GraphicCore *Core) const =0 |
Check for GraphicCore acceptance. | |
virtual bool | isAcceptFileExtension (const std::string &FileExtension) const =0 |
Check for correct file extension. | |
bool | isLocked () const |
returns state of object. | |
virtual bool | isShaderCreated (const std::string &ShaderName) const =0 |
virtual bool | isUniformCreated (const std::string &UniformName) const =0 |
virtual bool | preCompile (const std::string &ShaderName, const std::string &ShaderSource, const std::string &Parameters="") |
ShaderSystem (const std::string &ShaderSystemName) | |
virtual void | start ()=0 |
Perform initialization of ShaderSystem. | |
virtual void | stop ()=0 |
Perform deinitialization of ShaderSystem. | |
virtual void | unbind (Shader *shader)=0 |
virtual | ~ShaderSystem () |
Protected Member Functions | |
void | addSpecificParameter (const std::string &ParameterName, void *ParameterValue, size_t Size) |
void | lock () |
void | unlock () |
This class provides unified mechanism for working with shaders, when we need shader, we ask object of this class to create shader for us. It can create shader from source, or from text file.
Definition at line 54 of file shader_system.h.
gpucalc::ShaderSystem::ShaderSystem | ( | const std::string & | ShaderSystemName | ) |
Definition at line 40 of file shader_system.cpp.
00040 : Object(_ShaderSystemClassName, ShaderSystemName) 00041 { 00042 }
gpucalc::ShaderSystem::~ShaderSystem | ( | ) | [virtual] |
virtual void gpucalc::ShaderSystem::addAcceptableGraphicCoreID | ( | const std::string & | GraphicCoreID | ) | [pure virtual] |
Method for manual adding acceptable GraphicCore ID.
This method is useful when we use specific GraphicCore with ID different from standart ids.
Implemented in gpucalc::GLCgShaderSystem, and gpucalc::GLGLSLShaderSystem.
void gpucalc::Object::addSpecificParameter | ( | const std::string & | ParameterName, | |
void * | ParameterValue, | |||
size_t | Size | |||
) | [inline, protected, inherited] |
Definition at line 254 of file object.h.
00255 { 00256 SpecificParametersMap::iterator i = mSpecificParameters.find(ParameterName); 00257 if (i != mSpecificParameters.end()) 00258 { 00259 mSpecificParameters.erase(i); 00260 } 00261 mSpecificParameters[ParameterName] = Any(ParameterValue, Size); 00262 }
virtual void gpucalc::ShaderSystem::bind | ( | Shader * | shader | ) | [pure virtual] |
Implemented in gpucalc::GLCgShaderSystem, and gpucalc::GLGLSLShaderSystem.
Creates Uniform from texture.
texture | - texture, from which we convert to our Uniform. |
Implemented in gpucalc::GLCgShaderSystem, and gpucalc::GLGLSLShaderSystem.
creates Uniform variable.
data | - represents data, from which we convert to our Uniform. |
Implemented in gpucalc::GLCgShaderSystem, and gpucalc::GLGLSLShaderSystem.
virtual Shader* gpucalc::ShaderSystem::create | ( | const std::string & | ShaderName | ) | [pure virtual] |
Creates Shader object.
ShaderName | - name of our shader object. |
Implemented in gpucalc::GLCgShaderSystem, and gpucalc::GLGLSLShaderSystem.
virtual void gpucalc::ShaderSystem::destroy | ( | Shader * | shader | ) | [pure virtual] |
Deletes Shader object.
This method removes shader from mShaderMap and delete it.
Implemented in gpucalc::GLCgShaderSystem, and gpucalc::GLGLSLShaderSystem.
virtual void gpucalc::ShaderSystem::destroy | ( | Uniform * | uniform | ) | [pure virtual] |
Deletes given Uniform.
Sometimes Uniform may contain pointers or smth else. This method does NOT delete it (pointers).
Implemented in gpucalc::GLCgShaderSystem, and gpucalc::GLGLSLShaderSystem.
virtual Shader* gpucalc::ShaderSystem::getActiveShader | ( | ) | const [pure virtual] |
Implemented in gpucalc::GLCgShaderSystem, and gpucalc::GLGLSLShaderSystem.
const std::string& gpucalc::Object::getClassName | ( | ) | const [inline, inherited] |
Returns name of class of our object.
Definition at line 92 of file object.h.
00093 { 00094 return mClassName; 00095 }
virtual debugger::CodeInstructor* gpucalc::ShaderSystem::getCodeInstructor | ( | ) | const [pure virtual] |
Returns CodeInstructor - special object, which allows to instruct shader with debugging symbols.
Implemented in gpucalc::GLCgShaderSystem, and gpucalc::GLGLSLShaderSystem.
const std::string& gpucalc::Object::getObjectName | ( | ) | const [inline, inherited] |
Returns name of our object.
Definition at line 101 of file object.h.
00102 { 00103 return mObjectName; 00104 }
virtual Shader* gpucalc::ShaderSystem::getShaderByName | ( | const std::string & | ShaderName | ) | const [pure virtual] |
Implemented in gpucalc::GLCgShaderSystem, and gpucalc::GLGLSLShaderSystem.
void gpucalc::Object::getSpecificParameter | ( | const std::string & | ParameterName, | |
void * | ParameterValue | |||
) | [inline, inherited] |
Method for obtaining some specific parameters, such as texture specific params, and so on.
ParameterName | - name of parameter, usually it similar to specific method of some object (for example, GLTextureID) | |
ParameterValue | - contain value of named parameter, it must be allocated and have sufficient size. |
Definition at line 128 of file object.h.
00129 { 00130 SpecificParametersMap::iterator i = mSpecificParameters.find(ParameterName); 00131 if (i != mSpecificParameters.end()) 00132 { 00133 i->second.copyValue(ParameterValue); 00134 } 00135 else 00136 { 00137 Except<ERR_ITEM_NOT_FOUND>(this, "Parameter \"" + ParameterName + "\" does not exists.", "Object::getSpecificParameter()", __FILE__, __LINE__); 00138 } 00139 }
virtual Uniform* gpucalc::ShaderSystem::getUniformByName | ( | const std::string & | UniformName | ) | const [pure virtual] |
Implemented in gpucalc::GLCgShaderSystem, and gpucalc::GLGLSLShaderSystem.
virtual bool gpucalc::ShaderSystem::isAcceptCore | ( | const GraphicCore * | Core | ) | const [pure virtual] |
Check for GraphicCore acceptance.
We need correct type of GraphicCore, because some shader systems cannot work with some graphic cores (DX core and GL system).
Implemented in gpucalc::GLCgShaderSystem, and gpucalc::GLGLSLShaderSystem.
virtual bool gpucalc::ShaderSystem::isAcceptFileExtension | ( | const std::string & | FileExtension | ) | const [pure virtual] |
Check for correct file extension.
Implemented in gpucalc::GLCgShaderSystem, and gpucalc::GLGLSLShaderSystem.
bool gpucalc::Object::isLocked | ( | ) | const [inline, inherited] |
virtual bool gpucalc::ShaderSystem::isShaderCreated | ( | const std::string & | ShaderName | ) | const [pure virtual] |
Implemented in gpucalc::GLCgShaderSystem, and gpucalc::GLGLSLShaderSystem.
virtual bool gpucalc::ShaderSystem::isUniformCreated | ( | const std::string & | UniformName | ) | const [pure virtual] |
Implemented in gpucalc::GLCgShaderSystem, and gpucalc::GLGLSLShaderSystem.
void gpucalc::Object::lock | ( | ) | [inline, protected, inherited] |
bool gpucalc::ShaderSystem::preCompile | ( | const std::string & | ShaderName, | |
const std::string & | ShaderSource, | |||
const std::string & | Parameters = "" | |||
) | [virtual] |
Definition at line 48 of file shader_system.cpp.
00049 { 00050 try 00051 { 00052 Shader * sh = create(ShaderName); 00053 sh->setSource(ShaderSource); 00054 sh->compile(Parameters); 00055 return true; 00056 } 00057 catch(const Exception & e) 00058 { 00059 LogManager::getSingleton().logMessage(this, "Precompilation failed, see log for details.", LML_Critical); 00060 return false; 00061 } 00062 }
virtual void gpucalc::ShaderSystem::start | ( | ) | [pure virtual] |
Perform initialization of ShaderSystem.
Implemented in gpucalc::GLCgShaderSystem, and gpucalc::GLGLSLShaderSystem.
virtual void gpucalc::ShaderSystem::stop | ( | ) | [pure virtual] |
Perform deinitialization of ShaderSystem.
Implemented in gpucalc::GLCgShaderSystem, and gpucalc::GLGLSLShaderSystem.
virtual void gpucalc::ShaderSystem::unbind | ( | Shader * | shader | ) | [pure virtual] |
Implemented in gpucalc::GLCgShaderSystem, and gpucalc::GLGLSLShaderSystem.
void gpucalc::Object::unlock | ( | ) | [inline, protected, inherited] |