GLW
Computer Graphics Structures library
glw::UniformBuffer< T > Class Template Reference

Object to store global variables, arrays or structures and manipulate them. Type of elements inside the buffer must be defined as template type. More...

Public Member Functions

 UniformBuffer ()
 Register new buffer to video memory.
 
 ~UniformBuffer ()
 Free buffer from video memory.
 
uint32_t Size ()
 Get number of elements in currently allocated buffer.
 
void Resize (const uint32_t size)
 Allocate new buffer with specified number of elements, copies old buffer data to newly created one.
 
void Reset (const std::vector< T > &data)
 
void Bind (uint32_t index)
 Bind this buffer onto specified shader location.
 
void SetData (const std::vector< T > &data, const uint32_t position=0u)
 
void SetData (const T &data, const uint32_t position=0)
 

Detailed Description

template<typename T>
class glw::UniformBuffer< T >

Object to store global variables, arrays or structures and manipulate them. Type of elements inside the buffer must be defined as template type.

Member Function Documentation

◆ Reset()

template<typename T >
void glw::UniformBuffer< T >::Reset ( const std::vector< T > &  data)

Deletes all previously allocated data, resizes buffer to the size of provided data, and stores defined data inside buffer.

Here is the call graph for this function:

◆ SetData() [1/2]

template<typename T >
void glw::UniformBuffer< T >::SetData ( const std::vector< T > &  data,
const uint32_t  position = 0u 
)

Set array of data elements into the buffer at defined position. Does not change the size of buffer. When data vector should be written outside buffer, outlaying data is ignored.

Here is the caller graph for this function:

◆ SetData() [2/2]

template<typename T >
void glw::UniformBuffer< T >::SetData ( const T &  data,
const uint32_t  position = 0 
)

Set single data element into the buffer at defined position. Does not change the size of buffer. When data should be written outside buffer, writing is ignored.