Brenta Engine 1.2
Loading...
Searching...
No Matches
mesh.hpp
1// SPDX-License-Identifier: MIT
2// Author: Giovanni Santini
3// Mail: giovanni.santini@proton.me
4// Github: @San7o
5
6#pragma once
7
8#include <brenta/buffer.hpp>
9#include <brenta/gl.hpp>
10#include <brenta/shader.hpp>
11#include <brenta/texture.hpp>
12#include <brenta/vao.hpp>
13#include <glm/glm.hpp>
14#include <glm/gtc/matrix_transform.hpp>
15#include <glm/gtc/type_ptr.hpp>
16#include <string>
17#include <vector>
18
19namespace brenta
20{
21
22namespace types
23{
24
31struct vertex
32{
33 glm::vec3 position;
34 glm::vec3 normal;
35 glm::vec2 tex_coords;
36};
37
45struct texture
46{
47 unsigned int id;
48 std::string type;
49 std::string path;
50};
51
52} // namespace types
53
61class mesh
62{
63public:
67 std::vector<types::vertex> vertices;
75 std::vector<unsigned int> indices;
79 std::vector<types::texture> textures;
95 GLint wrapping;
119 GLboolean has_mipmap;
184
185 struct config;
186 class builder;
187 static const config default_config;
188
189 mesh(config conf);
190
191 void draw(types::shader_name_t shader_name);
192
193private:
194
195 types::vao vao;
196 types::buffer vbo;
197 types::buffer ebo;
198 void setup_mesh();
199};
200
202{
203 std::vector<types::vertex> vertices;
204 std::vector<unsigned int> indices;
205 std::vector<types::texture> textures;
206 GLint wrapping;
207 GLint filtering_min;
208 GLint filtering_mag;
209 GLboolean has_mipmap;
210 GLint mipmap_min;
211 GLint mipmap_max;
212};
213
218{
219private:
220
221 mesh::config conf = mesh::default_config;
222
223public:
224 builder &vertices(std::vector<types::vertex> vertices);
225 builder &indices(std::vector<unsigned int> indices);
226 builder &textures(std::vector<types::texture> textures);
227 builder &wrapping(GLint wrapping);
230 builder &has_mipmap(GLboolean has_mipmap);
233
234 mesh build();
235};
236
237} // namespace brenta
The Builder class is used to build a Mesh object.
Definition mesh.hpp:218
The Mesh class represents a 3D model.
Definition mesh.hpp:62
std::vector< types::texture > textures
textures of the mesh
Definition mesh.hpp:79
GLint filtering_min
Minifying texture filtering.
Definition mesh.hpp:105
GLint mipmap_mag
Type of mipmap magnifying texture filtering.
Definition mesh.hpp:183
GLint wrapping
Type of texture wrapping.
Definition mesh.hpp:95
GLboolean has_mipmap
Should the texture have a mipmap?
Definition mesh.hpp:119
std::vector< unsigned int > indices
indices of the mesh
Definition mesh.hpp:75
std::vector< types::vertex > vertices
vertices of the mesh
Definition mesh.hpp:67
GLint mipmap_min
Type of mipmap minifying texture filtering.
Definition mesh.hpp:151
GLint filtering_mag
Magnifying texture filtering.
Definition mesh.hpp:115
Buffer wrapper around OpenGL buffer objects.
Definition buffer.hpp:30
Vertex Array Object (VAO)
Definition vao.hpp:23
The Texture struct represents a texture of a 3D model.
Definition mesh.hpp:46
The Vertex struct represents a vertex of a 3D model.
Definition mesh.hpp:32