diff options
author | rtk0c <[email protected]> | 2022-04-17 20:08:57 -0700 |
---|---|---|
committer | rtk0c <[email protected]> | 2022-04-17 20:08:57 -0700 |
commit | 5424a1d5434e3ddd911a504719918c2df027e2fd (patch) | |
tree | 6275aab13140d81dcc46c8290e73ac9a8bbb5605 /source/Mesh.hpp | |
parent | afcac59c7d04f4337d6b04ebed8cac7e871ccc50 (diff) |
Changeset: 8 Initial work on sprites and texture system
Diffstat (limited to 'source/Mesh.hpp')
-rw-r--r-- | source/Mesh.hpp | 33 |
1 files changed, 16 insertions, 17 deletions
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<RcPtr<GpuVertexBuffer>, 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<VertexElementFormat>& GetElements() { return elements; } void AddElement(VertexElementFormat element); void RemoveElement(int index); - - void Sort(); - void CompactBindingIndex(); }; +// Initialized in main() +inline RcPtr<VertexFormat> gVformatStandard{}; +inline RcPtr<VertexFormat> gVformatStandardPacked{}; + +// TODO handle immutability class GpuMesh : public RefCounted { public: RcPtr<VertexFormat> vertFormat; - RcPtr<BufferBindings> vertBufBindings; + BufferBindings vertBufBindings; RcPtr<GpuIndexBuffer> 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; }; |