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
14#include <glm/glm.hpp>
15#include <glm/gtc/matrix_transform.hpp>
16#include <glm/gtc/type_ptr.hpp>
17
18#include <string>
19#include <vector>
20#include <memory>
21
22namespace brenta
23{
24
25namespace types
26{
27
34struct vertex
35{
36 glm::vec3 position;
37 glm::vec3 normal;
38 glm::vec2 tex_coords;
39};
40
41} // namespace types
42
50class mesh
51{
52public:
53
54 std::vector<types::vertex> vertices;
62 std::vector<unsigned int> indices;
63 std::vector<std::shared_ptr<texture>> textures;
79 GLint wrapping;
103 GLboolean has_mipmap;
168
169 struct config;
170 class builder;
171 static const config default_config;
172
173 mesh(config&& conf);
174
175 constexpr mesh(const mesh&) = delete;
176 constexpr mesh& operator=(const mesh&) = delete;
177
178 constexpr mesh(mesh&&) noexcept = default;
179 constexpr mesh& operator=(mesh&&) noexcept = default;
180 ~mesh();
181
182 void draw(shader::name_t shader_name) const;
183
184private:
185
186 types::vao vao;
187 types::buffer vbo;
188 types::buffer ebo;
189
190 void init();
191};
192
194{
195 std::vector<types::vertex> vertices;
196 std::vector<unsigned int> indices;
197 std::vector<std::shared_ptr<texture>> textures;
198 GLint wrapping;
199 GLint filtering_min;
200 GLint filtering_mag;
201 GLboolean has_mipmap;
202 GLint mipmap_min;
203 GLint mipmap_max;
204};
205
210{
211private:
212
213 mesh::config conf = mesh::default_config;
214
215public:
216 builder &vertices(std::vector<types::vertex> vertices);
217 builder &indices(std::vector<unsigned int> indices);
218 builder &textures(std::vector<std::shared_ptr<texture>> textures);
219 builder &wrapping(GLint wrapping);
220 builder &filtering_min(GLint filtering_min);
221 builder &filtering_mag(GLint filtering_mag);
222 builder &has_mipmap(GLboolean has_mipmap);
223 builder &mipmap_min(GLint mipmap_min);
224 builder &mipmap_mag(GLint mipmap_mag);
225
226 mesh build();
227};
228
229} // namespace brenta
The Builder class is used to build a Mesh object.
Definition mesh.hpp:210
The Mesh class represents a 3D model.
Definition mesh.hpp:51
GLint filtering_min
Minifying texture filtering.
Definition mesh.hpp:89
GLint mipmap_mag
Type of mipmap magnifying texture filtering.
Definition mesh.hpp:167
GLint wrapping
Type of texture wrapping.
Definition mesh.hpp:79
GLboolean has_mipmap
Should the texture have a mipmap?
Definition mesh.hpp:103
std::vector< unsigned int > indices
indices of the mesh
Definition mesh.hpp:62
GLint mipmap_min
Type of mipmap minifying texture filtering.
Definition mesh.hpp:135
GLint filtering_mag
Magnifying texture filtering.
Definition mesh.hpp:99
Shader class.
Definition shader.hpp:36
The Vertex struct represents a vertex of a 3D model.
Definition mesh.hpp:35