title: Problem drawing more than one texture in WebGL
body: <p>I'm developing a little exercise in WebGL to start learning, which consists on loading simple geometry with textures. However, I'm a bit stuck with a little problem I'm having on rendering meshes with textures.</p>
  
  <p>The point is that I have a main code which loads 2 triangles and 2 squares and generates a texture for one of the triangles, and all that renders perfectly.</p>
  
  <p><img src="https://i.stack.imgur.com/UvddK.png" alt="One Texture Rendering"></p>
  
  <p>However, if I try to load more textures, all the textured objects except the one with the last texture loaded, are not rendered.</p>
  
  <p><img src="https://i.stack.imgur.com/1yYfQ.png" alt="like this">.</p>
  
  <p>I'm not sure what I'm doing wrong, since it works a bit different than OpenGL. I looked at the code again and I don't get it. The code to render each object is the next step (a bit hardcoded, but is just to learn WebGL), which just binds a buffer with <code>Position</code> and <code>TextureCoordinates</code> attributes, sends some uniforms and draws:</p>
  
  <pre><code>        gl.bindBuffer(gl.ARRAY_BUFFER, mesh.getID());
          gl.vertexAttribPointer(shader_bound.vPosAttr, 3, gl.FLOAT, false, 20, 0);        
          gl.vertexAttribPointer(shader_bound.vTCoordAttr, 2, gl.FLOAT, false, 20, 12);
  
          shader_bound.SetUniformMat4f("u_ModelMatrix", mesh.getModelMatrix());
          shader_bound.SetUniformVec4f("u_Color", mesh.getMeshColor());   
          shader_bound.SetUniform1i("u_UseTextures", 0);
  
          if(mesh.getMeshTexture() != null)
          {
              gl.activeTexture(gl.TEXTURE0);
              gl.bindTexture(gl.TEXTURE_2D, mesh.getMeshTexture().getTexture());
              shader_bound.SetUniform1i("u_AlbedoTexture", 0);
              shader_bound.SetUniform1i("u_UseTextures", 1);
          }
  
          gl.drawArrays(gl.TRIANGLES, 0, mesh.getVertexNumber());
          gl.bindBuffer(gl.ARRAY_BUFFER, null);
          gl.bindTexture(gl.TEXTURE_2D, null);
  </code></pre>
  
  <p>The shader is very basic, the only thing it does is to determine if it has texture or not (with the "u_UseTextures" uniform), and, based on that, paints the mesh with color or with texture*color.</p>
  
  <p>Does anybody see where the error is? Thanks!</p>
  
  <p><strong>Edit:</strong> I added a log just after activating and binding the texture in the code I show. The log just shows the name of the texture that's being bounded and it seems it's correct:</p>
  
  <p><img src="https://i.stack.imgur.com/n1xPl.png" alt="Console Logs"></p>