renamed model to mesh

This commit is contained in:
2026-09-08 22:48:59 -07:00
parent c211fffda1
commit 73d2121bc1
8 changed files with 41 additions and 42 deletions
+66
View File
@@ -0,0 +1,66 @@
#pragma once
#include <memory>
#include <vector>
#define GLM_FORCE_RADIANS
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
#include <glm/glm.hpp>
#include "buffer.hpp"
#include "device.hpp"
namespace sophia {
class Mesh {
public:
struct Vertex {
glm::vec2 position{};
glm::vec3 color{};
// glm::vec3 normal{};
// glm::vec2 uv{};
static std::vector<vk::VertexInputBindingDescription>
getBindingDescriptions();
static std::vector<vk::VertexInputAttributeDescription>
getAttributeDescriptions();
// bool operator==(const Vertex& other) const {
// return position == other.position && color == other.color;
// }
};
struct Builder {
std::vector<Vertex> vertices{};
std::vector<uint32_t> indices{};
// void loadModel(const std::string& filepath);
};
Mesh(Device& device, const Mesh::Builder& builder);
~Mesh();
Mesh(const Mesh&) = delete;
Mesh& operator=(const Mesh&) = delete;
// static std::unique_ptr<Mesh> createMeshFromFile(
// Device& device, const std::string& filepath);
void bind(vk::CommandBuffer commandBuffer);
void draw(vk::CommandBuffer commandBuffer);
private:
void createVertexBuffers(const std::vector<Vertex>& vertices);
void createIndexBuffers(const std::vector<u32>& indices);
Device& device;
std::unique_ptr<Buffer> vertexBuffer;
u32 vertexCount;
bool hasIndexBuffer = false;
std::unique_ptr<Buffer> indexBuffer;
u32 indexCount;
};
} // namespace sophia