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 "../systems/logging_sys.h"
4 
9 struct Vertex {
10  glm::vec2 position;
11  glm::vec2 tex_coord;
12  glm::vec4 color;
13 };
14 
15 
24 class Mesh {
25 public:
26  Mesh();
27 
28  explicit Mesh(const std::vector<Vertex>& vertices, const std::vector<Uint32>& indices = {});
29 
30  ~Mesh();
31 
32  void Bind() const;
33 
34  void Draw(unsigned int mode = GL_TRIANGLES) const;
35 
36  void Update(const std::vector<Vertex>& new_vertices, const std::vector<Uint32>& new_indices = {});
37 
38  size_t GetVertexCount() const;
39 
40 private:
41  unsigned int VAO, VBO, EBO;
42  std::vector<Vertex> vertices;
43  std::vector<Uint32> indices;
44 
45  void Setup();
46 
47  bool bIsDirty = false;
48 };
49 
Mesh class.
Definition: mesh.h:24
void Update(const std::vector< Vertex > &new_vertices, const std::vector< Uint32 > &new_indices={})
Mesh(const std::vector< Vertex > &vertices, const std::vector< Uint32 > &indices={})
size_t GetVertexCount() const
void Draw(unsigned int mode=GL_TRIANGLES) const
void Bind() const
Vertex struct.
Definition: mesh.h:9
glm::vec2 tex_coord
Definition: mesh.h:11
glm::vec2 position
Definition: mesh.h:10
glm::vec4 color
Definition: mesh.h:12