Skip to content
Advertisement

WebGL render loop performance

I’ve just started learning WebGL.

I am rendering multiple spheres but I’m not sure about the “bindBuffer” and “bufferData” calls inside the render loops.

I can render a single sphere with 2 million vertices no problem. But once I try to render 3 spheres with 100k vertices each (300k total, 85% less vertices), the performance starts to go down.

I want to know exactly what needs to remain inside the render loop and what doesn’t. And if there is something else I am missing.

Here is my Sphere “class”:

JavaScript

And here is the main “class”:

JavaScript

Advertisement

Answer

You shouldn’t call bufferData at render time unless you’re changing the data in the buffer.

JavaScript

you might find these articles and in particular this one

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement