I have many Polylgons. one contains different amount of points. I'm drawing them using LINE_LOOP in 2d (orthographic).
Now i want to upload all of them to a single buffer.
The problem is when i'm drawing the buffer using glDrawArrays
the last point of the first polygon is connected by line to the next point which is the first point of the second polygon, and so on.
I know that with glDrawElements
i can send the indices and it is solving the issue. but for this, I need to send allot of data for drawing polygons with allot of points, and changing the LINE_LOOP to LINES.
Is there a way to draw only with the start and end indices of each polygon ?
For example
// My 2d polygons points are
polygons = [
0,0, 10,0, 10,5, 5,10, // polygon 1
20,20, 30,20, 30,30 // polygon 2
]
// First polygon is starting at 0, the second at index 8
// If there was function like this
draw(polygons, [0, 8]);
------ADDITION-----------------
We can do it in OpenGL by calling the glDrawMultiArray - Thanks for ratchet freak answer.
But in WebGL this function does not exists. Is there any alternative ?