Ember
A C++ 20 'game engine' built with SDL3 with wide platform support.
mesh.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "helpers/logging.h"
4 
9 struct Vertex {
10  glm::vec3 Position;
11  glm::vec4 Color;
12  glm::vec2 UV;
13  float TextureIndex;
14 };
15 
23 class Mesh {
24 public:
25  Mesh();
26 
27  explicit Mesh(const std::vector<Vertex>& vertices, const std::vector<Uint32>& indices = {});
28 
29  ~Mesh();
30 
31  void Bind() const;
32 
33  void Draw(unsigned int mode = GL_TRIANGLES) const;
34 
35  void Update(const std::vector<Vertex>& new_vertices, const std::vector<Uint32>& new_indices = {});
36 
37  size_t GetVertexCount() const;
38 
39 private:
40  unsigned int VAO, VBO, EBO;
41  std::vector<Vertex> vertices;
42  std::vector<Uint32> indices;
43 
44  void Setup();
45 
46  bool bIsDirty = false;
47 };
48 
Mesh class.
Definition: mesh.h:23
void Update(const std::vector< Vertex > &new_vertices, const std::vector< Uint32 > &new_indices={})
Definition: mesh.cpp:49
Mesh()
Definition: mesh.cpp:3
size_t GetVertexCount() const
Definition: mesh.cpp:33
~Mesh()
Definition: mesh.cpp:21
void Draw(unsigned int mode=GL_TRIANGLES) const
Definition: mesh.cpp:37
void Bind() const
Definition: mesh.cpp:29
Vertex struct.
Definition: mesh.h:9
glm::vec2 UV
Definition: mesh.h:12
glm::vec4 Color
Definition: mesh.h:11
float TextureIndex
Definition: mesh.h:13
glm::vec3 Position
Definition: mesh.h:10