template<class T = float>
glpp::core::object::buffer_t class

class for creating and managing buffers in OpenGL

buffer_t is a storage class for OpenGL buffers, that creates, owns and manages buffer objects.

Constructors, destructors, conversion operators

buffer_t()
Default constructor of buffer_t.
buffer_t(const buffer_t& cpy) deleted
buffer_t is non copyable.
buffer_t(buffer_t&& mov) defaulted noexcept
move constructor Constructs a buffer_t object using contents of mov. After move the mov object is in an invalid state. All access other then destruction and reassignment will be undefined behaviour.
buffer_t(buffer_target_t target, const T* data, size_t size, buffer_usage_t usage)
constructor for buffer_t

Public functions

void bind() const
bind buffer Bind buffer to active vertex array object in the OpenGL state machiene.
auto operator=(const buffer_t& cpy) -> buffer_t& deleted
buffer_t is non copyable.
auto operator=(buffer_t&& mov) -> buffer_t& defaulted noexcept
move assignment Assign a buffer_t object using contents of mov. After move the mov object is in an invalid state. All access other then destruction and reassignment will be undefined behaviour.
auto read() const -> std::vector<T>
Read values from the buffer Get the values saved in the buffer from the GPU back to CPU memory.
void read(T* data) const
Read values from the buffer Get the values saved in the buffer from the GPU back to CPU memory.
auto size() const -> size_t
Number of elements in buffer.
auto target() const -> buffer_target_t
returns the buffer target of the underlying OpenGL buffer.

Function documentation

template<class T>
glpp::core::object::buffer_t<T>::buffer_t()

Default constructor of buffer_t.

The default constructor will allocate an empty buffer in the OpenGL state machine for later use.

template<class T>
glpp::core::object::buffer_t<T>::buffer_t(buffer_target_t target, const T* data, size_t size, buffer_usage_t usage)

constructor for buffer_t

Parameters
target [in] target type of the buffer
data [in] pointer to buffer holding data, that should be sent to the gpu.
size [in] size of data that should be sent to the gpu in bytes
usage [in] usage hint for performance optimization by the gpu driver

This constructor will create a buffer object, set its properties and copies the data from cpu memory to gpu memory.

template<class T>
buffer_t& glpp::core::object::buffer_t<T>::operator=(buffer_t&& mov) defaulted noexcept

move assignment Assign a buffer_t object using contents of mov. After move the mov object is in an invalid state. All access other then destruction and reassignment will be undefined behaviour.

Returns Reference to itself.

template<class T>
std::vector<T> glpp::core::object::buffer_t<T>::read() const

Read values from the buffer Get the values saved in the buffer from the GPU back to CPU memory.

Returns std::vector<T> of values

template<class T>
void glpp::core::object::buffer_t<T>::read(T* data) const

Read values from the buffer Get the values saved in the buffer from the GPU back to CPU memory.

Parameters
data out location where the values are copied to. The provided memory location must be at least size() elements long.

template<class T>
size_t glpp::core::object::buffer_t<T>::size() const

Number of elements in buffer.

Returns Number of elements saved in buffer.

template<class T>
buffer_target_t glpp::core::object::buffer_t<T>::target() const

returns the buffer target of the underlying OpenGL buffer.

Returns buffer target