A named block of uniforms. More...
#include <Uniform.h>
Public Member Functions | |
virtual | ~UniformBlock () |
Deletes this uniform block. | |
string | getName () const |
Returns the name of this uniform block. | |
ptr< GPUBuffer > | getBuffer () const |
Returns the GPUBuffer that stores the values of the uniforms of this block. | |
ptr< Uniform > | getUniform (const string &name) const |
Returns the uniform of this block whose name is given. | |
ptr< Uniform1f > | getUniform1f (const string &name) |
Returns the uniform1f of this block whose name is given. | |
ptr< Uniform1d > | getUniform1d (const string &name) |
Returns the uniform1d of this block whose name is given. | |
ptr< Uniform1i > | getUniform1i (const string &name) |
Returns the uniform1i of this block whose name is given. | |
ptr< Uniform1ui > | getUniform1ui (const string &name) |
Returns the uniform1ui of this block whose name is given. | |
ptr< Uniform1b > | getUniform1b (const string &name) |
Returns the uniform1b of this block whose name is given. | |
ptr< Uniform2f > | getUniform2f (const string &name) |
Returns the uniform2f of this block whose name is given. | |
ptr< Uniform2d > | getUniform2d (const string &name) |
Returns the uniform2d of this block whose name is given. | |
ptr< Uniform2i > | getUniform2i (const string &name) |
Returns the uniform2i of this block whose name is given. | |
ptr< Uniform2ui > | getUniform2ui (const string &name) |
Returns the uniform2ui of this block whose name is given. | |
ptr< Uniform2b > | getUniform2b (const string &name) |
Returns the uniform2b of this block whose name is given. | |
ptr< Uniform3f > | getUniform3f (const string &name) |
Returns the uniform3f of this block whose name is given. | |
ptr< Uniform3d > | getUniform3d (const string &name) |
Returns the uniform3d of this block whose name is given. | |
ptr< Uniform3i > | getUniform3i (const string &name) |
Returns the uniform3i of this block whose name is given. | |
ptr< Uniform3ui > | getUniform3ui (const string &name) |
Returns the uniform3ui of this block whose name is given. | |
ptr< Uniform3b > | getUniform3b (const string &name) |
Returns the uniform3b of this block whose name is given. | |
ptr< Uniform4f > | getUniform4f (const string &name) |
Returns the uniform4f of this block whose name is given. | |
ptr< Uniform4d > | getUniform4d (const string &name) |
Returns the uniform4d of this block whose name is given. | |
ptr< Uniform4i > | getUniform4i (const string &name) |
Returns the uniform4i of this block whose name is given. | |
ptr< Uniform4ui > | getUniform4ui (const string &name) |
Returns the uniform4ui of this block whose name is given. | |
ptr< Uniform4b > | getUniform4b (const string &name) |
Returns the uniform4b of this block whose name is given. | |
ptr< UniformMatrix2f > | getUniformMatrix2f (const string &name) |
Returns the uniformMatrix2f of this block whose name is given. | |
ptr< UniformMatrix2d > | getUniformMatrix2d (const string &name) |
Returns the uniformMatrix2d of this block whose name is given. | |
ptr< UniformMatrix3f > | getUniformMatrix3f (const string &name) |
Returns the uniformMatrix3f of this block whose name is given. | |
ptr< UniformMatrix3d > | getUniformMatrix3d (const string &name) |
Returns the uniformMatrix3d of this block whose name is given. | |
ptr< UniformMatrix4f > | getUniformMatrix4f (const string &name) |
Returns the uniformMatrix4f of this block whose name is given. | |
ptr< UniformMatrix4d > | getUniformMatrix4d (const string &name) |
Returns the uniformMatrix4d of this block whose name is given. | |
ptr< UniformMatrix2x3f > | getUniformMatrix2x3f (const string &name) |
Returns the uniformMatrix2x3f of this block whose name is given. | |
ptr< UniformMatrix2x3d > | getUniformMatrix2x3d (const string &name) |
Returns the uniformMatrix2x3d of this block whose name is given. | |
ptr< UniformMatrix2x4f > | getUniformMatrix2x4f (const string &name) |
Returns the uniformMatrix2x4f of this block whose name is given. | |
ptr< UniformMatrix2x4d > | getUniformMatrix2x4d (const string &name) |
Returns the uniformMatrix2x4d of this block whose name is given. | |
ptr< UniformMatrix3x2f > | getUniformMatrix3x2f (const string &name) |
Returns the uniformMatrix3x2f of this block whose name is given. | |
ptr< UniformMatrix3x2d > | getUniformMatrix3x2d (const string &name) |
Returns the uniformMatrix3x2d of this block whose name is given. | |
ptr< UniformMatrix3x4f > | getUniformMatrix3x4f (const string &name) |
Returns the uniformMatrix3x4f of this block whose name is given. | |
ptr< UniformMatrix3x4d > | getUniformMatrix3x4d (const string &name) |
Returns the uniformMatrix3x4d of this block whose name is given. | |
ptr< UniformMatrix4x2f > | getUniformMatrix4x2f (const string &name) |
Returns the uniformMatrix4x2f of this block whose name is given. | |
ptr< UniformMatrix4x2d > | getUniformMatrix4x2d (const string &name) |
Returns the uniformMatrix4x2d of this block whose name is given. | |
ptr< UniformMatrix4x3f > | getUniformMatrix4x3f (const string &name) |
Returns the uniformMatrix4x3f of this block whose name is given. | |
ptr< UniformMatrix4x3d > | getUniformMatrix4x3d (const string &name) |
Returns the uniformMatrix4x2d of this block whose name is given. | |
ptr< UniformSampler > | getUniformSampler (const string &name) |
Returns the uniform sampler of this block whose name is given. | |
void | setBuffer (ptr< GPUBuffer > buffer) |
Sets the GPUBuffer to store the values of the uniforms of this block. | |
Protected Member Functions | |
UniformBlock (Program *program, const string &name, GLuint index, GLuint size) | |
Creates a new uniform block. | |
bool | isMapped () const |
Returns true if the GPUBuffer associated with this block is currently mapped in client memory. | |
volatile void * | mapBuffer (GLint offset) |
Maps the GPUBuffer associated with this block in client memory. | |
void | unmapBuffer () |
Unmaps the GPUBuffer associated with this block in client memory. | |
Static Protected Member Functions | |
static ptr< GPUBuffer > | newBuffer (string name) |
Callback method to create a new buffer. | |
Protected Attributes | |
Program * | program |
The Program to which this uniform block belongs. | |
string | name |
The name of this uniform block. | |
GLuint | index |
The index of this uniform block in its program. | |
GLuint | size |
The total size of this uniform block's uniforms. | |
ptr< GPUBuffer > | buffer |
The GPUBuffer that stores the values of the uniforms of this block. | |
map< string, ptr< Uniform > > | uniforms |
The uniforms of this block. | |
Static Protected Attributes | |
static static_ptr< Factory < string, ptr< GPUBuffer > > > | buffers |
The buffers associated to each uniform blocks. |
A named block of uniforms.
The values of the uniforms in a uniform block are stored in a GPUBuffer. Different Programs having identical uniform blocks have different UniformBlock objects, but these objects can share the same GPUBuffer to store their values. Hence, changing values inside this GPUBuffer changes the uniform values in all the programs that use this GPUBuffer. You don't have to manipulate the GPUBuffer content yourself to change the uniforms inside a uniform block: this is automatically managed by the Uniform and UniformBlock classes. In particular, these classes know the offset of each uniform in the buffer, and map and unmap this buffer in client memory when necessary. Initially the GPUBuffer associated with a UniformBlock is NULL. You must set it with setBuffer() before using the uniforms of this block.
virtual ork::UniformBlock::~UniformBlock | ( | ) | [virtual] |
Deletes this uniform block.
ork::UniformBlock::UniformBlock | ( | Program * | program, | |
const string & | name, | |||
GLuint | index, | |||
GLuint | size | |||
) | [protected] |
Creates a new uniform block.
program | the program to which this uniform block belongs. | |
name | the name of this uniform block in the GLSL code. | |
index | the index of this uniform block in its program. | |
size | the minimum buffer size to store the uniforms of this block. |
Returns the GPUBuffer that stores the values of the uniforms of this block.
string ork::UniformBlock::getName | ( | ) | const |
Returns the name of this uniform block.
Returns the uniform of this block whose name is given.
name | a uniform name. |
Returns the uniform1b of this block whose name is given.
name | a GLSL uniform name. |
Returns the uniform1d of this block whose name is given.
name | a GLSL uniform name. |
Returns the uniform1f of this block whose name is given.
name | a GLSL uniform name. |
Returns the uniform1i of this block whose name is given.
name | a GLSL uniform name. |
ptr< Uniform1ui > ork::UniformBlock::getUniform1ui | ( | const string & | name | ) | [inline] |
Returns the uniform1ui of this block whose name is given.
name | a GLSL uniform name. |
Returns the uniform2b of this block whose name is given.
name | a GLSL uniform name. |
Returns the uniform2d of this block whose name is given.
name | a GLSL uniform name. |
Returns the uniform2f of this block whose name is given.
name | a GLSL uniform name. |
Returns the uniform2i of this block whose name is given.
name | a GLSL uniform name. |
ptr< Uniform2ui > ork::UniformBlock::getUniform2ui | ( | const string & | name | ) | [inline] |
Returns the uniform2ui of this block whose name is given.
name | a GLSL uniform name. |
Returns the uniform3b of this block whose name is given.
name | a GLSL uniform name. |
Returns the uniform3d of this block whose name is given.
name | a GLSL uniform name. |
Returns the uniform3f of this block whose name is given.
name | a GLSL uniform name. |
Returns the uniform3i of this block whose name is given.
name | a GLSL uniform name. |
ptr< Uniform3ui > ork::UniformBlock::getUniform3ui | ( | const string & | name | ) | [inline] |
Returns the uniform3ui of this block whose name is given.
name | a GLSL uniform name. |
Returns the uniform4b of this block whose name is given.
name | a GLSL uniform name. |
Returns the uniform4d of this block whose name is given.
name | a GLSL uniform name. |
Returns the uniform4f of this block whose name is given.
name | a GLSL uniform name. |
Returns the uniform4i of this block whose name is given.
name | a GLSL uniform name. |
ptr< Uniform4ui > ork::UniformBlock::getUniform4ui | ( | const string & | name | ) | [inline] |
Returns the uniform4ui of this block whose name is given.
name | a GLSL uniform name. |
ptr< UniformMatrix2d > ork::UniformBlock::getUniformMatrix2d | ( | const string & | name | ) | [inline] |
Returns the uniformMatrix2d of this block whose name is given.
name | a GLSL uniform name. |
ptr< UniformMatrix2f > ork::UniformBlock::getUniformMatrix2f | ( | const string & | name | ) | [inline] |
Returns the uniformMatrix2f of this block whose name is given.
name | a GLSL uniform name. |
ptr< UniformMatrix2x3d > ork::UniformBlock::getUniformMatrix2x3d | ( | const string & | name | ) | [inline] |
Returns the uniformMatrix2x3d of this block whose name is given.
name | a GLSL uniform name. |
ptr< UniformMatrix2x3f > ork::UniformBlock::getUniformMatrix2x3f | ( | const string & | name | ) | [inline] |
Returns the uniformMatrix2x3f of this block whose name is given.
name | a GLSL uniform name. |
ptr< UniformMatrix2x4d > ork::UniformBlock::getUniformMatrix2x4d | ( | const string & | name | ) | [inline] |
Returns the uniformMatrix2x4d of this block whose name is given.
name | a GLSL uniform name. |
ptr< UniformMatrix2x4f > ork::UniformBlock::getUniformMatrix2x4f | ( | const string & | name | ) | [inline] |
Returns the uniformMatrix2x4f of this block whose name is given.
name | a GLSL uniform name. |
ptr< UniformMatrix3d > ork::UniformBlock::getUniformMatrix3d | ( | const string & | name | ) | [inline] |
Returns the uniformMatrix3d of this block whose name is given.
name | a GLSL uniform name. |
ptr< UniformMatrix3f > ork::UniformBlock::getUniformMatrix3f | ( | const string & | name | ) | [inline] |
Returns the uniformMatrix3f of this block whose name is given.
name | a GLSL uniform name. |
ptr< UniformMatrix3x2d > ork::UniformBlock::getUniformMatrix3x2d | ( | const string & | name | ) | [inline] |
Returns the uniformMatrix3x2d of this block whose name is given.
name | a GLSL uniform name. |
ptr< UniformMatrix3x2f > ork::UniformBlock::getUniformMatrix3x2f | ( | const string & | name | ) | [inline] |
Returns the uniformMatrix3x2f of this block whose name is given.
name | a GLSL uniform name. |
ptr< UniformMatrix3x4d > ork::UniformBlock::getUniformMatrix3x4d | ( | const string & | name | ) | [inline] |
Returns the uniformMatrix3x4d of this block whose name is given.
name | a GLSL uniform name. |
ptr< UniformMatrix3x4f > ork::UniformBlock::getUniformMatrix3x4f | ( | const string & | name | ) | [inline] |
Returns the uniformMatrix3x4f of this block whose name is given.
name | a GLSL uniform name. |
ptr< UniformMatrix4d > ork::UniformBlock::getUniformMatrix4d | ( | const string & | name | ) | [inline] |
Returns the uniformMatrix4d of this block whose name is given.
name | a GLSL uniform name. |
ptr< UniformMatrix4f > ork::UniformBlock::getUniformMatrix4f | ( | const string & | name | ) | [inline] |
Returns the uniformMatrix4f of this block whose name is given.
name | a GLSL uniform name. |
ptr< UniformMatrix4x2d > ork::UniformBlock::getUniformMatrix4x2d | ( | const string & | name | ) | [inline] |
Returns the uniformMatrix4x2d of this block whose name is given.
name | a GLSL uniform name. |
ptr< UniformMatrix4x2f > ork::UniformBlock::getUniformMatrix4x2f | ( | const string & | name | ) | [inline] |
Returns the uniformMatrix4x2f of this block whose name is given.
name | a GLSL uniform name. |
ptr< UniformMatrix4x3d > ork::UniformBlock::getUniformMatrix4x3d | ( | const string & | name | ) | [inline] |
Returns the uniformMatrix4x2d of this block whose name is given.
name | a GLSL uniform name. |
ptr< UniformMatrix4x3f > ork::UniformBlock::getUniformMatrix4x3f | ( | const string & | name | ) | [inline] |
Returns the uniformMatrix4x3f of this block whose name is given.
name | a GLSL uniform name. |
ptr< UniformSampler > ork::UniformBlock::getUniformSampler | ( | const string & | name | ) | [inline] |
Returns the uniform sampler of this block whose name is given.
name | a GLSL uniform name. |
bool ork::UniformBlock::isMapped | ( | ) | const [protected] |
Returns true if the GPUBuffer associated with this block is currently mapped in client memory.
volatile void* ork::UniformBlock::mapBuffer | ( | GLint | offset | ) | [protected] |
Maps the GPUBuffer associated with this block in client memory.
This method also returns the address in client memory of the value at the given offset in the buffer.
offset | an offset in bytes from the start of the buffer. |
Callback method to create a new buffer.
For use with buffers.
Sets the GPUBuffer to store the values of the uniforms of this block.
buffer | a GPUBuffer. This buffer can be shared between different UniformBlock instances corresponding to the same uniform block declaration. |
void ork::UniformBlock::unmapBuffer | ( | ) | [protected] |
Unmaps the GPUBuffer associated with this block in client memory.
ptr<GPUBuffer> ork::UniformBlock::buffer [protected] |
The GPUBuffer that stores the values of the uniforms of this block.
static_ptr<Factory<string, ptr<GPUBuffer> > > ork::UniformBlock::buffers [static, protected] |
The buffers associated to each uniform blocks.
When creating a new uniform block, the user should check if a buffer was already created for that UB name. Otherwise, he may create a new one.
GLuint ork::UniformBlock::index [protected] |
The index of this uniform block in its program.
string ork::UniformBlock::name [protected] |
The name of this uniform block.
Program* ork::UniformBlock::program [protected] |
The Program to which this uniform block belongs.
GLuint ork::UniformBlock::size [protected] |
The total size of this uniform block's uniforms.
map<string, ptr<Uniform> > ork::UniformBlock::uniforms [protected] |
The uniforms of this block.