Kanzi  3.9.9
Kanzi Engine C++ API
kanzi::GPUBuffer Class Reference

#include <kanzi/core.ui/platform/graphics_backend/gl/gpu_buffer.hpp>

Public Types

using NativeHandle = unsigned int
 Backend specific handle type. More...
 
enum  Type { BufferTypeVertex, BufferTypeIndex, BufferTypeInstance }
 

Public Member Functions

NativeHandle getNativeHandle () const
 Gets the underlying native GL handle. More...
 
size_t getSize () const
 Gets the size of the buffer. More...
 
Type getType () const
 Gets the type of the buffer. More...
 
 GPUBuffer ()=default
 Default constructor. More...
 
 GPUBuffer (Renderer &renderer, Type type, size_t size)
 Constructor that initializes as empty and without uploading. More...
 
 GPUBuffer (Renderer &renderer, Type type, ConstByteSpan data)
 Constructor that initializes with data and uploads immediately. More...
 
 GPUBuffer (Renderer &renderer, Type type, size_t size, NativeHandle nativeHandle, bool takeOwnership)
 Constructor that initializes from existing GL handle. More...
 
 GPUBuffer (GPUBuffer &&other)
 Move constructor. More...
 
GPUBufferoperator= (GPUBuffer &&other)
 Move operator. More...
 
void setData (Renderer &renderer, ConstByteSpan data, const bool shrinkToFit)
 Updates all data in the buffer. More...
 
void setSubData (Renderer &renderer, ConstByteSpan data, unsigned int offset)
 Updates a subsection of data in the buffer. More...
 

Static Public Attributes

static constexpr NativeHandle NativeHandleInvalid
 Invalid value to initialize native handles with. More...
 

Friends

void swap (GPUBuffer &lhs, GPUBuffer &rhs)
 Swaps buffer contents with each other. More...
 

Member Typedef Documentation

using kanzi::GPUBuffer::NativeHandle = unsigned int

Backend specific handle type.

For OpenGL that is GLuint (unsigned int).

Since
Kanzi 3.9.6

Member Enumeration Documentation

Enumerator
BufferTypeVertex 
BufferTypeIndex 
BufferTypeInstance 

Constructor & Destructor Documentation

kanzi::GPUBuffer::GPUBuffer ( )
explicitdefault

Default constructor.

kanzi::GPUBuffer::GPUBuffer ( Renderer renderer,
Type  type,
size_t  size 
)
inlineexplicit

Constructor that initializes as empty and without uploading.

Parameters
rendererThe renderer to use.
typeType of buffer: VBO or IBO.
sizeInitial size in bytes.
kanzi::GPUBuffer::GPUBuffer ( Renderer renderer,
Type  type,
ConstByteSpan  data 
)
inlineexplicit

Constructor that initializes with data and uploads immediately.

Parameters
rendererThe renderer to use.
typeType of buffer: VBO or IBO.
dataInitial data to upload.
kanzi::GPUBuffer::GPUBuffer ( Renderer renderer,
Type  type,
size_t  size,
NativeHandle  nativeHandle,
bool  takeOwnership 
)
inlineexplicit

Constructor that initializes from existing GL handle.

Parameters
rendererThe renderer to use.
typeType of buffer: VBO or IBO.
sizeInitial size in bytes.
nativeHandleNative handle.
takeOwnershipWhether to destroy the native handle when GPUBuffer is destroyed.
Since
Kanzi 3.9.6
kanzi::GPUBuffer::GPUBuffer ( GPUBuffer &&  other)
inline

Move constructor.

Parameters
otherSource buffer.

Member Function Documentation

NativeHandle kanzi::GPUBuffer::getNativeHandle ( ) const
inline

Gets the underlying native GL handle.

Returns
The native GL handle of the buffer.
size_t kanzi::GPUBuffer::getSize ( ) const
inline

Gets the size of the buffer.

Returns
Size of the buffer.
Type kanzi::GPUBuffer::getType ( ) const
inline

Gets the type of the buffer.

Returns
Type of the buffer.
void kanzi::GPUBuffer::setSubData ( Renderer renderer,
ConstByteSpan  data,
unsigned int  offset 
)

Updates a subsection of data in the buffer.

Uploads changes immediately.

Parameters
rendererPointer to the renderer being used.
dataThe new data.
offsetOffset in the buffer into which to update the data.
void kanzi::GPUBuffer::setData ( Renderer renderer,
ConstByteSpan  data,
const bool  shrinkToFit 
)

Updates all data in the buffer.

Uploads changes immediately.

Parameters
rendererPointer to the renderer being used.
dataThe new data.
shrinkToFitWhether to allow the buffer to shrink, if the data size is smaller than the buffer size.
GPUBuffer& kanzi::GPUBuffer::operator= ( GPUBuffer &&  other)
inline

Move operator.

Parameters
otherSource buffer.
Returns
This object.

Friends And Related Function Documentation

void swap ( GPUBuffer lhs,
GPUBuffer rhs 
)
friend

Swaps buffer contents with each other.

Parameters
lhsLeft-hand side operand.
rhsRight-hand side operand.

Member Data Documentation

constexpr NativeHandle kanzi::GPUBuffer::NativeHandleInvalid
static

Invalid value to initialize native handles with.

Since
Kanzi 3.9.6

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