29#include "engine_logger.hpp"
33using namespace Brenta;
34using namespace Brenta::Utils;
37 std::vector<unsigned int> indices,
38 std::vector<Types::Texture> textures, GLint wrapping,
39 GLint filtering_min, GLint filtering_mag, GLboolean hasMipmap,
40 GLint mipmap_min, GLint mipmap_max)
60 if (this->vao.
GetVAO() == 0)
62 ERROR(
"Mesh not initialized");
66 unsigned int diffuseNr = 1;
67 unsigned int specularNr = 1;
68 for (
unsigned int i = 0; i < this->
textures.size(); i++)
73 if (name ==
"texture_diffuse")
74 number = std::to_string(diffuseNr++);
75 else if (name ==
"texture_specular")
76 number = std::to_string(specularNr++);
77 Shader::SetInt(shader_name, (
"material." + name + number).c_str(), i);
96 &this->vertices[0], GL_STATIC_DRAW);
98 &this->indices[0], GL_STATIC_DRAW);
111Mesh::Builder &Mesh::Builder::set_vertices(std::vector<Types::Vertex> vertices)
113 this->vertices = vertices;
159Mesh Mesh::Builder::build()
static void DrawElements(GLenum mode, int count, GLenum type, const void *indices)
Draw Elements.
static void BindVertexArray(unsigned int n)
Enable Depth Test.
The Builder class is used to build a Mesh object.
The Mesh class represents a 3D model.
GLint wrapping
Type of texture wrapping.
GLint filtering_min
Minifying texture filtering.
std::vector< Types::Vertex > vertices
vertices of the mesh
GLint mipmap_min
Type of mipmap minifying texture filtering.
GLboolean hasMipmap
Should the texture have a mipmap?
void Draw(Types::ShaderName shader_name)
Draw the mesh.
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.
std::vector< Types::Texture > textures
textures of the mesh
GLint filtering_mag
Magnifying texture filtering.
GLint mipmap_mag
Type of mipmap magnifying texture filtering.
std::vector< unsigned int > indices
indices of the mesh
static void SetInt(Types::ShaderName shader_name, const std::string &name, int value)
Set an integer in the shader.
static void BindTexture(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.
static void ActiveTexture(GLenum texture)
Activate a texture unit.
Buffer wrapper around OpenGL buffer objects.
void CopyIndices(GLsizeiptr size, const void *data, GLenum usage)
Copy data to the buffer object.
void CopyVertices(GLsizeiptr size, const void *data, GLenum usage)
Copy data to the buffer object.
void Init()
Init Constructor.
unsigned int GetVAO()
Get the VAO.
void Unbind()
Unbind the VAO.
void SetVertexData(Buffer buffer, unsigned int index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer)
Set the vertex data.
The Vertex struct represents a vertex of a 3D model.