Added mesh class (unfinished)

This commit is contained in:
Warwick 2022-02-22 14:42:07 +00:00
parent f42740d8cc
commit 65e7447fe3
No known key found for this signature in database
GPG key ID: A063045576839DB7
2 changed files with 44 additions and 0 deletions

10
src/Mesh.cpp Normal file
View file

@ -0,0 +1,10 @@
#include "Mesh.h"
Mesh::Mesh(std::vector<Vertex> vertices, std::vector<unsigned int> indices,
std::vector<Texture> textures) {
this->vertices = vertices;
this->indices = indices;
this->textures = textures;
setupMesh();
}

34
src/Mesh.h Normal file
View file

@ -0,0 +1,34 @@
#pragma once
#include "Error.h"
#include "ShaderLoader.h"
#include <glm/glm.hpp>
#include <iostream>
#include <vector>
// 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<Vertex> vertices;
std::vector<unsigned int> indices;
std::vector<Texture> textures;
void Draw(ShaderLoader &shader);
Mesh(std::vector<Vertex> vertices, std::vector<unsigned int> indices,
std::vector<Texture> textures);
};