0
- I have a list of objects;
- Each object has different amounts of texture;
- When I do glBindTexture 2 textures (fuzzy and specular) to an object, it can happen that the next object can have only 1 texture (fuzzy);
- It turns out that the second texture of the first object ends up being sent to the next object to be rendered, because the second texture is still linked.
Question: Would you like to know how to proceed in such cases and try to unlink all the previous textures is appropriate? If so, how? Because I tried to use the function glDisable(GL_TEXTURE_2D); only it is not unlinking.
As you can see, the specular texture of the wall has ended up in the glasses that only have a fuzzy texture. (And no, by coincidence it seems that the glasses are reflecting the scenery, but that’s not it)
for (Mesh & obj : openglDraw::objs) {
...
if (obj.textureDiffuse.size() != 0) {
unsigned int i = 0;
for (unsigned int &j : obj.textureDiffuse) {
openglUtils::setTexture(programme, i, j);
openglUtils::setInt(programme, "material.diffmap", i);
i++;
}
for (unsigned int &j : obj.textureSpecular) {
openglUtils::setTexture(programme, i, j);
openglUtils::setInt(programme, "material.specmap", i);
i++;
}
...
glDisable(GL_TEXTURE_2D);
}
...