gpucalc::ShaderSystem Class Reference

Class representing storage for our shader objects. More...

#include <shader_system.h>

Inheritance diagram for gpucalc::ShaderSystem:

Inheritance graph

List of all members.

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 Uniformcreate (Texture *texture)=0
 Creates Uniform from texture.
virtual Uniformcreate (const Data &data)=0
 creates Uniform variable.
virtual Shadercreate (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 ShadergetActiveShader () const =0
const std::string & getClassName () const
 Returns name of class of our object.
virtual debugger::CodeInstructorgetCodeInstructor () 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 ShadergetShaderByName (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 UniformgetUniformByName (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 ()


Detailed Description

Class representing storage for our shader objects.

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.

Todo:
Create method for creating shader from OBJECT code. See Cg manual.

Definition at line 54 of file shader_system.h.


Constructor & Destructor Documentation

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]

Definition at line 44 of file shader_system.cpp.

00045     {
00046     }


Member Function Documentation

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]

virtual Uniform* gpucalc::ShaderSystem::create ( Texture texture  )  [pure virtual]

Creates Uniform from texture.

Parameters:
texture - texture, from which we convert to our Uniform.

Implemented in gpucalc::GLCgShaderSystem, and gpucalc::GLGLSLShaderSystem.

virtual Uniform* gpucalc::ShaderSystem::create ( const Data data  )  [pure virtual]

creates Uniform variable.

Parameters:
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.

Parameters:
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]

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]

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.

Parameters:
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.
Todo:
Think for better realization.

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]

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]

returns state of object.

If object is locked then we cannot change some state of it, because object is used in computation. If object is unlocked then we can change some state of it, object is not in computation.

Definition at line 113 of file object.h.

00114    {
00115     return mIsLocked;
00116    }

virtual bool gpucalc::ShaderSystem::isShaderCreated ( const std::string &  ShaderName  )  const [pure virtual]

virtual bool gpucalc::ShaderSystem::isUniformCreated ( const std::string &  UniformName  )  const [pure virtual]

void gpucalc::Object::lock (  )  [inline, protected, inherited]

Definition at line 265 of file object.h.

00266    {
00267     mIsLocked = true;
00268    }

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]

void gpucalc::Object::unlock (  )  [inline, protected, inherited]

Definition at line 271 of file object.h.

00272    {
00273     mIsLocked = false;
00274    }


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

Generated on Thu Mar 5 22:36:46 2009 for gpucalc by  doxygen 1.5.6