Kanzi  3.9.4
Kanzi Engine API
kanzi::GPUBuffer Class Reference

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

Public Types

enum  Type { BufferTypeVertex, BufferTypeIndex }
 

Public Member Functions

unsigned int getNativeHandle () const
 Gets the underlying native GL name. 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 (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...
 

Friends

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

Member Enumeration Documentation

◆ Type

Enumerator
BufferTypeVertex 
BufferTypeIndex 

Constructor & Destructor Documentation

◆ GPUBuffer() [1/4]

kanzi::GPUBuffer::GPUBuffer ( )
explicitdefault

Default constructor.

◆ GPUBuffer() [2/4]

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/4]

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/4]

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

Move constructor.

Parameters
otherSource buffer.

Member Function Documentation

◆ getNativeHandle()

unsigned int kanzi::GPUBuffer::getNativeHandle ( ) const
inline

Gets the underlying native GL name.

Returns
The native GL name 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.

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