GL_INVALID_OPERATION : glDrawArrays: attempt to access out of range vertices in attribute 0
Closed this issue · 1 comments
I added a piece of code to the demo in the demo, but it is work normal on windows and reported an error with gl.LINE_LOOP GL ERROR :GL_INVALID_OPERATION : glDrawArrays: attempt to access out of range vertices in attribute 0 on the mac.
Could someone please take a look and let me know what am I missing here?here is my code:
gl.drawArrays(gl.TRIANGLES, 0, rectangle.length / 2);
gl.uniform1i(lineType, 1);
gl.bindBuffer(gl.ARRAY_BUFFER, lineBuf);
gl.enableVertexAttribArray(linePosition);
gl.vertexAttribPointer(linePosition, 2, gl.FLOAT, false, 0, 0);
gl.uniform4f(lineColor, 0.6,0.6,0.6,1.0);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
-1, 1,
1, 1,
1, -1,
-1, -1,
]), gl.STATIC_DRAW);
gl.drawArrays(gl.LINE_LOOP, 0, 4);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
0, 1,
0, -1,
1, 0,
-1, 0,
]), gl.STATIC_DRAW);
gl.drawArrays(gl.LINES, 0, 4);
I resolved this issue
the reason of this error is :the counts of vertices is deferent between drawArrays(gl.TRIANGLE,,) and drawArrays(gl.LINES,,),cause the mac browser report WebGL error ,and which is work normally on windows