3
我有面指數(指向點)和點,並希望繪製一個循環中的三角形。 Web控制檯提供了我這個錯誤:繪圖與webGL的元素
WebGL: drawElements: bound element array buffer is too small for given count and offset
這是我的代碼:
for(var i=1;i<38000;i++){
var vtx = new Float32Array(
[points[faces[i][1]][1],points[faces[i][1]][2],points[faces[i][1]][3],
points[faces[i][2]][1],points[faces[i][2]][2],points[faces[i][2]][3],
points[faces[i][3]][1],points[faces[i][3]][2],points[faces[i][3]][3]
]
);
var idx = new Uint16Array([0, 1]);
initBuffers(vtx, idx);
gl.lineWidth(1.0);
gl.uniform4f(shaderProgram.colorUniform, 0, 0, 0, 1);
gl.drawElements(gl.LINES, 3, gl.UNSIGNED_SHORT, 0);
unbindBuffers();
}
}
例程不畫任何東西。我該如何解決這個問題?