Kale
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Private Attributes | List of all members
Kale::OpenGL::Buffer< T > Class Template Reference

#include <Buffer.hpp>

Public Member Functions

void allocBuffer (BufferUsage usage)
 
void updateBuffer ()
 
 Buffer (BufferType type)
 
template<size_t N>
 Buffer (BufferType type, BufferUsage usage, const std::array< T, N > &data)
 
 Buffer (BufferType type, BufferUsage usage, const std::vector< T > &dat)
 
 Buffer (BufferType type, BufferUsage usage, std::vector< T > &&dat)
 
 Buffer (BufferType type, BufferUsage usage, const T *arr, size_t n)
 
 Buffer (const Buffer &other)=delete
 
void operator= (const Buffer &other)=delete
 
 ~Buffer ()
 
size_t size () const
 
const Toperator[] (size_t i) const
 
Toperator[] (size_t i)
 
std::vector< T >::iterator begin ()
 
std::vector< T >::iterator end ()
 
std::vector< T >::const_iterator cbegin () const
 
std::vector< T >::const_iterator cend () const
 
void bind () const
 
template<size_t N>
void modify (size_t i, const std::array< T, N > &val)
 
void modify (size_t i, const std::vector< T > &val)
 
void modify (size_t i, const T *arr, size_t n)
 
void modify (size_t i, T val)
 
void resize (BufferUsage usage, size_t newSize)
 
template<size_t N>
void resize (BufferUsage usage, const std::array< T, N > &arr)
 
void resize (BufferUsage usage, const std::vector< T > &vec)
 
void resize (BufferUsage usage, std::vector< T > &&vec)
 
void resize (BufferUsage usage, const T *arr, size_t n)
 

Public Attributes

std::vector< Tdata
 

Private Attributes

unsigned int buffer
 
BufferType type
 

Detailed Description

template<typename T>
class Kale::OpenGL::Buffer< T >

Represents a block of data on the GPU

Definition at line 52 of file Buffer.hpp.

Constructor & Destructor Documentation

◆ Buffer() [1/6]

template<typename T >
Kale::OpenGL::Buffer< T >::Buffer ( BufferType type)
inline

Creates an empty buffer

Parameters
typeThe type of buffer

Definition at line 93 of file Buffer.hpp.

◆ Buffer() [2/6]

template<typename T >
template<size_t N>
Kale::OpenGL::Buffer< T >::Buffer ( BufferType type,
BufferUsage usage,
const std::array< T, N > & data )
inline

Creates a buffer from an array

Parameters
typeThe type of buffer
usageThe usage of the buffer
dataThe data to create the buffer from

Definition at line 104 of file Buffer.hpp.

◆ Buffer() [3/6]

template<typename T >
Kale::OpenGL::Buffer< T >::Buffer ( BufferType type,
BufferUsage usage,
const std::vector< T > & dat )
inline

Creates a buffer from a vector

Parameters
typeThe type of buffer
usageThe usage of the buffer
datThe data to create the buffer from

Definition at line 116 of file Buffer.hpp.

◆ Buffer() [4/6]

template<typename T >
Kale::OpenGL::Buffer< T >::Buffer ( BufferType type,
BufferUsage usage,
std::vector< T > && dat )
inline

Creates a buffer from a vector

Parameters
typeThe type of buffer
usageThe usage of the buffer
datThe data to create the buffer from

Definition at line 127 of file Buffer.hpp.

◆ Buffer() [5/6]

template<typename T >
Kale::OpenGL::Buffer< T >::Buffer ( BufferType type,
BufferUsage usage,
const T * arr,
size_t n )
inline

Creates a buffer from a C array

Parameters
typeThe type of buffer
usageThe usage of the buffer
arrThe data to create the buffer from
nThe length of the array

Definition at line 139 of file Buffer.hpp.

◆ Buffer() [6/6]

template<typename T >
Kale::OpenGL::Buffer< T >::Buffer ( const Buffer< T > & other)
delete

Buffers do not support copying

◆ ~Buffer()

template<typename T >
Kale::OpenGL::Buffer< T >::~Buffer ( )
inline

Destroys the buffer and frees resources from the GPU

Definition at line 157 of file Buffer.hpp.

Member Function Documentation

◆ allocBuffer()

template<typename T >
void Kale::OpenGL::Buffer< T >::allocBuffer ( BufferUsage usage)
inline

Reallocates the buffer on the GPU to the data within the vector

Parameters
usageThe usage of the buffer

Definition at line 76 of file Buffer.hpp.

◆ begin()

template<typename T >
std::vector< T >::iterator Kale::OpenGL::Buffer< T >::begin ( )
inline

Gets the beginning iterator of the data

Definition at line 189 of file Buffer.hpp.

◆ bind()

template<typename T >
void Kale::OpenGL::Buffer< T >::bind ( ) const
inline

Binds the buffer for use directly with opengl commands

Definition at line 217 of file Buffer.hpp.

◆ cbegin()

template<typename T >
std::vector< T >::const_iterator Kale::OpenGL::Buffer< T >::cbegin ( ) const
inline

Gets the beginning iterator of the data

Definition at line 203 of file Buffer.hpp.

◆ cend()

template<typename T >
std::vector< T >::const_iterator Kale::OpenGL::Buffer< T >::cend ( ) const
inline

Gets the beginning iterator of the data

Definition at line 210 of file Buffer.hpp.

◆ end()

template<typename T >
std::vector< T >::iterator Kale::OpenGL::Buffer< T >::end ( )
inline

Gets the beginning iterator of the data

Definition at line 196 of file Buffer.hpp.

◆ modify() [1/4]

template<typename T >
template<size_t N>
void Kale::OpenGL::Buffer< T >::modify ( size_t i,
const std::array< T, N > & val )
inline

modifies the buffer

Parameters
iThe index to begin modifying at
valThe data to modify and replace with

Definition at line 226 of file Buffer.hpp.

◆ modify() [2/4]

template<typename T >
void Kale::OpenGL::Buffer< T >::modify ( size_t i,
const std::vector< T > & val )
inline

modifies the buffer

Parameters
iThe index to begin modifying at
valThe data to modify and replace with

Definition at line 237 of file Buffer.hpp.

◆ modify() [3/4]

template<typename T >
void Kale::OpenGL::Buffer< T >::modify ( size_t i,
const T * arr,
size_t n )
inline

modifies the buffer

Parameters
iThe index to begin modifying at
arrThe data to modify and replace with
nThe length of the array/val data

Definition at line 249 of file Buffer.hpp.

◆ modify() [4/4]

template<typename T >
void Kale::OpenGL::Buffer< T >::modify ( size_t i,
T val )
inline

Modifies the buffer

Parameters
iThe index to modify
valThe data to replace the existing data at the index with

Definition at line 260 of file Buffer.hpp.

◆ operator=()

template<typename T >
void Kale::OpenGL::Buffer< T >::operator= ( const Buffer< T > & other)
delete

Buffers do not support copying

◆ operator[]() [1/2]

template<typename T >
T & Kale::OpenGL::Buffer< T >::operator[] ( size_t i)
inline

Retrieves the value in the buffer at a certain index

Parameters
iThe index
Returns
The value within the buffer

Definition at line 182 of file Buffer.hpp.

◆ operator[]() [2/2]

template<typename T >
const T & Kale::OpenGL::Buffer< T >::operator[] ( size_t i) const
inline

Retrieves the value in the buffer at a certain index

Parameters
iThe index
Returns
The value within the buffer

Definition at line 173 of file Buffer.hpp.

◆ resize() [1/5]

template<typename T >
template<size_t N>
void Kale::OpenGL::Buffer< T >::resize ( BufferUsage usage,
const std::array< T, N > & arr )
inline

Resizes the buffer to a given array and replaces the data

Parameters
usageThe usage for the buffer
arrthe array to resize to and replace with

Definition at line 281 of file Buffer.hpp.

◆ resize() [2/5]

template<typename T >
void Kale::OpenGL::Buffer< T >::resize ( BufferUsage usage,
const std::vector< T > & vec )
inline

Resizes the buffer to a given vector and replaces the data

Parameters
usageThe usage for the buffer
vecthe vector to resize to and replace with

Definition at line 292 of file Buffer.hpp.

◆ resize() [3/5]

template<typename T >
void Kale::OpenGL::Buffer< T >::resize ( BufferUsage usage,
const T * arr,
size_t n )
inline

Resizes the buffer to a given c array and replaces the data

Parameters
usageThe usage for the buffer
arrthe c array to resize to and replace with
nThe length of the c array

Definition at line 313 of file Buffer.hpp.

◆ resize() [4/5]

template<typename T >
void Kale::OpenGL::Buffer< T >::resize ( BufferUsage usage,
size_t newSize )
inline

Resizes the buffer to a given new size

Parameters
usageThe usage for the buffer
newSizethe new size of the buffer

Definition at line 271 of file Buffer.hpp.

◆ resize() [5/5]

template<typename T >
void Kale::OpenGL::Buffer< T >::resize ( BufferUsage usage,
std::vector< T > && vec )
inline

Resizes the buffer to a given vector and replaces the data

Parameters
usageThe usage for the buffer
vecthe vector to resize to and replace with

Definition at line 302 of file Buffer.hpp.

◆ size()

template<typename T >
size_t Kale::OpenGL::Buffer< T >::size ( ) const
inline

Returns the length of the data

Definition at line 164 of file Buffer.hpp.

◆ updateBuffer()

template<typename T >
void Kale::OpenGL::Buffer< T >::updateBuffer ( )
inline

Updates the buffer on the GPU to the data within the vector, if the vector has been resized this will crash.

Definition at line 84 of file Buffer.hpp.

Member Data Documentation

◆ buffer

template<typename T >
unsigned int Kale::OpenGL::Buffer< T >::buffer
private

The location of the buffer for opengl accessing

Definition at line 58 of file Buffer.hpp.

◆ data

template<typename T >
std::vector<T> Kale::OpenGL::Buffer< T >::data

The data this buffer holds

Definition at line 70 of file Buffer.hpp.

◆ type

template<typename T >
BufferType Kale::OpenGL::Buffer< T >::type
private

The type of buffer this is

Definition at line 63 of file Buffer.hpp.


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