aboutsummaryrefslogtreecommitdiff
path: root/source/Mesh.hpp
diff options
context:
space:
mode:
authorrtk0c <[email protected]>2022-04-25 20:22:07 -0700
committerrtk0c <[email protected]>2022-04-25 20:22:07 -0700
commit855da86feae1a5cc14dc2d486ccf115f484dbc2e (patch)
tree8284c6a6bdfb1a919eb1a22f466f4180a329c7f3 /source/Mesh.hpp
parentd78a55de5003dbb040f1d1c369409e63a2c806d8 (diff)
Changeset: 16 Initial work on rendering sprites to screen
Diffstat (limited to 'source/Mesh.hpp')
-rw-r--r--source/Mesh.hpp98
1 files changed, 30 insertions, 68 deletions
diff --git a/source/Mesh.hpp b/source/Mesh.hpp
index bc755a3..f86fd55 100644
--- a/source/Mesh.hpp
+++ b/source/Mesh.hpp
@@ -1,83 +1,45 @@
#pragma once
-#include "GraphicsTags.hpp"
+#include "Color.hpp"
+#include "VertexIndex.hpp"
+#include "PodVector.hpp"
#include "RcPtr.hpp"
-#include "SmallVector.hpp"
-#include <glad/glad.h>
#include <cstddef>
#include <cstdint>
-#include <vector>
+#include <glm/glm.hpp>
+#include <memory>
-struct GpuVertexBuffer : public RefCounted {
- GLuint handle;
- int sizeInBytes;
-
- GpuVertexBuffer();
- ~GpuVertexBuffer();
-
- void Upload(const std::byte* data, size_t sizeInBytes);
+struct StandardVertexExtra {
+ float u, v;
+ uint8_t r, g, b, a;
};
-struct GpuIndexBuffer : public RefCounted {
- GLuint handle;
- Tags::IndexType indexType;
- int sizeInBytes;
-
- GpuIndexBuffer();
- ~GpuIndexBuffer();
-
- void Upload(const std::byte* data, size_t count);
- void Upload(const std::byte* data, Tags::IndexType type, size_t count);
-};
-
-struct BufferBindings {
- SmallVector<RcPtr<GpuVertexBuffer>, 4> bindings;
-
- int GetMaxBindingIndex() const;
-
- /// Safe. Returns nullptr if the index is not bound to any buffers.
- GpuVertexBuffer* GetBinding(int index) const;
- /// Adds or updates a buffer binding. Setting a binding to nullptr effectively removes the binding.
- void SetBinding(int index, GpuVertexBuffer* buffer);
- void Clear();
-};
-
-struct VertexElementFormat {
- /// 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;
-};
-
-struct VertexFormat : public RefCounted {
- std::vector<VertexElementFormat> elements;
- int vertexSize = 0;
-
- const std::vector<VertexElementFormat>& GetElements() { return elements; }
- void AddElement(VertexElementFormat element);
- void RemoveElement(int index);
+class StandardCpuMeshData {
+public:
+ PodVector<glm::vec3> vertPositions;
+ PodVector<StandardVertexExtra> vertExtra;
+ PodVector<uint32_t> index;
+ size_t vertexCount;
+ size_t triangleCount;
};
-// Initialized in main()
-inline RcPtr<VertexFormat> gVformatStandard{};
-inline RcPtr<VertexFormat> gVformatStandardPacked{};
+class StandardCpuMesh {
+// private:
+// StandardCpuMeshData* mData = nullptr;
+// RcPtr<GpuMesh> mGpuMesh;
-// TODO handle immutability
-class GpuMesh : public RefCounted {
-public:
- RcPtr<VertexFormat> vertFormat;
- BufferBindings vertBufBindings;
- RcPtr<GpuIndexBuffer> indexBuf;
+// public:
+// StandardCpuMesh();
+// ~StandardCpuMesh();
-public:
- GpuMesh();
- ~GpuMesh();
+// GpuVertexBuffer* GetPosBuffer() const;
+// GpuVertexBuffer* GetExtraBuffer() const;
+// GpuMesh* GetGpuMesh() const { return mGpuMesh.Get(); }
- bool IsEmpty() 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);
};