diff options
author | hnOsmium0001 <[email protected]> | 2022-04-17 20:08:57 -0700 |
---|---|---|
committer | hnOsmium0001 <[email protected]> | 2022-04-17 20:08:57 -0700 |
commit | d43508ba4843801cbbf1f42a27af260d4eef5701 (patch) | |
tree | 39c51368cfe8ec097c08f198877cf07e9ff835ee /source/Mesh.hpp | |
parent | 509201784d6525fc26345e55a56ab81e4a7616b3 (diff) |
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; }; |