CUGL 4.0
Cornell University Game Library
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
cugl::graphics::UniformBuffer Class Reference

#include <CUUniformBuffer.h>

Public Member Functions

 UniformBuffer ()
 
 ~UniformBuffer ()
 
void dispose ()
 
bool init (size_t capacity, bool stream=true)
 
bool init (size_t capacity, Uint32 blocks, bool stream=true)
 
BufferData * getImplementation ()
 
void setName (std::string name)
 
const std::string getName () const
 
bool isStream () const
 
Uint32 getBlockCount () const
 
size_t getBlockSize () const
 
size_t getBlockStride () const
 
void setOffset (const std::string name, size_t offset)
 
size_t getOffset (const std::string name) const
 
std::vector< std::string > getOffsets () const
 
size_t loadData (const std::byte *data, size_t amt)
 
template<typename T >
bool loadData (const T &data)
 
size_t loadBlock (Uint32 block, const std::byte *data, size_t amt)
 
template<typename T >
bool loadBlock (Uint32 block, const T &data)
 
void flush ()
 
void pushInt (Sint64 block, const std::string name, Sint32 value)
 
void pushInt (Sint64 block, size_t offset, Sint32 value)
 
void pushUInt (Sint64 block, const std::string name, Uint32 value)
 
void pushUInt (Sint64 block, size_t offset, Uint32 value)
 
void pushFloat (Sint64 block, const std::string name, float value)
 
void pushFloat (Sint64 block, size_t offset, float value)
 
void pushVec2 (Sint64 block, const std::string name, const Vec2 &vec)
 
void pushVec2 (Sint64 block, size_t offset, const Vec2 &vec)
 
void pushVec2 (Sint64 block, const std::string name, float x, float y)
 
void pushVec2 (Sint64 block, size_t offset, float x, float y)
 
void pushVec3 (Sint64 block, const std::string name, const Vec3 &vec)
 
void pushVec3 (Sint64 block, size_t offset, const Vec3 &vec)
 
void pushVec3 (Sint64 block, const std::string name, float x, float y, float z)
 
void pushVec3 (Sint64 block, size_t offset, float x, float y, float z)
 
void pushVec4 (Sint64 block, const std::string name, const Vec4 &vec)
 
void pushVec4 (Sint64 block, size_t offset, const Vec4 &vec)
 
void pushVec4 (Sint64 block, const std::string name, const Quaternion &quat)
 
void pushVec4 (Sint64 block, size_t offset, const Quaternion &quat)
 
void pushVec4 (Sint64 block, const std::string name, float x, float y, float z, float w)
 
void pushVec4 (Sint64 block, size_t offset, float x, float y, float z, float w)
 
void pushIVec2 (Sint64 block, const std::string name, Sint32 x, Sint32 y)
 
void pushIVec2 (Sint64 block, size_t offset, Sint32 x, Sint32 y)
 
void pushIVec3 (Sint64 block, const std::string name, Sint32 x, Sint32 y, Sint32 z)
 
void pushIVec3 (Sint64 block, size_t offset, Sint32 x, Sint32 y, Sint32 z)
 
void pushIVec4 (Sint64 block, const std::string name, Sint32 x, Sint32 y, Sint32 z, Sint32 w)
 
void pushIVec4 (Sint64 block, size_t offset, Sint32 x, Sint32 y, Sint32 z, Sint32 w)
 
void pushUVec2 (Sint64 block, const std::string name, Uint32 x, Uint32 y)
 
void pushUVec2 (Sint64 block, size_t offset, Uint32 x, Uint32 y)
 
void pushUVec3 (Sint64 block, const std::string name, Uint32 x, Uint32 y, Uint32 z)
 
void pushUVec3 (Sint64 block, size_t offset, Uint32 x, Uint32 y, Uint32 z)
 
void pushUVec4 (Sint64 block, const std::string name, Uint32 x, Uint32 y, Uint32 z, Uint32 w)
 
void pushUVec4 (Sint64 block, size_t offset, Uint32 x, Uint32 y, Uint32 z, Uint32 w)
 
void pushColor4f (Sint64 block, const std::string name, const Color4f &color)
 
void pushColor4f (Sint64 block, size_t offset, const Color4f &color)
 
void pushColor4f (Sint64 block, const std::string name, float red, float green, float blue, float alpha)
 
void pushColor4f (Sint64 block, size_t offset, float red, float green, float blue, float alpha)
 
void pushColor4 (Sint64 block, const std::string name, const Color4 color)
 
void pushColor4 (Sint64 block, size_t offset, const Color4 color)
 
void pushColor4 (Sint64 block, const std::string name, Uint8 red, Uint8 green, Uint8 blue, Uint8 alpha)
 
void pushColor4 (Sint64 block, size_t offset, Uint8 red, Uint8 green, Uint8 blue, Uint8 alpha)
 
void pushMat2 (Sint64 block, const std::string name, const Affine2 &mat)
 
void pushMat2 (Sint64 block, size_t offset, const Affine2 &mat)
 
void pushMat2 (Sint64 block, const std::string name, const float *array)
 
void pushMat2 (Sint64 block, size_t offset, const float *array)
 
void pushMat3 (Sint64 block, const std::string name, const Affine2 &mat)
 
void pushMat3 (Sint64 block, size_t offset, const Affine2 &mat)
 
void pushMat3 (Sint64 block, const std::string name, const float *array)
 
void pushMat3 (Sint64 block, size_t offset, const float *array)
 
void pushMat4 (Sint64 block, const std::string name, const Mat4 &mat)
 
void pushMat4 (Sint64 block, size_t offset, const Mat4 &mat)
 
void pushMat4 (Sint64 block, const std::string name, const float *array)
 
void pushMat4 (Sint64 block, size_t offset, const float *array)
 
void pushBytes (Sint64 block, size_t offset, const Uint8 *data, size_t amt)
 

Static Public Member Functions

static std::shared_ptr< UniformBufferalloc (size_t capacity, bool stream=true)
 
static std::shared_ptr< UniformBufferalloc (size_t capacity, Uint32 blocks, bool stream=true)
 

Static Public Attributes

static const size_t INVALID_OFFSET
 

Detailed Description

This class defines a uniform buffer for a GraphicsShader.

Technically, a shader is associated with a uniform block, not a uniform buffer, since a uniform buffer may have multiple blocks. In the case of a uniform buffer with multiple blocks, the current block is managed through the shader (either GraphicsShader or ComputeShader).

Uniform buffers are required for Vulkan. However, CUGL uses them extensively in OpenGL as well. They ideal in two use cases. First of all, they are great for uniforms that are shared across multiple shaders. But it is also worthwhile to have a buffer for a single shader if (1) that shader has a large number of uniforms and (2) those uniforms change semi-frequently through out a render pass. In that case, the uniform buffer should be allocated with enough blocks so that all of the possible uniform values can be assigned at the start of the render pass, each to a different block. Once the shader starts to receive vertices, the uniforms should be managed via the GraphicsShader#setBlock method.

Note that we do not support BufferAccess types in uniform buffers. That is because is makes very little sense to allow compute access to a uniform buffer. Uniform buffers use std140, but any output buffer to a compute shader must use std430. This is conversion is complicated enough that we elected not to support it in CUGL.

Constructor & Destructor Documentation

◆ UniformBuffer()

cugl::graphics::UniformBuffer::UniformBuffer ( )

Creates an uninitialized uniform buffer.

You must initialize the uniform buffer to allocate memory.

◆ ~UniformBuffer()

cugl::graphics::UniformBuffer::~UniformBuffer ( )
inline

Deletes this uniform buffer, disposing all resources.

Member Function Documentation

◆ alloc() [1/2]

static std::shared_ptr< UniformBuffer > cugl::graphics::UniformBuffer::alloc ( size_t  capacity,
bool  stream = true 
)
inlinestatic

Returns a new uniform block to support a block of the given capacity.

This uniform buffer will only support a single block. The block capacity is measured in bytes. In std140 format, all scalars are 4 bytes, vectors are 8 or 16 bytes, and matrices are treated as an array of 8 or 16 byte column vectors.

Typically uniform buffers supports streaming, meaning that their values updated every frame or so. If stream is false, then this buffer can only be set once (typically at the start of the frame), and later calls to either flush or loadData will fail.

Parameters
capacityThe block capacity in bytes
streamWhether data can be streamed to the buffer
Returns
a new uniform block to support a block of the given capacity.

◆ alloc() [2/2]

static std::shared_ptr< UniformBuffer > cugl::graphics::UniformBuffer::alloc ( size_t  capacity,
Uint32  blocks,
bool  stream = true 
)
inlinestatic

Returns a new uniform buffer to support multiple blocks of the given capacity.

The block capacity is measured in bytes. In std140 format, all scalars are 4 bytes, vectors are 8 or 16 bytes, and matrices are treated as an array of 8 or 16 byte column vectors.

Keep in mind that uniform buffer blocks must be aligned, and so this may take significantly more memory than the number of blocks times the capacity. If the graphics card cannot support that many blocks, this method will return false.

Typically uniform buffers supports streaming, meaning that their values updated every frame or so. If stream is false, then this buffer can only be set once (typically at the start of the frame), and later calls to either flush or loadData will fail.

Parameters
capacityThe block capacity in bytes
blocksThe number of blocks to support
streamWhether data can be streamed to the buffer
Returns
a new uniform buffer to support multiple blocks of the given capacity.

◆ dispose()

void cugl::graphics::UniformBuffer::dispose ( )

Deletes the uniform buffer, freeing all resources.

You must reinitialize the uniform buffer to use it.

◆ flush()

void cugl::graphics::UniformBuffer::flush ( )

Flushes any changes to the graphics card.

For any method other than loadData, changes to this uniform buffer are only applied to a backing buffer in CPU memory, and are not reflected on the graphics card. This method synchronizes these two memory regions.

◆ getBlockCount()

Uint32 cugl::graphics::UniformBuffer::getBlockCount ( ) const
inline

Returns the number of blocks supported by this buffer.

A uniform buffer can support multiple uniform blocks at once.

Returns
the number of blocks supported by this buffer.

◆ getBlockSize()

size_t cugl::graphics::UniformBuffer::getBlockSize ( ) const
inline

Returns the capacity of a single block in this uniform buffer.

The block size is the amount of data necessary to populate the uniforms for a single block. It is measured in bytes.

Returns
the capacity of a single block in this uniform buffer.

◆ getBlockStride()

size_t cugl::graphics::UniformBuffer::getBlockStride ( ) const
inline

Returns the stride of a single block in this uniform buffer.

The stride measures the alignment (in bytes) of a block. It is at least as large as the block capacity, but may be more.

Returns
the stride of a single block in this uniform buffer.

◆ getImplementation()

BufferData * cugl::graphics::UniformBuffer::getImplementation ( )
inline

Returns the platform-specific implementation for this buffer

The value returned is an opaque type encapsulating the information for either OpenGL or Vulkan.

Returns
the platform-specific implementation for this buffer

◆ getName()

const std::string cugl::graphics::UniformBuffer::getName ( ) const
inline

Returns the name of this uniform buffer.

A name is a user-defined way of identifying a buffer. It is typically the appropriate shader variable name, but this is not necessary for it to function properly.

Returns
the name of this uniform buffer.

◆ getOffset()

size_t cugl::graphics::UniformBuffer::getOffset ( const std::string  name) const

Returns the byte offset for the given name.

This method requires that name be previously associated with an offset via setOffset. If it has not been associated with an offset, then this method will return INVALID_OFFSET instead.

Parameters
nameThe variable name to query for an offset
Returns
the byte offset of the given struct variable.

◆ getOffsets()

std::vector< std::string > cugl::graphics::UniformBuffer::getOffsets ( ) const

Returns the offsets defined for this buffer

The vector returned will include the name of every variable set by the method setOffset.

Returns
the offsets defined for this buffer

◆ init() [1/2]

bool cugl::graphics::UniformBuffer::init ( size_t  capacity,
bool  stream = true 
)
inline

Initializes this uniform buffer to support a block of the given capacity.

This uniform buffer will only support a single block. The block capacity is measured in bytes. In std140 format, all scalars are 4 bytes, vectors are 8 or 16 bytes, and matrices are treated as an array of 8 or 16 byte column vectors.

Typically uniform buffers supports streaming, meaning that their values updated every frame or so. If stream is false, then this buffer can only be set once (typically at the start of the frame), and later calls to either flush or loadData will fail.

Parameters
capacityThe block capacity in bytes
streamWhether data can be streamed to the buffer
Returns
true if initialization was successful.

◆ init() [2/2]

bool cugl::graphics::UniformBuffer::init ( size_t  capacity,
Uint32  blocks,
bool  stream = true 
)

Initializes this uniform buffer to support multiple blocks of the given capacity.

The block capacity is measured in bytes. In std140 format, all scalars are 4 bytes, vectors are 8 or 16 bytes, and matrices are treated as an array of 8 or 16 byte column vectors.

Keep in mind that uniform buffer blocks must be aligned, and so this may take significantly more memory than the number of blocks times the capacity. If the graphics card cannot support that many blocks, this method will return false.

Typically uniform buffers supports streaming, meaning that their values updated every frame or so. If stream is false, then this buffer can only be set once (typically at the start of the frame), and later calls to either flush or loadData will fail.

Parameters
capacityThe block capacity in bytes
blocksThe number of blocks to support
streamWhether data can be streamed to the buffer
Returns
true if initialization was successful.

◆ isStream()

bool cugl::graphics::UniformBuffer::isStream ( ) const
inline

Returns true if this buffer supports streaming.

A non-streaming buffer will only support one call to loadData and no calls to flush. The assumption is that the contents of the buffer are loaded once and remain unchanged for the duration of the buffer.

Returns
true if this buffer supports streaming.

◆ loadBlock() [1/2]

size_t cugl::graphics::UniformBuffer::loadBlock ( Uint32  block,
const std::byte *  data,
size_t  amt 
)

Loads the given data into the specified block

The value amt must be less than or equal to the size of block. Calling this method will update the CPU memory, but not update it on the GPU. You must call flush to synchronize the buffer.

If there is more than one block, this method will fail on any uniform buffer that is not streaming. If there is only one block, this method can only be called once on non-streaming buffers.

Parameters
blockThe block to update
dataThe data to load
amtThe data size in bytes
Returns
the number of bytes loaded

◆ loadBlock() [2/2]

template<typename T >
bool cugl::graphics::UniformBuffer::loadBlock ( Uint32  block,
const T data 
)
inline

Loads the given data into the specified block

The type T should be the natural data sizee of the block. Calling this method will update the CPU memory, but not update it on the GPU. You must call flush to synchronize the buffer.

If there is more than one block, this method will fail on any uniform buffer that is not streaming. If there is only one block, this method can only be called once on non-streaming buffers.

Parameters
blockThe block to update
dataThe data to load
Returns
true if the data was successfully loaded

◆ loadData() [1/2]

size_t cugl::graphics::UniformBuffer::loadData ( const std::byte *  data,
size_t  amt 
)

Loads the given data in to this buffer

This will load memory into the entire buffer, potentially across multiple blocks. It will call flush when done, committing the changes to the graphics card. If there is more than one block, this method is the only method that can be called for a non-streaming uniform buffer. And in that case, it can only be called once.

Note that if this buffer spans more than one block, each block must align with getBlockSize.

Parameters
dataThe data to load
amtThe data size in bytes
Returns
the number of bytes loaded

◆ loadData() [2/2]

template<typename T >
bool cugl::graphics::UniformBuffer::loadData ( const T data)
inline

Loads the given data in to this buffer

This will load the data structure into the uniform buffer. It will call flush when done, committing the changes to the graphics card.

This method is designed for uniform buffers with a single block. It allows the user to specify the block data a structured type. Due to alignment issues, it does not make sense to use this method on a uniform buffer with multiple blocks. Calling this method in that case will fail.

Parameters
dataThe data to load
Returns
true if the data was successfully loaded

◆ pushBytes()

void cugl::graphics::UniformBuffer::pushBytes ( Sint64  block,
size_t  offset,
const Uint8 *  data,
size_t  amt 
)

Pushes the given data to the specified block at the given offset

This method is intended to stream line the push methods, but is not really intended for general us. The value amt must be less than or equal to the size of block minus the offet.

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

This method will fail on any uniform buffer that is not streaming.

Parameters
blockThe block to update
offsetThe block offset in bytes
dataThe data to load
amtThe data size in bytes

◆ pushColor4() [1/4]

void cugl::graphics::UniformBuffer::pushColor4 ( Sint64  block,
const std::string  name,
const Color4  color 
)

Sets the given uniform variable to a color value.

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL ucolor can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
nameThe name of the uniform
colorThe value for the uniform

◆ pushColor4() [2/4]

void cugl::graphics::UniformBuffer::pushColor4 ( Sint64  block,
const std::string  name,
Uint8  red,
Uint8  green,
Uint8  blue,
Uint8  alpha 
)

Sets the given uniform variable to a color value.

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL ucolor can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
nameThe name of the uniform
redThe uniform red value
greenThe uniform green value
blueThe uniform blue value
alphaThe uniform alpha value

◆ pushColor4() [3/4]

void cugl::graphics::UniformBuffer::pushColor4 ( Sint64  block,
size_t  offset,
const Color4  color 
)

Sets the given block offset to a color value.

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL ucolor can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
offsetThe offset within the block
colorThe value for the uniform

◆ pushColor4() [4/4]

void cugl::graphics::UniformBuffer::pushColor4 ( Sint64  block,
size_t  offset,
Uint8  red,
Uint8  green,
Uint8  blue,
Uint8  alpha 
)

Sets the given block offset to a color value.

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL ucolor can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
offsetThe offset within the block
redThe uniform red value
greenThe uniform green value
blueThe uniform blue value
alphaThe uniform alpha value

◆ pushColor4f() [1/4]

void cugl::graphics::UniformBuffer::pushColor4f ( Sint64  block,
const std::string  name,
const Color4f color 
)

Sets the given uniform variable to a color value.

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL color can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
nameThe name of the uniform
colorThe value for the uniform

◆ pushColor4f() [2/4]

void cugl::graphics::UniformBuffer::pushColor4f ( Sint64  block,
const std::string  name,
float  red,
float  green,
float  blue,
float  alpha 
)

Sets the given uniform variable to a color value.

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL color can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
nameThe name of the uniform
redThe uniform red value
greenThe uniform green value
blueThe uniform blue value
alphaThe uniform alpha value

◆ pushColor4f() [3/4]

void cugl::graphics::UniformBuffer::pushColor4f ( Sint64  block,
size_t  offset,
const Color4f color 
)

Sets the given block offset to a color value.

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL color can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
offsetThe offset within the block
colorThe value for the uniform

◆ pushColor4f() [4/4]

void cugl::graphics::UniformBuffer::pushColor4f ( Sint64  block,
size_t  offset,
float  red,
float  green,
float  blue,
float  alpha 
)

Sets the given block offset to a color value.

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL color can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
offsetThe offset within the block
redThe uniform red value
greenThe uniform green value
blueThe uniform blue value
alphaThe uniform alpha value

◆ pushFloat() [1/2]

void cugl::graphics::UniformBuffer::pushFloat ( Sint64  block,
const std::string  name,
float  value 
)

Sets the given uniform variable to a float value.

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL float can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
nameThe name of the uniform
valueThe value for the uniform

◆ pushFloat() [2/2]

void cugl::graphics::UniformBuffer::pushFloat ( Sint64  block,
size_t  offset,
float  value 
)

Sets the given block offset to a float value.

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL float can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
offsetThe offset within the block
valueThe value for the uniform

◆ pushInt() [1/2]

void cugl::graphics::UniformBuffer::pushInt ( Sint64  block,
const std::string  name,
Sint32  value 
)

Sets the given uniform variable to a integer value.

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL int can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
nameThe name of the uniform
valueThe value for the uniform

◆ pushInt() [2/2]

void cugl::graphics::UniformBuffer::pushInt ( Sint64  block,
size_t  offset,
Sint32  value 
)

Sets the given block offset to a integer value.

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL int can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
offsetThe offset within the block
valueThe value for the uniform

◆ pushIVec2() [1/2]

void cugl::graphics::UniformBuffer::pushIVec2 ( Sint64  block,
const std::string  name,
Sint32  x,
Sint32  y 
)

Sets the given uniform variable to the given values

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL ivec2 can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
nameThe name of the uniform
xThe x-value for the vector
yThe x-value for the vector

◆ pushIVec2() [2/2]

void cugl::graphics::UniformBuffer::pushIVec2 ( Sint64  block,
size_t  offset,
Sint32  x,
Sint32  y 
)

Sets the given block offset to the given values

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL ivec2 can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
offsetThe offset within the block
xThe x-value for the vector
yThe x-value for the vector

◆ pushIVec3() [1/2]

void cugl::graphics::UniformBuffer::pushIVec3 ( Sint64  block,
const std::string  name,
Sint32  x,
Sint32  y,
Sint32  z 
)

Sets the given uniform variable to the given values

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL ivec3 can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
nameThe name of the uniform
xThe x-value for the vector
yThe x-value for the vector
zThe z-value for the vector

◆ pushIVec3() [2/2]

void cugl::graphics::UniformBuffer::pushIVec3 ( Sint64  block,
size_t  offset,
Sint32  x,
Sint32  y,
Sint32  z 
)

Sets the given block offset to the given values

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL ivec3 can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
offsetThe offset within the block
xThe x-value for the vector
yThe x-value for the vector
zThe z-value for the vector

◆ pushIVec4() [1/2]

void cugl::graphics::UniformBuffer::pushIVec4 ( Sint64  block,
const std::string  name,
Sint32  x,
Sint32  y,
Sint32  z,
Sint32  w 
)

Sets the given uniform variable to the given values

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL ivec4 can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
nameThe name of the uniform
xThe x-value for the vector
yThe x-value for the vector
zThe z-value for the vector
wThe z-value for the vector

◆ pushIVec4() [2/2]

void cugl::graphics::UniformBuffer::pushIVec4 ( Sint64  block,
size_t  offset,
Sint32  x,
Sint32  y,
Sint32  z,
Sint32  w 
)

Sets the given block offset to the given values

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL ivec4 can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
offsetThe offset within the block
xThe x-value for the vector
yThe x-value for the vector
zThe z-value for the vector
wThe z-value for the vector

◆ pushMat2() [1/4]

void cugl::graphics::UniformBuffer::pushMat2 ( Sint64  block,
const std::string  name,
const Affine2 mat 
)

Sets the given uniform variable to a 2x2 matrix.

The 2x2 matrix will be the non-translational part of the affine transform.

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL mat2 can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
nameThe name of the uniform
matThe value for the uniform

◆ pushMat2() [2/4]

void cugl::graphics::UniformBuffer::pushMat2 ( Sint64  block,
const std::string  name,
const float *  array 
)

Sets the given uniform variable to a 2x2 matrix.

The matrix will be read from the array in column major order (not row major).

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL mat2 can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
nameThe name of the uniform
arrayThe values for the uniform

◆ pushMat2() [3/4]

void cugl::graphics::UniformBuffer::pushMat2 ( Sint64  block,
size_t  offset,
const Affine2 mat 
)

Sets the given block offset to a 2x2 matrix.

The 2x2 matrix will be the non-translational part of the affine transform.

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL mat2 can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
offsetThe offset within the block
matThe value for the uniform

◆ pushMat2() [4/4]

void cugl::graphics::UniformBuffer::pushMat2 ( Sint64  block,
size_t  offset,
const float *  array 
)

Sets the given block offset to a 2x2 matrix.

The matrix will be read from the array in column major order (not row major).

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL mat2 can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
offsetThe offset within the block
arrayThe values for the uniform

◆ pushMat3() [1/4]

void cugl::graphics::UniformBuffer::pushMat3 ( Sint64  block,
const std::string  name,
const Affine2 mat 
)

Sets the given uniform variable to a 3x3 matrix.

The 3x3 matrix will be affine transform in homoegenous coordinates.

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL mat3 can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
nameThe name of the uniform
matThe value for the uniform

◆ pushMat3() [2/4]

void cugl::graphics::UniformBuffer::pushMat3 ( Sint64  block,
const std::string  name,
const float *  array 
)

Sets the given uniform variable to a 3x3 matrix.

The matrix will be read from the array in column major order (not row major).

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL mat3 can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
nameThe name of the uniform
arrayThe values for the uniform

◆ pushMat3() [3/4]

void cugl::graphics::UniformBuffer::pushMat3 ( Sint64  block,
size_t  offset,
const Affine2 mat 
)

Sets the given block offset to a 3x3 matrix.

The 3x3 matrix will be affine transform in homoegenous coordinates.

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL mat3 can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
offsetThe offset within the block
matThe value for the uniform

◆ pushMat3() [4/4]

void cugl::graphics::UniformBuffer::pushMat3 ( Sint64  block,
size_t  offset,
const float *  array 
)

Sets the given block offset to a 3x3 matrix.

The matrix will be read from the array in column major order (not row major).

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL mat3 can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
offsetThe offset within the block
arrayThe values for the uniform

◆ pushMat4() [1/4]

void cugl::graphics::UniformBuffer::pushMat4 ( Sint64  block,
const std::string  name,
const float *  array 
)

Sets the given uniform variable to a 4x4 matrix.

The matrix will be read from the array in column major order (not row major).

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL mat4 can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
nameThe name of the uniform
arrayThe values for the uniform

◆ pushMat4() [2/4]

void cugl::graphics::UniformBuffer::pushMat4 ( Sint64  block,
const std::string  name,
const Mat4 mat 
)

Sets the given uniform variable to a 4x4 matrix

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL mat4 can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
nameThe name of the uniform
matThe value for the uniform

◆ pushMat4() [3/4]

void cugl::graphics::UniformBuffer::pushMat4 ( Sint64  block,
size_t  offset,
const float *  array 
)

Sets the given block offset to a 4x4 matrix.

The matrix will be read from the array in column major order (not row major).

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL mat4 can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
offsetThe offset within the block
arrayThe values for the uniform

◆ pushMat4() [4/4]

void cugl::graphics::UniformBuffer::pushMat4 ( Sint64  block,
size_t  offset,
const Mat4 mat 
)

Sets the given block offset to a 4x4 matrix

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL mat4 can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
offsetThe offset within the block
matThe value for the uniform

◆ pushUInt() [1/2]

void cugl::graphics::UniformBuffer::pushUInt ( Sint64  block,
const std::string  name,
Uint32  value 
)

Sets the given uniform variable to an unsigned integer value.

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL uint can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
nameThe name of the uniform
valueThe value for the uniform

◆ pushUInt() [2/2]

void cugl::graphics::UniformBuffer::pushUInt ( Sint64  block,
size_t  offset,
Uint32  value 
)

Sets the given block offset to an unsigned integer value.

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL uint can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
offsetThe offset within the block
valueThe value for the uniform

◆ pushUVec2() [1/2]

void cugl::graphics::UniformBuffer::pushUVec2 ( Sint64  block,
const std::string  name,
Uint32  x,
Uint32  y 
)

Sets the given uniform variable to the given values

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL uvec2 can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
nameThe name of the uniform
xThe x-value for the vector
yThe x-value for the vector

◆ pushUVec2() [2/2]

void cugl::graphics::UniformBuffer::pushUVec2 ( Sint64  block,
size_t  offset,
Uint32  x,
Uint32  y 
)

Sets the given block offset to the given values

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL uvec2 can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
offsetThe offset within the block
xThe x-value for the vector
yThe x-value for the vector

◆ pushUVec3() [1/2]

void cugl::graphics::UniformBuffer::pushUVec3 ( Sint64  block,
const std::string  name,
Uint32  x,
Uint32  y,
Uint32  z 
)

Sets the given uniform variable to the given values

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL uvec3 can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
nameThe name of the uniform
xThe x-value for the vector
yThe x-value for the vector
zThe z-value for the vector

◆ pushUVec3() [2/2]

void cugl::graphics::UniformBuffer::pushUVec3 ( Sint64  block,
size_t  offset,
Uint32  x,
Uint32  y,
Uint32  z 
)

Sets the given block offset to the given values

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL uvec3 can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
offsetThe offset within the block
xThe x-value for the vector
yThe x-value for the vector
zThe z-value for the vector

◆ pushUVec4() [1/2]

void cugl::graphics::UniformBuffer::pushUVec4 ( Sint64  block,
const std::string  name,
Uint32  x,
Uint32  y,
Uint32  z,
Uint32  w 
)

Sets the given uniform variable to the given values

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL uvec4 can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
nameThe name of the uniform
xThe x-value for the vector
yThe x-value for the vector
zThe z-value for the vector
wThe z-value for the vector

◆ pushUVec4() [2/2]

void cugl::graphics::UniformBuffer::pushUVec4 ( Sint64  block,
size_t  offset,
Uint32  x,
Uint32  y,
Uint32  z,
Uint32  w 
)

Sets the given block offset to the given values

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL uvec4 can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
offsetThe offset within the block
xThe x-value for the vector
yThe x-value for the vector
zThe z-value for the vector
wThe z-value for the vector

◆ pushVec2() [1/4]

void cugl::graphics::UniformBuffer::pushVec2 ( Sint64  block,
const std::string  name,
const Vec2 vec 
)

Sets the given uniform variable to a Vector2 value.

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL vec2 can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
nameThe name of the uniform
vecThe value for the uniform

◆ pushVec2() [2/4]

void cugl::graphics::UniformBuffer::pushVec2 ( Sint64  block,
const std::string  name,
float  x,
float  y 
)

Sets the given uniform variable to the given values

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL vec2 can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
nameThe name of the uniform
xThe x-value for the vector
yThe x-value for the vector

◆ pushVec2() [3/4]

void cugl::graphics::UniformBuffer::pushVec2 ( Sint64  block,
size_t  offset,
const Vec2 vec 
)

Sets the given block offset to a Vector2 value.

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL vec2 can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
offsetThe offset within the block
vecThe value for the uniform

◆ pushVec2() [4/4]

void cugl::graphics::UniformBuffer::pushVec2 ( Sint64  block,
size_t  offset,
float  x,
float  y 
)

Sets the given block offset to the given values

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL vec2 can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
offsetThe offset within the block
xThe x-value for the vector
yThe x-value for the vector

◆ pushVec3() [1/4]

void cugl::graphics::UniformBuffer::pushVec3 ( Sint64  block,
const std::string  name,
const Vec3 vec 
)

Sets the given uniform variable to a Vector3 value.

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL vec3 can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
nameThe name of the uniform
vecThe value for the uniform

◆ pushVec3() [2/4]

void cugl::graphics::UniformBuffer::pushVec3 ( Sint64  block,
const std::string  name,
float  x,
float  y,
float  z 
)

Sets the given uniform variable to the given values

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL vec3 can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
nameThe name of the uniform
xThe x-value for the vector
yThe x-value for the vector
zThe z-value for the vector

◆ pushVec3() [3/4]

void cugl::graphics::UniformBuffer::pushVec3 ( Sint64  block,
size_t  offset,
const Vec3 vec 
)

Sets the given uniform variable to a Vector3 value.

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL vec3 can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
offsetThe offset within the block
vecThe value for the uniform

◆ pushVec3() [4/4]

void cugl::graphics::UniformBuffer::pushVec3 ( Sint64  block,
size_t  offset,
float  x,
float  y,
float  z 
)

Sets the given block offset to the given values

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL vec3 can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
offsetThe offset within the block
xThe x-value for the vector
yThe x-value for the vector
zThe z-value for the vector

◆ pushVec4() [1/6]

void cugl::graphics::UniformBuffer::pushVec4 ( Sint64  block,
const std::string  name,
const Quaternion quat 
)

Sets the given uniform variable to a quaternion.

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL vec4 can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
nameThe name of the uniform
quatThe value for the uniform

◆ pushVec4() [2/6]

void cugl::graphics::UniformBuffer::pushVec4 ( Sint64  block,
const std::string  name,
const Vec4 vec 
)

Sets the given uniform variable to a Vector4 value.

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL vec4 can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
nameThe name of the uniform
vecThe value for the uniform

◆ pushVec4() [3/6]

void cugl::graphics::UniformBuffer::pushVec4 ( Sint64  block,
const std::string  name,
float  x,
float  y,
float  z,
float  w 
)

Sets the given uniform variable to the given values

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL vec4 can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
nameThe name of the uniform
xThe x-value for the vector
yThe x-value for the vector
zThe z-value for the vector
wThe z-value for the vector

◆ pushVec4() [4/6]

void cugl::graphics::UniformBuffer::pushVec4 ( Sint64  block,
size_t  offset,
const Quaternion quat 
)

Sets the given block offset to a quaternion.

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL vec4 can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
offsetThe offset within the block
quatThe value for the uniform

◆ pushVec4() [5/6]

void cugl::graphics::UniformBuffer::pushVec4 ( Sint64  block,
size_t  offset,
const Vec4 vec 
)

Sets the given block offset to a Vector4 value.

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL vec4 can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
offsetThe offset within the block
vecThe value for the uniform

◆ pushVec4() [6/6]

void cugl::graphics::UniformBuffer::pushVec4 ( Sint64  block,
size_t  offset,
float  x,
float  y,
float  z,
float  w 
)

Sets the given uniform to the given values

If block is -1, it sets this value in every block in this uniform buffer. Values set by this method will not be sent to the graphics card until a call to flush.

Unlike shaders, uniform buffers do not check for correctness of their variables. Assigning this value to a variable that is not a GLSL vec4 can corrupt the memory.

This method will fail if the buffer is not streaming.

Parameters
blockThe block in this uniform buffer to access
offsetThe offset within the block
xThe x-value for the vector
yThe x-value for the vector
zThe z-value for the vector
wThe z-value for the vector

◆ setName()

void cugl::graphics::UniformBuffer::setName ( std::string  name)
inline

Sets the name of this uniform buffer.

A name is a user-defined way of identifying a buffer. It is typically the appropriate shader variable name, but this is not necessary for it to function properly.

Parameters
nameThe name of this uniform buffer.

◆ setOffset()

void cugl::graphics::UniformBuffer::setOffset ( const std::string  name,
size_t  offset 
)

Defines the byte offset of the given buffer variable.

It is not necessary to call this method to use the uniform buffer. It is always possible to pass data to the uniform block by specifying the byte offset.The shader uses byte offsets to pull data from the uniform buffer and assign it to the appropriate struct variable.

However, this method makes use of the uniform buffer easier to follow. It explicitly assigns a variable name to a byte offset. This variable name can now be used in place of the byte offset with passing data to this uniform block. It is akin to declaring uniforms and attributes before compiling a GraphicsShader.

This method can be called any time, even while the buffer is in use. It has no affect on the underlying data.

Parameters
nameThe variable name to use for this offset
offsetThe buffer offset in bytes

Member Data Documentation

◆ INVALID_OFFSET

const size_t cugl::graphics::UniformBuffer::INVALID_OFFSET
static

The byte position of an invalid offset


The documentation for this class was generated from the following file: