Hello,
I am drawing a grid of vertices with TRIANGLE_STRIP. At the end of each row, i would call the assigned restart primitive.
WebGl does not support this. What alternatives are there to drawing a simple grid efficiently?
Old School glGenBuffers(1, &uiVBOIndices);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, uiVBOIndices);
int iIndices[] =
{
0, 4, 1, 5, 2, 6, 3, 7, 16, // First row, then restart
4, 8, 5, 9, 6, 10, 7, 11, 16, // Second row, then restart
8, 12, 9, 13, 10, 14, 11, 15 // Third row, no restart
};
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(iIndices), iIndices, GL_STATIC_DRAW);
glEnable(GL_PRIMITIVE_RESTART);
glPrimitiveRestartIndex(HM_SIZE_X*HM_SIZE_Y);
New SchoolgridIndicesBuffer = gl.createBuffer();
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, gridIndicesBuffer);
var indices = [];
//Do stuff to indices
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(indices), gl.STATIC_DRAW);
gridIndicesBuffer.itemSize = 1;
gridIndicesBuffer.numItems = indices.length;
gl.enable(gl.GL_PRIMITIVE_RESTART);
gl.primitiveRestartIndex(totalIndices);
Any pointers here?
Regards,
Daniel