From 5424a1d5434e3ddd911a504719918c2df027e2fd Mon Sep 17 00:00:00 2001 From: rtk0c Date: Sun, 17 Apr 2022 20:08:57 -0700 Subject: Changeset: 8 Initial work on sprites and texture system --- source/Mesh.hpp | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'source/Mesh.hpp') diff --git a/source/Mesh.hpp b/source/Mesh.hpp index a1c0984..bc755a3 100644 --- a/source/Mesh.hpp +++ b/source/Mesh.hpp @@ -31,7 +31,7 @@ struct GpuIndexBuffer : public RefCounted { void Upload(const std::byte* data, Tags::IndexType type, size_t count); }; -struct BufferBindings : public RefCounted { +struct BufferBindings { SmallVector, 4> bindings; int GetMaxBindingIndex() const; @@ -44,14 +44,15 @@ struct BufferBindings : public RefCounted { }; struct VertexElementFormat { - int offset; - int bindingIndex; - Tags::VertexElementType type; - Tags::VertexElementSemantic semantic; + /// NOTE: + /// "Automatic" means it will be set inside VertexFormat::AddElement() + /// "Parameter" means it must be set by the user + /* Automatic */ int offset; + /* Parameter */ int bindingIndex; + /* Parameter */ Tags::VertexElementType type; + /* Parameter */ Tags::VertexElementSemantic semantic; int GetStride() const; - - auto operator<=>(const VertexElementFormat&) const = default; }; struct VertexFormat : public RefCounted { @@ -61,24 +62,22 @@ struct VertexFormat : public RefCounted { const std::vector& GetElements() { return elements; } void AddElement(VertexElementFormat element); void RemoveElement(int index); - - void Sort(); - void CompactBindingIndex(); }; +// Initialized in main() +inline RcPtr gVformatStandard{}; +inline RcPtr gVformatStandardPacked{}; + +// TODO handle immutability class GpuMesh : public RefCounted { public: RcPtr vertFormat; - RcPtr vertBufBindings; + BufferBindings vertBufBindings; RcPtr indexBuf; public: - GpuMesh(VertexFormat* vertexFormat, BufferBindings* bindings, GpuIndexBuffer* indexBuffer); + GpuMesh(); + ~GpuMesh(); bool IsEmpty() const; - void SetVertex(VertexFormat* vertexFormat, BufferBindings* bindings); - VertexFormat* GetVertexFormat() const; - BufferBindings* GetVertexBufferBindings() const; - void SetIndex(GpuIndexBuffer* buffer); - GpuIndexBuffer* GetIndexBuffer() const; }; -- cgit v1.2.3-70-g09d2