Y
Y
yipuz2017-02-25 18:03:45
JavaScript
yipuz, 2017-02-25 18:03:45

How to properly draw multiple objects in webgl?

Can you please tell me why in many articles on webgl the drawing function (drawArrays/drawElements) is called for each object? Isn't it better to draw at once?
I also looked into the ThreeJS library, it does the same thing there. Maybe there is some kind of intermediate buffer and so faster?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Pavlyuk, 2017-02-25
@yipuz

Because it will be necessary for each frame to first shove all the objects into one buffer, and then draw it, it will be more expensive. And so, each object in its own buffer and draw as we want. Plus, how do you turn on different shaders and textures for different objects if they are drawn with one call?
Further, if you have 100 identical objects, you will have to make a buffer the size of 100 objects, instead of drawing from one buffer 100 times in a row.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question