template<class T = float>
buffer_t class
class for creating and managing buffers in OpenGL
buffer_
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(buffer_ target_ t target,
const T* data,
size_t size,
buffer_ usage_ t usage)
constructor for buffer_
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_
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>
buffer_ target_ t glpp:: core:: object:: buffer_t<T>:: target() const
returns the buffer target of the underlying OpenGL buffer.
Returns | buffer target |
---|