gpucalc::Shader Class Reference

Class representing abstract shader - program for GPU. More...

#include <shader.h>

Inheritance diagram for gpucalc::Shader:

Inheritance graph

List of all members.

Public Member Functions

virtual void addUniform (Uniform *uniform)=0
 Set uniform variable, declared in our shader.
void bind ()
 Bind our object.
virtual void compile (const std::string &Parameters=std::string())=0
 Compiles current shader.
const std::string & getClassName () const
 Returns name of class of our object.
virtual std::string getLanguageID () const =0
const std::string & getObjectName () const
 Returns name of our object.
virtual std::string getSource () const =0
 Returns current source of shader.
void getSpecificParameter (const std::string &ParameterName, void *ParameterValue)
 Method for obtaining some specific parameters, such as texture specific params, and so on.
bool isActive () const
virtual bool isCompiled () const =0
 Simple method for checking compilation status.
virtual bool isDebugEnabled () const =0
 Check for debugging our shader.
bool isLocked () const
 returns state of object.
virtual void preCompute ()=0
 Precompute shader.
virtual void removeUniform (Uniform *uniform)=0
 Remove uniform variable from shader.
virtual void setSource (const std::string &ShaderSource)=0
 Performs basic initialization of shader and sets up shader source.
 Shader (const std::string &ShaderClassName, const std::string &ShaderName, ShaderSystem *System)
void unbind ()
 Unbind our object.
virtual void validate ()=0
 Validate Shader.
virtual ~Shader ()

Protected Member Functions

void addSpecificParameter (const std::string &ParameterName, void *ParameterValue, size_t Size)
void lock ()
void unlock ()

Private Attributes

ShaderSystemmDefaultShaderSystem


Detailed Description

Class representing abstract shader - program for GPU.

Definition at line 53 of file shader.h.


Constructor & Destructor Documentation

gpucalc::Shader::Shader ( const std::string &  ShaderClassName,
const std::string &  ShaderName,
ShaderSystem System 
) [inline]

Definition at line 62 of file shader.h.

00062                                                                                                  :
00063     Object(ShaderClassName, ShaderName), Bindable(ShaderClassName, ShaderName), mDefaultShaderSystem(System)
00064    {
00065    }

virtual gpucalc::Shader::~Shader (  )  [inline, virtual]

Definition at line 68 of file shader.h.

00069    {
00070    }


Member Function Documentation

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::Shader::addUniform ( Uniform uniform  )  [pure virtual]

Set uniform variable, declared in our shader.

Parameters:
uniform - pointer to class Uniform, that contain all necessary members for correct setting uniform variable.

Implemented in gpucalc::GLCgShader, and gpucalc::GLGLSLShader.

void gpucalc::Shader::bind (  )  [inline, virtual]

Bind our object.

For example, set in some active state (Texture, Shader and so on)

Implements gpucalc::Bindable.

Definition at line 140 of file shader.h.

00141    {
00142     mDefaultShaderSystem->bind(this);
00143    }

virtual void gpucalc::Shader::compile ( const std::string &  Parameters = std::string()  )  [pure virtual]

Compiles current shader.

Implemented in gpucalc::GLCgShader, and gpucalc::GLGLSLShader.

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 std::string gpucalc::Shader::getLanguageID (  )  const [pure virtual]

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 std::string gpucalc::Shader::getSource (  )  const [pure virtual]

Returns current source of shader.

Implemented in gpucalc::GLCgShader, and gpucalc::GLGLSLShader.

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    }

bool gpucalc::Shader::isActive (  )  const [inline, virtual]

Implements gpucalc::Bindable.

Definition at line 134 of file shader.h.

00135    {
00136     return (this == mDefaultShaderSystem->getActiveShader());
00137    }

virtual bool gpucalc::Shader::isCompiled (  )  const [pure virtual]

Simple method for checking compilation status.

Implemented in gpucalc::GLCgShader, and gpucalc::GLGLSLShader.

virtual bool gpucalc::Shader::isDebugEnabled (  )  const [pure virtual]

Check for debugging our shader.

Implemented in gpucalc::GLCgShader, and gpucalc::GLGLSLShader.

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    }

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

Definition at line 265 of file object.h.

00266    {
00267     mIsLocked = true;
00268    }

virtual void gpucalc::Shader::preCompute (  )  [pure virtual]

Precompute shader.

Implemented in gpucalc::GLCgShader, and gpucalc::GLGLSLShader.

virtual void gpucalc::Shader::removeUniform ( Uniform uniform  )  [pure virtual]

Remove uniform variable from shader.

Implemented in gpucalc::GLCgShader, and gpucalc::GLGLSLShader.

virtual void gpucalc::Shader::setSource ( const std::string &  ShaderSource  )  [pure virtual]

Performs basic initialization of shader and sets up shader source.

Depending on shader type this method can compile shader or not.

Implemented in gpucalc::GLCgShader, and gpucalc::GLGLSLShader.

void gpucalc::Shader::unbind (  )  [inline, virtual]

Unbind our object.

For example, set in some inactive state (Texture, Shader and so on)

Implements gpucalc::Bindable.

Definition at line 146 of file shader.h.

00147    {
00148     mDefaultShaderSystem->unbind(this);
00149    }

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

Definition at line 271 of file object.h.

00272    {
00273     mIsLocked = false;
00274    }

virtual void gpucalc::Shader::validate (  )  [pure virtual]

Validate Shader.

This method checks that all uniform variables are set. Also it checks that this program is ready for use.

Implemented in gpucalc::GLCgShader, and gpucalc::GLGLSLShader.


Member Data Documentation

Definition at line 156 of file shader.h.


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

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