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

sp::video::Shader Class Reference
[Shaders]

#include <spShaderProgram.hpp>

Inheritance diagram for sp::video::Shader:
sp::video::CgShaderProgram sp::video::Direct3D11Shader sp::video::Direct3D9Shader sp::video::OpenGLShader sp::video::CgShaderProgramD3D11 sp::video::CgShaderProgramD3D9 sp::video::CgShaderProgramGL

List of all members.

Public Member Functions

 Shader (ShaderClass *ShdClass, const EShaderTypes Type, const EShaderVersions Version)
virtual ~Shader ()
virtual bool compile (const std::list< io::stringc > &ShaderBuffer, const io::stringc &EntryPoint="", const c8 **CompilerOptions=0)
virtual const SShaderConstantgetConstantRef (const io::stringc &Name) const
virtual const SShaderConstantgetConstant (const io::stringc &Name) const
virtual ConstantBuffergetConstantBuffer (const io::stringc &Name) const
virtual bool setConstant (s32 Number, const EConstantTypes Type, const f32 Value)
virtual bool setConstant (s32 Number, const EConstantTypes Type, const f32 *Buffer, s32 Count)
virtual bool setConstant (s32 Number, const EConstantTypes Type, const dim::vector3df &Position)
virtual bool setConstant (s32 Number, const EConstantTypes Type, const video::color &Color)
virtual bool setConstant (s32 Number, const EConstantTypes Type, const dim::matrix4f &Matrix)
virtual bool setConstant (const io::stringc &Name, const f32 Value)
virtual bool setConstant (const io::stringc &Name, const f32 *Buffer, s32 Count)
virtual bool setConstant (const io::stringc &Name, const s32 Value)
virtual bool setConstant (const io::stringc &Name, const s32 *Buffer, s32 Count)
virtual bool setConstant (const io::stringc &Name, const dim::vector3df &Position)
virtual bool setConstant (const io::stringc &Name, const dim::vector4df &Position)
virtual bool setConstant (const io::stringc &Name, const video::color &Color)
virtual bool setConstant (const io::stringc &Name, const dim::matrix4f &Matrix)
virtual bool setConstant (const SShaderConstant &Constant, const f32 Value)
virtual bool setConstant (const SShaderConstant &Constant, const f32 *Buffer, s32 Count)
virtual bool setConstant (const SShaderConstant &Constant, const s32 Value)
virtual bool setConstant (const SShaderConstant &Constant, const s32 *Buffer, s32 Count)
virtual bool setConstant (const SShaderConstant &Constant, const dim::vector3df &Vector)
virtual bool setConstant (const SShaderConstant &Constant, const dim::vector4df &Vector)
virtual bool setConstant (const SShaderConstant &Constant, const video::color &Color)
virtual bool setConstant (const SShaderConstant &Constant, const dim::matrix4f &Matrix)
virtual bool setConstant (const f32 *Buffer, s32 StartRegister, s32 ConstAmount)
virtual bool setConstantBuffer (const io::stringc &Name, const void *Buffer)
virtual bool setConstantBuffer (u32 Number, const void *Buffer)
EShaderTypes getType () const
 Returns the shader type.
EShaderVersions getVersion () const
 Returns the shader model version.
ShaderClassgetShaderClass () const
 Returns a pointer to the shader class.
const std::vector
< SShaderConstant > & 
getConstantList () const
 Returns the list of all shader constants.
u32 getConstantCount () const
 Returns the count of shader constants.
const std::vector
< ConstantBuffer * > & 
getConstantBufferList () const
 Returns the list of all shader constant buffers.
u32 getConstantBufferCount () const
 Returns the count of shader constant buffers.
bool valid () const
 Returns true if the shader has been compiled successfully otherwise false.
bool isHighLevel () const
 Returns true if this is a high-level shader.

Static Public Member Functions

static io::stringc getOption (const io::stringc &Op)
 Returns a shader compiler option. This is equivalent to: "#define" + Op + "\n".
static void addOption (std::list< io::stringc > &ShaderCompilerOp, const io::stringc &Op)
static void addShaderCore (std::list< io::stringc > &ShaderCode, bool UseCg=false)

Protected Member Functions

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

Static Protected Member Functions

static void createProgramString (const std::list< io::stringc > &ShaderBuffer, c8 *&ProgramBuffer)

Protected Attributes

EShaderTypes Type_
EShaderVersions Version_
ShaderClassShdClass_
std::vector< SShaderConstantConstantList_
std::vector< ConstantBuffer * > ConstantBufferList_
bool HighLevel_
bool OwnShaderClass_
bool CompiledSuccessfully_

Static Protected Attributes

static SShaderConstant EmptyConstant_

Detailed Description

Shader objects are used for high- or low level shader effects. Supported are GLSL (OpenGL Shading Language), HLSL (DirectX High Level Shading Language), OpenGL ARB Vertex- and Fragement Programs and DirectX Vertex- and Pixel Programs.


Constructor & Destructor Documentation

sp::video::Shader::Shader ( ShaderClass ShdClass,
const EShaderTypes  Type,
const EShaderVersions  Version 
)
sp::video::Shader::~Shader (  )  [virtual]

Member Function Documentation

void sp::video::Shader::addOption ( std::list< io::stringc > &  ShaderCompilerOp,
const io::stringc Op 
) [static]

Adds a shader compiler option to the given list. The behaivour of this function is equivalent to the following code:

        ShaderCompilerOp.push_back("#define " + Op + "\n");
Parameters:
[in,out] ShaderCompilerOp Specifies the list of strings which is to be extended.
[in] Op Specifies the new compiler option.
void sp::video::Shader::addShaderCore ( std::list< io::stringc > &  ShaderCode,
bool  UseCg = false 
) [static]

Adds the shader core to the given source code. This should be added to the front of the list. It contains a lot of macros so that shaders can be written mainly independently of the underlying render system, e.g. for GLSL you can also use float2, float4x4 etc.

Parameters:
[out] ShaderCode Specifies the resulting shader source code string list.
[in] UseCg Specifies whether Cg shaders are to be used or not. By default false.
bool sp::video::Shader::compile ( const std::list< io::stringc > &  ShaderBuffer,
const io::stringc EntryPoint = "",
const c8 **  CompilerOptions = 0 
) [virtual]

Compiles the given shader source code.

Parameters:
[in] ShaderBuffer Specifies the shader source code in form of a string container. Each string line has to end with the end-of-line character ('
')!
[in] EntryPoint Specifies the shader entry point. This not required for GLSL shaders. But for HLSL and Cg. It's actually just the shader's main function name.
[in] CompilerOptions Specifies the pointer to the comiler option strings.
Returns:
True if the shader could be compiled successful.

Reimplemented in sp::video::Direct3D9Shader, sp::video::Direct3D11Shader, sp::video::OpenGLShader, and sp::video::CgShaderProgram.

void sp::video::Shader::createProgramString ( const std::list< io::stringc > &  ShaderBuffer,
c8 *&  ProgramBuffer 
) [static, protected]
const SShaderConstant & sp::video::Shader::getConstant ( const io::stringc Name  )  const [virtual]

Returns the specified shader constant.

Parameters:
[in] Name Specifies the shader constant name (or rather shader uniform).
Returns:
Constant reference to the SShaderConstant object. If the shader constant does not exist, the default dempty shader constant will be returned.

Reimplemented in sp::video::OpenGLShader.

ConstantBuffer * sp::video::Shader::getConstantBuffer ( const io::stringc Name  )  const [virtual]

Returns the specified constant buffer (or rather uniform buffer block).

Parameters:
[in] Name Specifies the buffer block name in the shader.
Returns:
Pointer to the ConstantBuffer object or null if the active render system does not support constant buffers.
Note:
Only the OpenGL 4 and Direct3D 11 render systems support constant buffers.
See also:
ConstantBuffer
u32 sp::video::Shader::getConstantBufferCount (  )  const [inline]

Returns the count of shader constant buffers.

const std::vector<ConstantBuffer*>& sp::video::Shader::getConstantBufferList (  )  const [inline]

Returns the list of all shader constant buffers.

u32 sp::video::Shader::getConstantCount (  )  const [inline]

Returns the count of shader constants.

Reimplemented in sp::video::Direct3D11Shader.

const std::vector<SShaderConstant>& sp::video::Shader::getConstantList (  )  const [inline]

Returns the list of all shader constants.

Reimplemented in sp::video::Direct3D11Shader.

const SShaderConstant * sp::video::Shader::getConstantRef ( const io::stringc Name  )  const [virtual]

Returns a pointer to the specified shader constant.

Parameters:
[in] Name Specifies the shader constant name (or rather shader uniform).
Returns:
Constant pointer to the specified shader constant or null if the shader constant does not exist.

Reimplemented in sp::video::OpenGLShader.

io::stringc sp::video::Shader::getOption ( const io::stringc Op  )  [static]

Returns a shader compiler option. This is equivalent to: "#define" + Op + "\n".

ShaderClass* sp::video::Shader::getShaderClass (  )  const [inline]

Returns a pointer to the shader class.

EShaderTypes sp::video::Shader::getType (  )  const [inline]

Returns the shader type.

EShaderVersions sp::video::Shader::getVersion (  )  const [inline]

Returns the shader model version.

bool sp::video::Shader::isHighLevel (  )  const [inline]

Returns true if this is a high-level shader.

void sp::video::Shader::printError ( const io::stringc Message  )  [protected]
void sp::video::Shader::printWarning ( const io::stringc Message  )  [protected]
bool sp::video::Shader::setConstant ( const io::stringc Name,
const video::color Color 
) [virtual]
bool sp::video::Shader::setConstant ( const f32 Buffer,
s32  StartRegister,
s32  ConstAmount 
) [virtual]

Sets floating-point constant arrays for assembly shaders.

Parameters:
[in] Buffer Pointer to a floating-point buffer.
[in] StartRegister Specifies the register start offset (in 4 bytes).
[in] ConstAmount Specifies the count of constants (or rather array size).

Reimplemented in sp::video::Direct3D9Shader, and sp::video::OpenGLShader.

bool sp::video::Shader::setConstant ( const SShaderConstant Constant,
const dim::matrix4f Matrix 
) [virtual]

Reimplemented in sp::video::OpenGLShader.

bool sp::video::Shader::setConstant ( s32  Number,
const EConstantTypes  Type,
const video::color Color 
) [virtual]
bool sp::video::Shader::setConstant ( const SShaderConstant Constant,
const dim::vector4df Vector 
) [virtual]

Reimplemented in sp::video::OpenGLShader.

bool sp::video::Shader::setConstant ( const io::stringc Name,
const f32 Buffer,
s32  Count 
) [virtual]
bool sp::video::Shader::setConstant ( const SShaderConstant Constant,
const dim::vector3df Vector 
) [virtual]

Reimplemented in sp::video::OpenGLShader.

bool sp::video::Shader::setConstant ( s32  Number,
const EConstantTypes  Type,
const dim::matrix4f Matrix 
) [virtual]
bool sp::video::Shader::setConstant ( const SShaderConstant Constant,
const s32  Value 
) [virtual]

Reimplemented in sp::video::OpenGLShader.

bool sp::video::Shader::setConstant ( const io::stringc Name,
const dim::matrix4f Matrix 
) [virtual]
bool sp::video::Shader::setConstant ( const SShaderConstant Constant,
const f32 Buffer,
s32  Count 
) [virtual]

Reimplemented in sp::video::OpenGLShader.

bool sp::video::Shader::setConstant ( const SShaderConstant Constant,
const f32  Value 
) [virtual]

Reimplemented in sp::video::OpenGLShader.

bool sp::video::Shader::setConstant ( s32  Number,
const EConstantTypes  Type,
const f32  Value 
) [virtual]
bool sp::video::Shader::setConstant ( const io::stringc Name,
const dim::vector3df Position 
) [virtual]
bool sp::video::Shader::setConstant ( const io::stringc Name,
const s32 Buffer,
s32  Count 
) [virtual]
bool sp::video::Shader::setConstant ( const SShaderConstant Constant,
const video::color Color 
) [virtual]

Reimplemented in sp::video::OpenGLShader.

bool sp::video::Shader::setConstant ( const SShaderConstant Constant,
const s32 Buffer,
s32  Count 
) [virtual]

Reimplemented in sp::video::OpenGLShader.

bool sp::video::Shader::setConstant ( const io::stringc Name,
const dim::vector4df Position 
) [virtual]
bool sp::video::Shader::setConstant ( const io::stringc Name,
const f32  Value 
) [virtual]
bool sp::video::Shader::setConstant ( s32  Number,
const EConstantTypes  Type,
const f32 Buffer,
s32  Count 
) [virtual]
bool sp::video::Shader::setConstant ( s32  Number,
const EConstantTypes  Type,
const dim::vector3df Position 
) [virtual]
bool sp::video::Shader::setConstant ( const io::stringc Name,
const s32  Value 
) [virtual]
bool sp::video::Shader::setConstantBuffer ( const io::stringc Name,
const void *  Buffer 
) [virtual]

Fills a constant buffer with content (actual only for HLSL ShaderModel 4+).

Parameters:
Name,: Constant buffer's name which is to be used.
Buffer,: Pointer to the buffer where the content for the constant buffer is stored. This buffer needs to have the same size like the constant buffer in the shader!

Reimplemented in sp::video::Direct3D11Shader, and sp::video::OpenGLShader.

bool sp::video::Shader::setConstantBuffer ( u32  Number,
const void *  Buffer 
) [virtual]
Parameters:
[in] Number Specifies the index number of the constant buffer which is to be used.

Reimplemented in sp::video::Direct3D11Shader.

void sp::video::Shader::updateShaderClass (  )  [protected]
bool sp::video::Shader::valid (  )  const [inline]

Returns true if the shader has been compiled successfully otherwise false.


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