Kanzi Framework  3.9.0
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
 Get the underlying native GL name. More...
 
size_t getSize () const
 Get the size of the buffer. More...
 
Type getType () const
 Get 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)
 
GPUBufferoperator= (GPUBuffer &&other)
 
void setData (Renderer &renderer, ConstByteSpan data, const bool shrinkToFit)
 Update all data in the buffer. More...
 
void setSubData (Renderer &renderer, ConstByteSpan data, unsigned int offset)
 Update a subsection of data in the buffer. More...
 

Friends

void swap (GPUBuffer &left, GPUBuffer &right)
 

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 
)
inline

Constructor that initializes as empty and without uploading.

Parameters
rendererThe renderer to be used.
typeType of buffer; VBO or IBO
sizeInitial size in bytes.

◆ GPUBuffer() [3/4]

kanzi::GPUBuffer::GPUBuffer ( Renderer renderer,
Type  type,
ConstByteSpan  data 
)
inline

Constructor that initializes with data and uploads immediately.

Parameters
rendererThe renderer to be used.
typeType of buffer; VBO or IBO
dataInitial data to upload.

◆ GPUBuffer() [4/4]

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

Member Function Documentation

◆ getNativeHandle()

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

Get the underlying native GL name.

Returns
Buffer's native GL name.

◆ getSize()

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

Get the size of the buffer.

Returns
Size of the buffer.

◆ getType()

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

Get the type of the buffer.

Returns
Type of the buffer.

◆ setSubData()

void kanzi::GPUBuffer::setSubData ( Renderer renderer,
ConstByteSpan  data,
unsigned int  offset 
)

Update a subsection of data in the buffer.

Uploads changes immediately.

Parameters
rendererPointer to the renderer being used.
dataThe new data.
offsetOffset in the buffer to update the data into.

◆ setData()

void kanzi::GPUBuffer::setData ( Renderer renderer,
ConstByteSpan  data,
const bool  shrinkToFit 
)

Update 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

Friends And Related Function Documentation

◆ swap

void swap ( GPUBuffer left,
GPUBuffer right 
)
friend

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