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
19
namespace
brenta
20
{
21
22
namespace
types
23
{
24
31
struct
vertex
32
{
33
glm::vec3 position;
34
glm::vec3 normal;
35
glm::vec2 tex_coords;
36
};
37
45
struct
texture
46
{
47
unsigned
int
id;
48
std::string type;
49
std::string path;
50
};
51
52
}
// namespace types
53
61
class
mesh
62
{
63
public
:
67
std::vector<types::vertex>
vertices
;
75
std::vector<unsigned int>
indices
;
79
std::vector<types::texture>
textures
;
95
GLint
wrapping
;
105
GLint
filtering_min
;
115
GLint
filtering_mag
;
119
GLboolean
has_mipmap
;
151
GLint
mipmap_min
;
183
GLint
mipmap_mag
;
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
193
private
:
194
195
types::vao
vao;
196
types::buffer
vbo;
197
types::buffer
ebo;
198
void
setup_mesh();
199
};
200
201
struct
mesh::config
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
217
class
mesh::builder
218
{
219
private
:
220
221
mesh::config
conf = mesh::default_config;
222
223
public
:
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
);
228
builder
&
filtering_min
(GLint
filtering_min
);
229
builder
&
filtering_mag
(GLint
filtering_mag
);
230
builder
&
has_mipmap
(GLboolean
has_mipmap
);
231
builder
&
mipmap_min
(GLint
mipmap_min
);
232
builder
&
mipmap_mag
(GLint
mipmap_mag
);
233
234
mesh
build();
235
};
236
237
}
// namespace brenta
brenta::mesh::builder
The Builder class is used to build a Mesh object.
Definition
mesh.hpp:218
brenta::mesh
The Mesh class represents a 3D model.
Definition
mesh.hpp:62
brenta::mesh::textures
std::vector< types::texture > textures
textures of the mesh
Definition
mesh.hpp:79
brenta::mesh::filtering_min
GLint filtering_min
Minifying texture filtering.
Definition
mesh.hpp:105
brenta::mesh::mipmap_mag
GLint mipmap_mag
Type of mipmap magnifying texture filtering.
Definition
mesh.hpp:183
brenta::mesh::wrapping
GLint wrapping
Type of texture wrapping.
Definition
mesh.hpp:95
brenta::mesh::has_mipmap
GLboolean has_mipmap
Should the texture have a mipmap?
Definition
mesh.hpp:119
brenta::mesh::indices
std::vector< unsigned int > indices
indices of the mesh
Definition
mesh.hpp:75
brenta::mesh::vertices
std::vector< types::vertex > vertices
vertices of the mesh
Definition
mesh.hpp:67
brenta::mesh::mipmap_min
GLint mipmap_min
Type of mipmap minifying texture filtering.
Definition
mesh.hpp:151
brenta::mesh::filtering_mag
GLint filtering_mag
Magnifying texture filtering.
Definition
mesh.hpp:115
brenta::types::buffer
Buffer wrapper around OpenGL buffer objects.
Definition
buffer.hpp:30
brenta::types::vao
Vertex Array Object (VAO)
Definition
vao.hpp:23
brenta::mesh::config
Definition
mesh.hpp:202
brenta::types::texture
The Texture struct represents a texture of a 3D model.
Definition
mesh.hpp:46
brenta::types::vertex
The Vertex struct represents a vertex of a 3D model.
Definition
mesh.hpp:32
include
brenta
mesh.hpp
Generated by
1.12.0