Hi,
I would like to reduce the number of drawElements call when rendering a mesh. The mesh that have been loaded has some sets of Triangles strip. I've put all this indices of vertices in a U16 array prefixed by the number of vertices for each set of triangle strips, example:
[6, 1, 4, 3, 6, 7, 9, 5, 7, 1, 3, 6, 4 etc...]
explain: Each red value in the array is the next number of vertices to use.
in javascript, this array is loaded as an Element Buffer and for each set of triangle strip there's a call to drawElements
javascript code :
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indicesBuffer);
int offset = 0
while(offset < indices.length) {
var setLength = indices[offset];
offset++;
gl.drawElements(gl.TRIANGLE_STRIP, setLength, gl.UNSIGNED_SHORT, offset);
offset += setLength;
}
this work just fine but there's a lot call to drawElements, how can I reduce this ?
I think moving this to vertex shader program but I don't know how ?
this is the actual vertex shader:
attribute vec3 aVertexPosition;
uniform mat4 uMVMatrix;
uniform mat4 uPMatrix;
void main(void) {
gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);
}
Any help is appreciated
Thanks