title: Only first call works in multiple drawElements calls with same vertex buffers
body: <p>I am trying to render a model under multiple light sources using multiple drawElement calls with different light sources. The gist of the code is as follows.</p>
  
  <pre><code>    this.setUniform("u_matrix", "Matrix4fv", false, matrix);
      this.setUniform("u_nMatrix", "Matrix3fv", false, nMatrix);
  
      this.setUniform("u_kSpecular", "3fv", material.specular);
      this.setUniform("u_kDiffuse", "3fv", material.diffuse);
      this.setUniform("u_kAmbient", "3fv", material.ambient);
      this.setUniform("u_shininess", "1f", material.shininess);
  
      this.setVertexAttribArray("a_position", new Float32Array(mesh.vertices), 3);
      this.setVertexAttribArray("a_normal", new Float32Array(mesh.vertexNormals), 3);
      this.setElementArray(new Uint16Array(mesh.indices));
  
      for(var i = 0;i &lt; lights.length;i++) {
          if(i == 1) {
              gl.enable(gl.BLEND);
              gl.blendFunc(gl.ONE, gl.ONE);
              gl.blendEquation(gl.FUNC_ADD);
          }
          var light = lights[i];
          console.dir(light);
          this.setUniform("u_lightType", "1i", light.type);
          this.setUniform("u_lightVector", "3fv", light.vector);
          this.setUniform("u_lightColor", "3fv", light.color);
          gl.drawElements(gl.TRIANGLES, mesh.indices.length, gl.UNSIGNED_SHORT, 0);
      }
      gl.disable(gl.BLEND);
  </code></pre>
  
  <p>The issue here is that only the first lighting is rendered. Subsequent drawElements do not render anything. I do not think the issue is with my shader code, because the issue persists even if I strip the shader down to just set fragment color equal to the light type or some such parameter.</p>
  
  <p><code>setUniform</code> <code>setVertexAttribArray</code> and <code>setElementArray</code> are some helpers that i have written. They basically look like this:</p>
  
  <pre><code>setElementArray: function(array) {
      var gl = this.gl;
      var buffer = this._arrBuffers.__indexBuffer;
      if(_.isUndefined(buffer)) {
          buffer = gl.createBuffer();
          this._arrBuffers.__indexBuffer = buffer;
      }
      gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, buffer);
      gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, array, gl.STATIC_DRAW);
  }
  
  setVertexAttribArray: function(name, array, size, type, normalized, stride, offset) {
      var gl = this.gl;
      size = size || 2;
      type = type || gl.FLOAT;
      normalized = normalized || false;
      stride = stride || 0;
      offset = offset || 0;
  
      var buffer = this._arrBuffers[name];
      if(_.isUndefined(buffer)) {
          buffer = gl.createBuffer();
          this._arrBuffers[name] = buffer;
      }
      var location = this.getLocation(name, true);
  
      gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
      gl.bufferData(gl.ARRAY_BUFFER, array, gl.STATIC_DRAW);
      gl.enableVertexAttribArray(location);
      gl.vertexAttribPointer(location, size, type, normalized, stride, offset);
  }
  </code></pre>