6#include <brenta/logger.hpp>
7#include <brenta/mesh.hpp>
10using namespace brenta;
20 GL_LINEAR_MIPMAP_LINEAR,
24mesh::mesh(config conf)
43void mesh::draw(types::shader_name_t shader_name)
47 ERROR(
"mesh::draw: not initialized");
51 unsigned int diffuseNr = 1;
52 unsigned int specularNr = 1;
53 for (
unsigned int i = 0; i < this->
textures.size(); i++)
58 if (name ==
"texture_diffuse")
59 number = std::to_string(diffuseNr++);
60 else if (name ==
"texture_specular")
61 number = std::to_string(specularNr++);
77void mesh::setup_mesh()
80 &this->vertices[0], GL_STATIC_DRAW);
82 &this->indices[0], GL_STATIC_DRAW);
92 gl::bind_vertex_array(0);
99mesh::builder &mesh::builder::vertices(std::vector<types::vertex> vertices)
147mesh mesh::builder::build()
149 return mesh(this->conf);
static void draw_elements(GLenum mode, int count, GLenum type, const void *indices)
Draw Elements.
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.
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.
static bool set_int(types::shader_name_t shader_name, const GLchar *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.