forked from GabrielRosenberg/Shader-evaluator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Mesh.h
46 lines (38 loc) · 1.03 KB
/
Mesh.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#pragma once
#include <glm/glm.hpp>
#include <string>
#include <vector>
#include <glad.h>
#include "Shader.h"
struct Vertex {
glm::vec3 position;
glm::vec3 normal;
glm::vec2 texCoords;
};
struct Texture {
unsigned int id;
std::string type;
};
/*
* Basic mesh class based on code from learnopengl.com
*
* */
class Mesh {
public:
// mesh data
std::vector<Vertex> vertices;
std::vector<unsigned int> indices;
std::vector<Texture> textures;
unsigned int VAO;
Mesh(std::vector<Vertex> vertices, std::vector<unsigned int> indices);
//Mesh(std::vector<Vertex> vertices, std::vector<unsigned int> indices, std::vector<Texture> textures);
void loadTexture(const char *path, std::string type);
void draw(Shader &shader, GLenum mode) const;
private:
// render data
unsigned int VBO, EBO;
void setupMesh();
};
// Functions to generate primitive meshes
Mesh generateSphere(float radius, unsigned int rings = 16, unsigned int segments = 32);
Mesh generatePlane(float width = 1);