29#include "engine_logger.hpp"
33using namespace brenta;
36 std::vector<unsigned int> indices,
37 std::vector<types::texture> textures, GLint wrapping,
38 GLint filtering_min, GLint filtering_mag, GLboolean has_mipmap,
39 GLint mipmap_min, GLint mipmap_max)
61 ERROR(
"Mesh not initialized");
65 unsigned int diffuseNr = 1;
66 unsigned int specularNr = 1;
67 for (
unsigned int i = 0; i < this->
textures.size(); i++)
72 if (name ==
"texture_diffuse")
73 number = std::to_string(diffuseNr++);
74 else if (name ==
"texture_specular")
75 number = std::to_string(specularNr++);
92void mesh::setup_mesh()
95 &this->vertices[0], GL_STATIC_DRAW);
97 &this->indices[0], GL_STATIC_DRAW);
110mesh::builder &mesh::builder::set_vertices(std::vector<types::vertex> vertices)
112 this->vertices = vertices;
158mesh mesh::builder::build()
static void draw_elements(GLenum mode, int count, GLenum type, const void *indices)
Draw Elements.
static void bind_vertex_array(unsigned int n)
Enable Depth Test.
The Builder class is used to build a Mesh object.
The Mesh class represents a 3D model.
std::vector< types::texture > textures
textures of the mesh
GLint filtering_min
Minifying texture filtering.
GLint mipmap_mag
Type of mipmap magnifying texture filtering.
void draw(types::shader_name_t shader_name)
Draw the mesh.
GLint wrapping
Type of texture wrapping.
GLboolean has_mipmap
Should the texture have a mipmap?
std::vector< unsigned int > indices
indices of the mesh
std::vector< types::vertex > vertices
vertices of the mesh
GLint mipmap_min
Type of mipmap minifying texture filtering.
GLint filtering_mag
Magnifying texture filtering.
mesh(std::vector< types::vertex > vertices, std::vector< unsigned int > indices, std::vector< types::texture > textures, GLint wrapping=GL_REPEAT, GLint filtering_min=GL_NEAREST, GLint filtering_mag=GL_LINEAR, GLboolean hasMipmap=GL_TRUE, GLint mipmap_min=GL_LINEAR_MIPMAP_LINEAR, GLint mipmap_max=GL_LINEAR)
Construct a new Mesh object.
static void set_int(types::shader_name_t shader_name, const std::string &name, int value)
Set an integer in the shader.
static void active_texture(GLenum texture)
Activate a texture unit.
static void bind_texture(GLenum target, unsigned int texture, GLint wrapping=GL_REPEAT, GLint filtering_min=GL_NEAREST, GLint filtering_mag=GL_NEAREST, GLboolean hasMipmap=GL_TRUE, GLint mipmap_min=GL_LINEAR_MIPMAP_LINEAR, GLint mipmap_mag=GL_LINEAR)
Bind a texture.
Buffer wrapper around OpenGL buffer objects.
void copy_indices(GLsizeiptr size, const void *data, GLenum usage)
Copy data to the buffer object.
void copy_vertices(GLsizeiptr size, const void *data, GLenum usage)
Copy data to the buffer object.
void set_vertex_data(buffer buffer, unsigned int index, GLint size, GLenum type, GLboolean is_normalized, GLsizei stride, const void *pointer)
Set the vertex data.
unsigned int get_vao()
Get the VAO.
void unbind()
Unbind the VAO.
void init()
Init Constructor.
The Vertex struct represents a vertex of a 3D model.