#include <spShaderProgram.hpp>
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 SShaderConstant * | getConstantRef (const io::stringc &Name) const |
virtual const SShaderConstant & | getConstant (const io::stringc &Name) const |
virtual ConstantBuffer * | getConstantBuffer (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. | |
ShaderClass * | getShaderClass () 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_ |
ShaderClass * | ShdClass_ |
std::vector< SShaderConstant > | ConstantList_ |
std::vector< ConstantBuffer * > | ConstantBufferList_ |
bool | HighLevel_ |
bool | OwnShaderClass_ |
bool | CompiledSuccessfully_ |
Static Protected Attributes | |
static SShaderConstant | EmptyConstant_ |
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.
sp::video::Shader::Shader | ( | ShaderClass * | ShdClass, | |
const EShaderTypes | Type, | |||
const EShaderVersions | Version | |||
) |
sp::video::Shader::~Shader | ( | ) | [virtual] |
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");
[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.
[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.
[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. |
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.
[in] | Name | Specifies the shader constant name (or rather shader uniform). |
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).
[in] | Name | Specifies the buffer block name in the shader. |
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.
[in] | Name | Specifies the shader constant name (or rather shader uniform). |
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] |
Reimplemented in sp::video::Direct3D9Shader, sp::video::OpenGLShader, and sp::video::CgShaderProgram.
bool sp::video::Shader::setConstant | ( | const f32 * | Buffer, | |
s32 | StartRegister, | |||
s32 | ConstAmount | |||
) | [virtual] |
Sets floating-point constant arrays for assembly shaders.
[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] |
Reimplemented in sp::video::Direct3D9Shader, and sp::video::OpenGLShader.
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] |
Reimplemented in sp::video::Direct3D9Shader, sp::video::OpenGLShader, sp::video::CgShaderProgram, and sp::video::CgShaderProgramGL.
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] |
Reimplemented in sp::video::Direct3D9Shader, and sp::video::OpenGLShader.
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] |
Reimplemented in sp::video::Direct3D9Shader, sp::video::OpenGLShader, and sp::video::CgShaderProgram.
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] |
Reimplemented in sp::video::Direct3D9Shader, and sp::video::OpenGLShader.
bool sp::video::Shader::setConstant | ( | const io::stringc & | Name, | |
const dim::vector3df & | Position | |||
) | [virtual] |
Reimplemented in sp::video::Direct3D9Shader, sp::video::OpenGLShader, and sp::video::CgShaderProgram.
bool sp::video::Shader::setConstant | ( | const io::stringc & | Name, | |
const s32 * | Buffer, | |||
s32 | Count | |||
) | [virtual] |
Reimplemented in sp::video::Direct3D9Shader, sp::video::OpenGLShader, and sp::video::CgShaderProgram.
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] |
Reimplemented in sp::video::Direct3D9Shader, sp::video::OpenGLShader, and sp::video::CgShaderProgram.
bool sp::video::Shader::setConstant | ( | const io::stringc & | Name, | |
const f32 | Value | |||
) | [virtual] |
Reimplemented in sp::video::Direct3D9Shader, sp::video::OpenGLShader, and sp::video::CgShaderProgram.
bool sp::video::Shader::setConstant | ( | s32 | Number, | |
const EConstantTypes | Type, | |||
const f32 * | Buffer, | |||
s32 | Count | |||
) | [virtual] |
Reimplemented in sp::video::Direct3D9Shader, and sp::video::OpenGLShader.
bool sp::video::Shader::setConstant | ( | s32 | Number, | |
const EConstantTypes | Type, | |||
const dim::vector3df & | Position | |||
) | [virtual] |
Reimplemented in sp::video::Direct3D9Shader, and sp::video::OpenGLShader.
bool sp::video::Shader::setConstant | ( | const io::stringc & | Name, | |
const s32 | Value | |||
) | [virtual] |
Reimplemented in sp::video::Direct3D9Shader, sp::video::OpenGLShader, and sp::video::CgShaderProgram.
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+).
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] |
[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.
bool sp::video::Shader::CompiledSuccessfully_ [protected] |
std::vector<ConstantBuffer*> sp::video::Shader::ConstantBufferList_ [protected] |
std::vector<SShaderConstant> sp::video::Shader::ConstantList_ [protected] |
SShaderConstant sp::video::Shader::EmptyConstant_ [static, protected] |
bool sp::video::Shader::HighLevel_ [protected] |
bool sp::video::Shader::OwnShaderClass_ [protected] |
ShaderClass* sp::video::Shader::ShdClass_ [protected] |
EShaderTypes sp::video::Shader::Type_ [protected] |
EShaderVersions sp::video::Shader::Version_ [protected] |