Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
esengine::IndexBuffer Class Reference

GPU buffer for index data. More...

#include <Buffer.hpp>

Public Member Functions

 IndexBuffer ()=default
 ~IndexBuffer ()
 IndexBuffer (const IndexBuffer &)=delete
IndexBuffer & operator= (const IndexBuffer &)=delete
 IndexBuffer (IndexBuffer &&other) noexcept
IndexBuffer & operator= (IndexBuffer &&other) noexcept
u32 getCount () const
 Gets the number of indices.
BufferHandle handle () const
 Gets the device buffer handle.
bool is16Bit () const
 Returns true if using 16-bit indices.

Static Public Member Functions

static Unique< IndexBuffer > create (GfxDevice &device, GfxContent content, std::span< const u32 > indices)
 Creates an index buffer from a span of 32-bit indices.
static Unique< IndexBuffer > create (GfxDevice &device, GfxContent content, std::span< const u16 > indices)
 Creates an index buffer from a span of 16-bit indices.
static Unique< IndexBuffer > create (GfxDevice &device, GfxContent content, const std::vector< u32 > &indices)
 Creates an index buffer from a vector of 32-bit indices.
static Unique< IndexBuffer > create (GfxDevice &device, GfxContent content, const std::vector< u16 > &indices)
 Creates an index buffer from a vector of 16-bit indices.
static Unique< IndexBuffer > create (GfxDevice &device, GfxContent content, const u32 *indices, u32 count)
 Creates an index buffer with 32-bit indices from pointer.
static Unique< IndexBuffer > create (GfxDevice &device, GfxContent content, const u16 *indices, u32 count)
 Creates an index buffer with 16-bit indices from pointer.

Detailed Description

GPU buffer for index data.

Wraps a GfxDevice element buffer object. Supports both 16-bit and 32-bit indices.

std::vector<u32> indices = {0, 1, 2, 2, 3, 0};
auto ebo = IndexBuffer::create(device, GfxContent::retained(), std::span(indices));
static constexpr GfxContent retained()
static Unique< IndexBuffer > create(GfxDevice &device, GfxContent content, std::span< const u32 > indices)
Creates an index buffer from a span of 32-bit indices.
Definition Buffer.hpp:353

Definition at line 337 of file Buffer.hpp.

Constructor & Destructor Documentation

◆ IndexBuffer() [1/3]

esengine::IndexBuffer::IndexBuffer ( )
default

◆ ~IndexBuffer()

esengine::IndexBuffer::~IndexBuffer ( )

Definition at line 111 of file Buffer.cpp.

References esengine::Invalid.

◆ IndexBuffer() [2/3]

esengine::IndexBuffer::IndexBuffer ( const IndexBuffer & )
delete

References IndexBuffer().

◆ IndexBuffer() [3/3]

esengine::IndexBuffer::IndexBuffer ( IndexBuffer && other)
noexcept

Definition at line 117 of file Buffer.cpp.

References IndexBuffer(), and esengine::Invalid.

Member Function Documentation

◆ create() [1/6]

Unique< IndexBuffer > esengine::IndexBuffer::create ( GfxDevice & device,
GfxContent content,
const std::vector< u16 > & indices )
inlinestatic

Creates an index buffer from a vector of 16-bit indices.

Definition at line 368 of file Buffer.hpp.

References create().

◆ create() [2/6]

Unique< IndexBuffer > esengine::IndexBuffer::create ( GfxDevice & device,
GfxContent content,
const std::vector< u32 > & indices )
inlinestatic

Creates an index buffer from a vector of 32-bit indices.

Definition at line 363 of file Buffer.hpp.

References create().

◆ create() [3/6]

Unique< IndexBuffer > esengine::IndexBuffer::create ( GfxDevice & device,
GfxContent content,
const u16 * indices,
u32 count )
static

Creates an index buffer with 16-bit indices from pointer.

Use 16-bit indices for better performance when vertex count is under 65536.

Definition at line 148 of file Buffer.cpp.

References esengine::GfxDevice::createBuffer(), esengine::Index, and esengine::makeUnique().

◆ create() [4/6]

Unique< IndexBuffer > esengine::IndexBuffer::create ( GfxDevice & device,
GfxContent content,
const u32 * indices,
u32 count )
static

Creates an index buffer with 32-bit indices from pointer.

Definition at line 138 of file Buffer.cpp.

References esengine::GfxDevice::createBuffer(), esengine::Index, and esengine::makeUnique().

◆ create() [5/6]

Unique< IndexBuffer > esengine::IndexBuffer::create ( GfxDevice & device,
GfxContent content,
std::span< const u16 > indices )
inlinestatic

Creates an index buffer from a span of 16-bit indices.

Definition at line 358 of file Buffer.hpp.

References create().

◆ create() [6/6]

Unique< IndexBuffer > esengine::IndexBuffer::create ( GfxDevice & device,
GfxContent content,
std::span< const u32 > indices )
inlinestatic

◆ getCount()

u32 esengine::IndexBuffer::getCount ( ) const
inline

Gets the number of indices.

Definition at line 387 of file Buffer.hpp.

◆ handle()

BufferHandle esengine::IndexBuffer::handle ( ) const
inline

Gets the device buffer handle.

Definition at line 390 of file Buffer.hpp.

◆ is16Bit()

bool esengine::IndexBuffer::is16Bit ( ) const
inline

Returns true if using 16-bit indices.

Definition at line 393 of file Buffer.hpp.

◆ operator=() [1/2]

IndexBuffer & esengine::IndexBuffer::operator= ( const IndexBuffer & )
delete

References IndexBuffer().

◆ operator=() [2/2]

IndexBuffer & esengine::IndexBuffer::operator= ( IndexBuffer && other)
noexcept

Definition at line 123 of file Buffer.cpp.

References IndexBuffer(), and esengine::Invalid.


The documentation for this class was generated from the following files:
  • /home/runner/work/estella/estella/src/esengine/renderer/rhi/Buffer.hpp
  • /home/runner/work/estella/estella/src/esengine/renderer/rhi/Buffer.cpp