Class VertexBuffer#

Class Documentation#

class VertexBuffer#

Public Functions

VertexBuffer(VertexBuffer&&) noexcept = default#

Move constructor.

VertexBuffer &operator=(VertexBuffer&&) noexcept = default#

Move assignment operator.

consteval VertexBuffer(const VertexBuffer&) noexcept = delete#

Copy constructor.

consteval VertexBuffer &operator=(const VertexBuffer&) noexcept = delete#

Copy assignment operator.

~VertexBuffer() = default#

Destructor.

constexpr const VertexBufferLayout &GetLayout() const noexcept#

Retrieve the vertex buffer layout of this buffer.

Returns:

Vertex buffer layout.

constexpr void SetLayout(const VertexBufferLayout &layout)#

Set the vertex buffer layout to be used by this buffer.

Parameters:

layout – New vertex buffer layout.

u64 GetSize() const noexcept#

Retrieve the total byte size of the buffer.

Returns:

Total buffer byte size.

u32 GetCount() const noexcept#

Retrieve the count of vertex elements inside this buffer.

Returns:

Count of vertex elements.

UpdateFrequency GetUpdateFrequency() const noexcept#

Retrieve the update frequency used by this buffer.

Returns:

Update frequency.

void SetData(std::span<const f32> data, u64 offset = 0)#

Update the buffers vertex data.

Parameters:
  • data – Pointer to the updated data.

  • offset – Byte offset into the currently used vertex data.

void Use(const Window &window = *TRAP::Application::GetWindow()) const#

Use this buffer for rendering on the given window.

Remark

Headless mode: This function is not available in headless mode.

Parameters:

windowWindow to use vertex buffer on. Default: Main Window.

bool IsLoaded() const#

Check whether uploading data to the GPU has finished.

Returns:

True if uploading data to the GPU has finished.

void AwaitLoading() const#

Wait until uploading data to the GPU has finished.

Public Static Functions

static Scope<VertexBuffer> Create(std::span<const f32> vertices, UpdateFrequency updateFrequency)#

Create a new vertex buffer and set its data.

Parameters:
  • vertices – Pointer to the data to upload.

  • updateFrequency – Update frequency for the buffer.

Returns:

New vertex buffer.

static Scope<VertexBuffer> Create(u64 size, UpdateFrequency updateFrequency)#

Create a new vertex buffer and set its size.

Parameters:
  • size – Byte size for the vertex buffer.

  • updateFrequency – Update frequency for the buffer.

Returns:

New vertex buffer.

Protected Functions

VertexBuffer(const TRAP::Ref<TRAP::Graphics::Buffer> &vertexBuffer, API::SyncToken syncToken) noexcept#

Constructor.

Parameters:
  • vertexBuffer – Internal vertex buffer object.

  • syncToken – Synchronization token.