Draw many unique triangles with a single call (for better performance)?

Here is a simple case scenario: http://jsfiddle.net/headchem/r28mm/10/

Is there a way to avoid calling this line for every single triangle I want to make?

gl.drawArrays(gl.TRIANGLES, 0, numItems);

As a training exercise, I am trying to create a 2D game from simple colored triangles. I would like to place several hundred moving triangles on the screen of each frame, but my frame rates are very slow with my current attempts. I suspect that due to hundreds of drawArrays () calls, I am making every frame.

I read a little about Vertex Buffer Objects, and this question sounds promising , but it's hard for me to put together all the parts in my demonstration of the violin above. Is it possible to create hundreds of unique two-dimensional triangular shapes + different colors + transparency in one callback with good performance?

+1
source share
1 answer

, VBO, , , , , , . , . , , , , , , . , 0, - (3*3 + 3*4), (number_of_vertices * number_of_floats_per_point + number_of_vertices * number_of_floats_per_color). .

, / , .

VBO, , , VBO, " ". , ( ), VBO, . , 1 .

, per-vertex .

+1

Source: https://habr.com/ru/post/1547469/


All Articles