template class glw::UniformBuffer

Overview

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

#include <UniformBuffer.h>

template <typename T>
class UniformBuffer {
public:
    // construction

    UniformBuffer();
    ~UniformBuffer();

    // methods

    uint32_t Size();
    void Resize(const uint32_t size);
    void Reset(const std::vector<T>& data);
    void Bind(uint32_t index);
    void SetData(const std::vector<T>& data, const uint32_t position = 0u);
    void SetData(const T& data, const uint32_t position = 0);
};

Detailed Documentation

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

Construction

UniformBuffer()

Register new buffer to video memory.

~UniformBuffer()

Free buffer from video memory.

Methods

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)

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

void Bind(uint32_t index)

Bind this buffer onto specified shader location.

void 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.

void 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.