src/mesh.cpp
// draws all the meshes of the model
draws all the meshes of the model
draws all the meshes of the model
void Mesh::draw(Shader &shader) {
  unsigned int diffuseNr = 1;
  unsigned int specularNr = 1;
  unsigned int normalNr = 1;
  for (unsigned int i = 0; i < textures.size(); i++) {
    glActiveTexture(GL_TEXTURE0 + i);
    std::string number;
    std::string name = textures[i].type;
    if (name == "texture_diffuse")
      number == std::to_string(diffuseNr++);
    else if (name == "texture_specular")
      number = std::to_string(specularNr++);
    else if (name == "texture_normal")
      number = std::to_string(normalNr++);
    shader.setUniform(("material." + name + number).c_str(), 1);
    glBindTexture(GL_TEXTURE_2D, textures[i].id);
  }
  glActiveTexture(GL_TEXTURE0);
  glBindVertexArray(VAO);
  glDrawElements(GL_TRIANGLES, indices.size(), GL_UNSIGNED_INT, 0);
  glBindVertexArray(0);
}
void Mesh :: draw ( Shader & shader ) { unsigned int diffuseNr = 1 ; unsigned int specularNr = 1 ; unsigned int normalNr = 1 ; for ( unsigned int i = 0 ; i < textures . size ( ) ; i ++ ) { glActiveTexture ( GL_TEXTURE0 + i ) ; std :: string number ; std :: string name = textures [ i ] . type ; if ( name == " " ) number == std :: to_string ( diffuseNr ++ ) ; else if ( name == " " ) number = std :: to_string ( specularNr ++ ) ; else if ( name == " " ) number = std :: to_string ( normalNr ++ ) ; shader . setUniform ( ( " " + name + number ) . c_str ( ) , 1 ) ; glBindTexture ( GL_TEXTURE_2D , textures [ i ] . id ) ; } glActiveTexture ( GL_TEXTURE0 ) ; glBindVertexArray ( VAO ) ; glDrawElements ( GL_TRIANGLES , indices . size ( ) , GL_UNSIGNED_INT , 0 ) ; glBindVertexArray ( 0 ) ; }
draws all the meshes of the model
draws all the meshes of the model
// bind all textures // draw the mesh