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/CpuMesh.hpp | |
parent | afcac59c7d04f4337d6b04ebed8cac7e871ccc50 (diff) |
Changeset: 8 Initial work on sprites and texture system
Diffstat (limited to 'source/CpuMesh.hpp')
-rw-r--r-- | source/CpuMesh.hpp | 53 |
1 files changed, 38 insertions, 15 deletions
diff --git a/source/CpuMesh.hpp b/source/CpuMesh.hpp index 7c6e2c8..9fcb00c 100644 --- a/source/CpuMesh.hpp +++ b/source/CpuMesh.hpp @@ -1,28 +1,51 @@ #pragma once +#include "Color.hpp" #include "Mesh.hpp" +#include "PodVector.hpp" #include "RcPtr.hpp" #include <cstddef> +#include <cstdint> +#include <glm/glm.hpp> #include <memory> -class CpuMesh : public RefCounted { +struct StandardVertex { + float x, y, z; + float u, v; + uint8_t r, g, b, a; +}; + +struct StandardVertexExtra { + float u, v; + uint8_t r, g, b, a; +}; + +class StandardCpuMeshData { +public: + PodVector<glm::vec3> vertPositions; + PodVector<StandardVertexExtra> vertExtra; + PodVector<uint32_t> index; + size_t vertexCount; + size_t triangleCount; +}; + +class StandardCpuMesh { private: - std::unique_ptr<std::byte[]> mVertexData; - std::unique_ptr<std::byte[]> mIndexData; - RcPtr<GpuMesh> mGpuMesh; - RcPtr<VertexFormat> mVertexFormat; - Tags::IndexType mIndexType; - int mVertexByteCount; - int mIndexCount; + StandardCpuMeshData* mData = nullptr; + RcPtr<GpuMesh> mGpuMesh; public: - bool IsEmpty() const; - std::byte* GetVertices() const; - int GetVertexNumBytes() const; - std::byte* GetIndices() const; - int GetIndexNumBytes() const; + StandardCpuMesh(); + ~StandardCpuMesh(); + + GpuVertexBuffer* GetPosBuffer() const; + GpuVertexBuffer* GetExtraBuffer() const; + GpuMesh* GetGpuMesh() const { return mGpuMesh.Get(); } - GpuMesh* SyncToGpuCreate() const; - void SyncToGpu(GpuMesh& mesh) const; + void CreateCpuData(); + bool UpdatePositions(glm::vec3* pos, size_t count, size_t startVertIndex); + bool UpdateColors(RgbaColor* color, size_t count, size_t starVertIndex); + bool UpdateNormals(glm::vec2* normals, size_t count, size_t startVertIndex); + bool UpdateIndices(uint32_t* indices, size_t count, size_t startVertIndex); }; |