summaryrefslogtreecommitdiff
path: root/engine/xe_model.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'engine/xe_model.hpp')
-rw-r--r--engine/xe_model.hpp40
1 files changed, 14 insertions, 26 deletions
diff --git a/engine/xe_model.hpp b/engine/xe_model.hpp
index 2ffe298..09c5913 100644
--- a/engine/xe_model.hpp
+++ b/engine/xe_model.hpp
@@ -11,52 +11,40 @@
namespace xe {
-class XeModel {
+class Model {
public:
- struct Vertex {
- glm::vec3 position;
- glm::vec3 color;
- glm::vec3 normal;
- glm::vec2 uv;
-
- static std::vector<VkVertexInputBindingDescription> getBindingDescriptions();
- static std::vector<VkVertexInputAttributeDescription> getAttributeDescriptions();
-
- bool operator==(const Vertex &other) const {
- return position == other.position && color == other.color && normal == other.normal && uv == other.uv;
- }
- };
-
struct Builder {
- std::vector<Vertex> vertices{};
+ std::vector<float> vertexData{};
+ uint32_t vertexSize;
+
std::vector<uint32_t> indices{};
void loadModel(const std::string &filepath);
};
- XeModel(XeDevice &device, const XeModel::Builder &builder);
- ~XeModel();
+ Model(Device &device, const Model::Builder &builder);
+ ~Model();
- XeModel(const XeModel &) = delete;
- XeModel operator=(const XeModel &) = delete;
+ Model(const Model &) = delete;
+ Model operator=(const Model &) = delete;
- static std::unique_ptr<XeModel> createModelFromFile(XeDevice &device, const std::string &filepath);
+ static std::unique_ptr<Model> createModelFromFile(Device &device, const std::string &filepath);
void bind(VkCommandBuffer commandBuffer);
void draw(VkCommandBuffer commandBuffer);
private:
- void createVertexBuffers(const std::vector<Vertex> &vertices);
- void createIndexBuffers(const std::vector<uint32_t> &indices);
+ void createVertexBuffers(const std::vector<float> &vertexData, uint32_t vertexSize);
+ void createIndexBuffers(const std::vector<uint32_t> &indexData);
- XeDevice &xeDevice;
+ Device &xeDevice;
- std::unique_ptr<XeBuffer> vertexBuffer;
+ std::unique_ptr<Buffer> vertexBuffer;
uint32_t vertexCount;
bool hasIndexBuffer = false;
- std::unique_ptr<XeBuffer> indexBuffer;
+ std::unique_ptr<Buffer> indexBuffer;
uint32_t indexCount;
};