2 pièce(s) jointe(s)
[SFML] Bug avec le chargement des textures
Bonjour,
j'ai un bug que je n'arrive pas à expliquer.
Lorsque que j'exécute se code j'ai le comportement souhaité :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| /***********************VAO 3DObject***********************/
if (glIsVertexArray(this->VAO_Mesh == GL_TRUE))
glDeleteVertexArrays(1, &this->VAO_Mesh);
glGenVertexArrays(1, &this->VAO_Mesh);
glBindVertexArray(this->VAO_Mesh);
glBindBuffer(GL_ARRAY_BUFFER, this->VBO_Vertices);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0));
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ARRAY_BUFFER, this->VBO_Normals);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0));
glEnableVertexAttribArray(1);
glBindBuffer(GL_ARRAY_BUFFER, 0);
if (!this->uvs.empty())
{
glBindBuffer(GL_ARRAY_BUFFER, this->VBO_UVs);
glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0));
glEnableVertexAttribArray(2);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
glBindVertexArray(0);
sf::Texture t;
t.loadFromFile("../refactoring/res/images/grass.jpg"); |
Pièce jointe 174124
Mais lorsque j'exécute ce code j'obtient ceci :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| sf::Texture t;
t.loadFromFile("../refactoring/res/images/grass.jpg");
/***********************VAO 3DObject***********************/
if (glIsVertexArray(this->VAO_Mesh == GL_TRUE))
glDeleteVertexArrays(1, &this->VAO_Mesh);
glGenVertexArrays(1, &this->VAO_Mesh);
glBindVertexArray(this->VAO_Mesh);
glBindBuffer(GL_ARRAY_BUFFER, this->VBO_Vertices);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0));
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ARRAY_BUFFER, this->VBO_Normals);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0));
glEnableVertexAttribArray(1);
glBindBuffer(GL_ARRAY_BUFFER, 0);
if (!this->uvs.empty())
{
glBindBuffer(GL_ARRAY_BUFFER, this->VBO_UVs);
glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0));
glEnableVertexAttribArray(2);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
glBindVertexArray(0); |
Pièce jointe 174125
Et franchement je ne vois pas pourquoi le chargement d'une texture serait affecté par un VAO ? Oo
L'erreur vient de glBindTexture(GL_TEXTURE_2D, 0) à la ligne 526.
Merci d'avance,
Robin