Kanzi  3.9.6
Kanzi Engine 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

◆ NativeHandle

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

◆ Type

Enumerator
BufferTypeVertex 
BufferTypeIndex 
BufferTypeInstance 

Constructor & Destructor Documentation

◆ GPUBuffer() [1/5]

kanzi::GPUBuffer::GPUBuffer ( )
explicitdefault

Default constructor.

◆ GPUBuffer() [2/5]

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.

◆ GPUBuffer() [3/5]

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.

◆ GPUBuffer() [4/5]

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

◆ GPUBuffer() [5/5]

kanzi::GPUBuffer::GPUBuffer ( GPUBuffer &&  other)
inline

Move constructor.

Parameters
otherSource buffer.

Member Function Documentation

◆ getNativeHandle()

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

Gets the underlying native GL handle.

Returns
The native GL handle of the buffer.

◆ getSize()

size_t kanzi::GPUBuffer::getSize ( ) const
inline

Gets the size of the buffer.

Returns
Size of the buffer.

◆ getType()

Type kanzi::GPUBuffer::getType ( ) const
inline

Gets the type of the buffer.

Returns
Type of the buffer.

◆ setSubData()

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.

◆ setData()

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.

◆ operator=()

GPUBuffer& kanzi::GPUBuffer::operator= ( GPUBuffer &&  other)
inline

Move operator.

Parameters
otherSource buffer.
Returns
This object.

Friends And Related Function Documentation

◆ swap

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

◆ NativeHandleInvalid

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: