From 65e7447fe3a328b3cdad0f0ce6a7a09476a4ff73 Mon Sep 17 00:00:00 2001 From: Warwick Date: Tue, 22 Feb 2022 14:42:07 +0000 Subject: [PATCH] Added mesh class (unfinished) --- src/Mesh.cpp | 10 ++++++++++ src/Mesh.h | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 src/Mesh.cpp create mode 100644 src/Mesh.h diff --git a/src/Mesh.cpp b/src/Mesh.cpp new file mode 100644 index 0000000..3cdbd6d --- /dev/null +++ b/src/Mesh.cpp @@ -0,0 +1,10 @@ +#include "Mesh.h" + +Mesh::Mesh(std::vector vertices, std::vector indices, + std::vector textures) { + this->vertices = vertices; + this->indices = indices; + this->textures = textures; + + setupMesh(); +} diff --git a/src/Mesh.h b/src/Mesh.h new file mode 100644 index 0000000..57d8d2c --- /dev/null +++ b/src/Mesh.h @@ -0,0 +1,34 @@ +#pragma once +#include "Error.h" +#include "ShaderLoader.h" +#include +#include +#include + +// Define some useful structures to be used in the mesh object +struct Vertex { + glm::vec3 Position; + glm::vec3 Normal; + glm::vec2 TexCoords; +}; +struct Texture { + unsigned int id; + std::string type; +}; + +class Mesh { +private: + Error error = Error("Mesh"); + + unsigned int VAO, VBO, EBO; + void setupMesh(); + +public: + std::vector vertices; + std::vector indices; + std::vector textures; + + void Draw(ShaderLoader &shader); + Mesh(std::vector vertices, std::vector indices, + std::vector textures); +};