66 lines
1.5 KiB
C++
66 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include <memory>
|
|
#include <sophia/handles.hpp>
|
|
#include <sophia/math.hpp>
|
|
#include <sophia/types.hpp>
|
|
#include <vector>
|
|
|
|
#include "vulkan/buffer.hpp"
|
|
#include "vulkan/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) const;
|
|
void draw(vk::CommandBuffer commandBuffer) const;
|
|
|
|
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
|