Hi,
I encounter some problems on drawing the line with the fourth and fifth vertices.
I can draw the line with first three vertices correctly using the following setting:
vertices = vertices.concat([0, 0, 0]);
vertices = vertices.concat([0, 0, 2]);
vertices = vertices.concat([2, 0, 0]);
vertices = vertices.concat([3, 0, 1]);
vertices = vertices.concat([1, 2, 1]);
vertices = vertices.concat([1, 2, 5]);
geometryVertexIndices = geometryVertexIndices.concat([0, 1, 1, 2, 2, 0, 1, 2, 2, 3, 3, 1, 0, 3]);
unpackedColors = unpackedColors.concat(color);
unpackedColors = unpackedColors.concat(color);
unpackedColors = unpackedColors.concat(color);
unpackedColors = unpackedColors.concat(color);
unpackedColors = unpackedColors.concat(color);
unpackedColors = unpackedColors.concat(color);
...
mvPushMatrix();
gl.bindBuffer(gl.ARRAY_BUFFER, geometryVertexPositionBuffer);
gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, geometryVertexPositionBuffer.itemSize, gl.FLOAT, false, 0, 0);
gl.bindBuffer(gl.ARRAY_BUFFER, geometryVertexColorBuffer);
gl.vertexAttribPointer(shaderProgram.vertexColorAttribute, geometryVertexColorBuffer.itemSize, gl.FLOAT, false, 0, 0);
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, geometryVertexIndexBuffer);
gl.lineWidth(5);
mvPushMatrix();
setMatrixUniforms();
gl.drawElements(gl.LINES, geometryVertexIndexBuffer.numItems, gl.UNSIGNED_SHORT, 0);
mvPopMatrix();
mvPopMatrix();
However, when I draw the line with the fourth or fifth vertice (see the last index), it shows nothing (draw nothing):
geometryVertexIndices = geometryVertexIndices.concat([0, 1, 1, 2, 2, 0, 1, 2, 2, 3, 3, 1, 0, 4]);
Is there anything wrong I have made? Can anyone help me to solve the problem? Thanks for your help.