Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The error means one of your indices is too large for the buffers you currently have attached.</p> <p>Example: Imagine you have a position buffer with 3 positions in it</p> <pre><code> [0.123, 0.010, 0.233, 0.423, 0.312, 0.344, 0.933, 1.332, 0.101] </code></pre> <p>Now imagine you make an index buffer</p> <pre><code> [0, 1, 3] </code></pre> <p>You've only got 3 positions so the only valid indices are 0, 1, and 2. <code>3</code> is out of range. That's the error your getting.</p> <p>Some possibilities:</p> <ol> <li><p>Your data could just be bad. Check your indices</p></li> <li><p>You drew a model with less vertices but more attributes, then drew a different model with more vertices but less attributes. You left the attributes for the previous model on while drawing the 2nd model.</p></li> </ol> <p>In other words</p> <pre><code>// setup first model with only 3 vertices, both positions and colors. gl.enableVertexAttribArray(0); gl.bindBuffer(gl.BUFFER_ARRAY, bufferWith3Positions); gl.vertexAttribPointer(0, ....); gl.enableVertexAttribArray(1); gl.bindBuffer(gl.BUFFER_ARRAY, bufferWith3Colors); gl.vertexAttribPointer(1, ....); gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indicesForFirstModel); // setup first model with 6 vertices but no colors gl.bindBuffer(gl.BUFFER_ARRAY, bufferWith6Positions); gl.vertexAttribPointer(0, ....); gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indicesForSecondModel); </code></pre> <p>You'll get an error because attrib #1 is still referencing <code>bufferWith3Colors</code>. You need to turn that attribute off. </p> <pre><code>gl.disableVertexAttribArray(1); </code></pre> <p>Note: That assumes the shader is still using attribute #1. If it's not you shouldn't get an error even if <code>bufferWith3Colors</code> is still attached to attribute #1.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload