9#include <SDL3/SDL_assert.h>
10#include <entt/entity/registry.hpp>
11#include <entt/entity/handle.hpp>
24 MeshView() noexcept = default;
44 MeshView(
const MeshView &parent, Uint32 subVertexOffset,
45 Uint32 vertexSubCount, Uint32 subIndexOffset, Uint32 indexSubCount);
58 SDL_GPUDevice *m_device{
nullptr};
59 std::vector<MeshView> m_views;
92 std::span<const MeshView>
views()
const {
return m_views; }
93 size_t numViews()
const {
return m_views.size(); }
99 Uint32 indexOffset, Uint32 indexSubCount);
147 if (mesh.
views().size() == 0)
This class defines the layout of a mesh's vertices.
Definition MeshLayout.h:98
A view into a Mesh object.
Definition Mesh.h:22
Uint32 indexCount
Number of indices in the mesh view.
Definition Mesh.h:40
MeshView(const MeshView &parent, Uint32 subVertexOffset, Uint32 vertexSubCount, Uint32 subIndexOffset, Uint32 indexSubCount)
Uint32 indexOffset
Index offset (in elements).
Definition Mesh.h:38
std::vector< SDL_GPUBuffer * > vertexBuffers
Vertex buffers.
Definition Mesh.h:28
friend class Mesh
Definition Mesh.h:23
Uint32 vertexOffset
Vertex offsets, expressed in elements.
Definition Mesh.h:33
bool isIndexed() const
Definition Mesh.h:42
Uint32 vertexCount
Number of vertices in the mesh view.
Definition Mesh.h:35
SDL_GPUBuffer * indexBuffer
Index buffer.
Definition Mesh.h:30
Handle class for meshes (vertex buffers and an optional index buffer) on the GPU.
Definition Mesh.h:57
void release() noexcept
Release all owned vertex and index buffers in the Mesh object.
Uint32 indexCount
Definition Mesh.h:64
Uint32 vertexCount
Definition Mesh.h:63
SDL_GPUBufferBinding getIndexBinding() const
Definition Mesh.h:136
bool isIndexed() const
Definition Mesh.h:126
Mesh & bindVertexBuffer(Uint32 slot, SDL_GPUBuffer *buffer)
Bind an existing vertex buffer to a given slot of the Mesh.
size_t numViews() const
Definition Mesh.h:93
const MeshLayout & layout() const
Definition Mesh.h:82
SDL_GPUBuffer * indexBuffer
Definition Mesh.h:78
Uint32 numVertexBuffers() const
Number of vertex buffers.
Definition Mesh.h:122
std::vector< SDL_GPUBuffer * > vertexBuffers
Definition Mesh.h:73
MeshView & addView(Uint32 vertexOffset, Uint32 vertexSubCount, Uint32 indexOffset, Uint32 indexSubCount)
Add a stored MeshView object. The added view will be drawn when calling Renderer::draw() with a Mesh ...
Mesh(const Device &device, const MeshLayout &layout)
std::span< const MeshView > views() const
Definition Mesh.h:92
Mesh & setIndexBuffer(SDL_GPUBuffer *buffer)
Bind an existing index buffer for the Mesh.
SDL_GPUBufferBinding getVertexBinding(Uint32 slot) const
Definition Mesh.h:132
Mesh & operator=(const Mesh &)=delete
Mesh & operator=(Mesh &&other) noexcept
Mesh(Mesh &&other) noexcept
const MeshView & view(size_t i) const
Definition Mesh.h:91
Mesh(const Mesh &)=delete
bool validateMeshView(const MeshView &view)
Validation for a MeshView object.
Definition Mesh.h:164
bool validateMeshLayout(const MeshLayout &layout)
Validation function. Checks if a MeshLayout produces invalid data for a Mesh.
Definition MeshLayout.h:199
bool validateMesh(const Mesh &mesh)
Check that all vertex buffers were set, and consistency in the "indexed/non-indexed" status.
Definition Mesh.h:144
RAII wrapper for SDL_GPUDevice.
Definition Device.h:17
Tag type for non-initializing constructors (for e.g. RAII classes)
Definition Tags.h:6