Public Member Functions | Protected Attributes

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

#include <spConstantBuffer.hpp>

Inheritance diagram for sp::video::ConstantBuffer:
sp::video::Direct3D11ConstantBuffer sp::video::OpenGLConstantBuffer

List of all members.

Public Member Functions

 ConstantBuffer (ShaderClass *Owner, const io::stringc &Name, u32 Index)
virtual ~ConstantBuffer ()
virtual bool updateBuffer (const void *Buffer, u32 Size=0)
virtual bool valid () const
 Returns true if this is a valid and successful created constant buffer.
void setBufferUsage (const EHWBufferUsage Usage)
const io::stringcgetName () const
 Returns the buffer name. This is the same name as used in the shader and can not be changed.
u32 getSize () const
u32 getIndex () const
 Returns the constant buffer index.
EHWBufferUsage getBufferUsage () const
 Returns the buffer usage. By default HWBUFFER_STATIC.
ShaderClassgetShaderClass () const
 Returns a pointer to the shader-class reference to which this buffer belongs.

Protected Attributes

ShaderClassShader_
 Shader-class reference.
EHWBufferUsage Usage_
bool HasUsageChanged_
u32 Size_

Detailed Description

Shader constant buffer class used for OpenGL 3 and Direct3D 11. Direct3D 9 does not support constant buffers! For this you still have to use the old uniforms or rather individual shader constants. Constant buffers are particularly used to group large shader uniform arrays.

See also:
Shader
ShaderClass
MeshBuffer
Since:
Version 3.2

Constructor & Destructor Documentation

sp::video::ConstantBuffer::ConstantBuffer ( ShaderClass Owner,
const io::stringc Name,
u32  Index 
)

Constant buffer constructor.

Parameters:
[in] Owner Pointer to the shader-class which owns this constant buffer. This must not be a null pointer!
[in] Name Specifies the constant buffer name. This must not be empty!
[in] Index Specifies the constant buffer index.
Exceptions:
io::NullPointerException If 'Owner' is a null pointer.
io::DefaultException If 'Name' is empty.
See also:
ShaderClass
sp::video::ConstantBuffer::~ConstantBuffer (  )  [virtual]

Member Function Documentation

EHWBufferUsage sp::video::ConstantBuffer::getBufferUsage (  )  const [inline]

Returns the buffer usage. By default HWBUFFER_STATIC.

u32 sp::video::ConstantBuffer::getIndex (  )  const [inline]

Returns the constant buffer index.

const io::stringc& sp::video::ConstantBuffer::getName (  )  const [inline]

Returns the buffer name. This is the same name as used in the shader and can not be changed.

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

Returns a pointer to the shader-class reference to which this buffer belongs.

u32 sp::video::ConstantBuffer::getSize (  )  const [inline]

Returns the buffer size in bytes. By default constant buffers are aligned in 4 component vectors (i.e. 4 floats). Thus the size is normally 16, 32, 48 etc.

void sp::video::ConstantBuffer::setBufferUsage ( const EHWBufferUsage  Usage  ) 

Sets the buffer usage type. Set this to dynamic usage if the buffer is modified often. Otherwise set it to static usage. By default HWBUFFER_DYNAMIC.

Note:
The new usage type will only become active when the "updateBuffer" function is called the next time.
See also:
EHWBufferUsage
MeshBuffer::setVertexBufferUsage
MeshBuffer::setIndexBufferUsage
bool sp::video::ConstantBuffer::updateBuffer ( const void *  Buffer,
u32  Size = 0 
) [virtual]

Updates the constant buffer by uploading the data to the shader.

Parameters:
[in] Buffer Constant pointer to the buffer data.
[in] Size Specifies the buffer size (in bytes). If zero the engine determines the size automatically. By default zero.
Returns:
True if the buffer could be updated successful. Otherwise false is returned and an error or warning message will be printed.

Reimplemented in sp::video::Direct3D11ConstantBuffer, and sp::video::OpenGLConstantBuffer.

bool sp::video::ConstantBuffer::valid (  )  const [virtual]

Returns true if this is a valid and successful created constant buffer.

Reimplemented in sp::video::Direct3D11ConstantBuffer, and sp::video::OpenGLConstantBuffer.


Member Data Documentation

Shader-class reference.


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