Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends

sp::video::ShaderClass Class Reference

#include <spShaderClass.hpp>

Inheritance diagram for sp::video::ShaderClass:
sp::BaseObject sp::video::CgShaderClass sp::video::Direct3D11ShaderClass sp::video::Direct3D9ShaderClass sp::video::OpenGLShaderClass

List of all members.

Public Member Functions

virtual ~ShaderClass ()
virtual void bind (const scene::MaterialNode *Object=0)=0
virtual void unbind ()=0
 Unbinds the table with its shaders.
virtual bool link ()=0
void setObjectCallback (const ShaderObjectCallback &CallbackProc)
void setSurfaceCallback (const ShaderSurfaceCallback &CallbackProc)
ShadergetVertexShader () const
ShadergetPixelShader () const
ShadergetGeometryShader () const
ShadergetHullShader () const
ShadergetDomainShader () const
ShadergetComputeShader () const
const std::vector
< ConstantBuffer * > & 
getConstantBufferList () const
bool isHighLevel () const
 Returns true if the shader is a high level shader.
bool valid () const
 Returns true if the shader class has been compiled successfully.

Static Public Member Functions

static EShaderVersions getShaderVersion (s32 Flags)
static bool build (const io::stringc &Name, ShaderClass *&ShdClass, VertexFormat *VertFmt, const std::list< io::stringc > *ShdBufferVertex, const std::list< io::stringc > *ShdBufferPixel, const io::stringc &VertexMain="VertexMain", const io::stringc &PixelMain="PixelMain", s32 Flags=SHADERBUILD_CG)

Protected Member Functions

 ShaderClass ()
void printError (const io::stringc &Message)
void printWarning (const io::stringc &Message)

Protected Attributes

ShaderObjectCallback ObjectCallback_
ShaderSurfaceCallback SurfaceCallback_
std::vector< ConstantBuffer * > ConstBufferList_
bool HighLevel_
bool CompiledSuccessfully_


class Shader

Detailed Description

Shader classes are used to link several shaders (Vertex-, Pixel shaders etc.) to one shader program. Modern graphics hardware has the following shader stages:

Constructor & Destructor Documentation

sp::video::ShaderClass::~ShaderClass (  )  [virtual]
sp::video::ShaderClass::ShaderClass (  )  [protected]

Member Function Documentation

virtual void sp::video::ShaderClass::bind ( const scene::MaterialNode Object = 0  )  [pure virtual]

Binds the table with its shaders.

Object,: Pointer to a MaterialNode object which shall be used for the shader callback if set.

Implemented in sp::video::Direct3D9ShaderClass, sp::video::Direct3D11ShaderClass, sp::video::OpenGLShaderClass, and sp::video::CgShaderClass.

bool sp::video::ShaderClass::build ( const io::stringc Name,
ShaderClass *&  ShdClass,
VertexFormat VertFmt,
const std::list< io::stringc > *  ShdBufferVertex,
const std::list< io::stringc > *  ShdBufferPixel,
const io::stringc VertexMain = "VertexMain",
const io::stringc PixelMain = "PixelMain",
s32  Flags = SHADERBUILD_CG 
) [static]

Builds a complete shader class with the specified vertex-format, shader source code and build flags. This is particularly used internally for the deferred-renderer and post-processing effects.

[in] Name Specifies the shader name and is used for possible error messages.
[out] ShdClass Specifies the resulting shader class object.
[in] VertFmt Pointer to the vertex format used for the shader class.
[in] ShdBufferVertex Constant pointer to the vertex shader source code (std::list<io::stringc>).
[in] ShdBufferPixel Constant pointer to the pixel shader source code (std::list<io::stringc>).
[in] VertexMain Specifies the name of the vertex shader main function.
[in] PixelMain Specifies the name of the pixel shader main function.
[in] Flags Specifies the compilation flags. This can be one of the following values: SHADERBUILD_CG, SHADERBUILD_GLSL, SHADERBUILD_HLSL3 or SHADERBUILD_HLSL5.
True if the shader class could be created successful.
This function always failes if "ShdBufferVertex" is null pointers.
See also:
Version 3.2
Shader* sp::video::ShaderClass::getComputeShader (  )  const [inline]
const std::vector<ConstantBuffer*>& sp::video::ShaderClass::getConstantBufferList (  )  const [inline]

Returns the list of all shader constant buffers used in the shader-class. To get the list of all shader constant buffers used in a single shader object, use the equivalent function of the respective shader.

See also:
Shader* sp::video::ShaderClass::getDomainShader (  )  const [inline]
Shader* sp::video::ShaderClass::getGeometryShader (  )  const [inline]
Shader* sp::video::ShaderClass::getHullShader (  )  const [inline]
Shader* sp::video::ShaderClass::getPixelShader (  )  const [inline]
EShaderVersions sp::video::ShaderClass::getShaderVersion ( s32  Flags  )  [static]

Returns the shader version used for the specified flags.

[in] Flags Specifies the build flags. This can be a combination of the values in the "EBuildShaderFlags" enumeration.
Shader version specified in the "EShaderVersions" enumeration. If no version could be found "DUMMYSHADER_VERSION" will be returned.
See also:
Version 3.2
Shader* sp::video::ShaderClass::getVertexShader (  )  const [inline]
bool sp::video::ShaderClass::isHighLevel (  )  const [inline]

Returns true if the shader is a high level shader.

virtual bool sp::video::ShaderClass::link (  )  [pure virtual]

Links the program with all its shaders.

Rename this to "compile"

Implemented in sp::video::Direct3D9ShaderClass, sp::video::Direct3D11ShaderClass, sp::video::OpenGLShaderClass, and sp::video::CgShaderClass.

void sp::video::ShaderClass::printError ( const io::stringc Message  )  [protected]
void sp::video::ShaderClass::printWarning ( const io::stringc Message  )  [protected]
void sp::video::ShaderClass::setObjectCallback ( const ShaderObjectCallback CallbackProc  )  [inline]

Sets the shader object callback function.

CallbackProc,: Callback function in the form of "void Callback(ShaderClass* Table, const scene::MaterialNode* Object);". This callback normally is used to update the world- view matrix. In GLSL these matrices are integrated but in HLSL you have to set these shader-constants manually.
void sp::video::ShaderClass::setSurfaceCallback ( const ShaderSurfaceCallback CallbackProc  )  [inline]

Sets the shader surface callback function.

[in] CallbackProc Specifies the surface callback function. This callback normally is used to update texture settings for each surface.
See also:
virtual void sp::video::ShaderClass::unbind (  )  [pure virtual]
bool sp::video::ShaderClass::valid (  )  const [inline]

Returns true if the shader class has been compiled successfully.

Friends And Related Function Documentation

friend class Shader [friend]

Member Data Documentation

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines