1

I thought in two ways to write my opengl es 2.0 code.

First, I write many calls to draw elements in the screen with many VAOs and VBOs or one only VAO and many VBOs.

Second, I save the coordinates of all elements in one list and I write all vertices of these coordinates in one only VAO and one only VBO and draw all vertices in the screen.

What is the better way that I should follow?

These are the ones I thought, what other ways are there?

PerduGames
  • 1,108
  • 8
  • 19

1 Answers1

1

The VAO is meant to save you some setup calls when setting the vertex attributes pointers and enabling/disabling the pipeline states related to that setup. Having just one VAO isn't saving you anything, because you will repeatedly re-bind the vertex buffers and change some settings. So you should aim to have multiple VAOs, one per "static" rendering batch, but not necessarily one per object drawn.

As to having all vertices in single VBO or many VBOs - that really depends on the task.

Having all data in single VBO has no benefits if you draw that all in many calls. But there's also no point in allocating one VBO per sprite. It's always about the balance between the costs of different calls to setup the pipeline, so ideally you try different approaches and decide what's best for you in your particular case.

There might be restrictions on the buffer sizes, and there's definitely "reasonable" sizes preferred by specific implementations. I remember some issues with old Intel drivers, when rendering the portion of the buffer would process the entire buffer, skipping unneeded vertices.

Vlad
  • 5,450
  • 1
  • 12
  • 19
  • Thanks, I reading more the specification and I found that opengl es 2.0 does not support the VAO. But I believe that be possible create one pseudo-vao with functions, is it correct? – PerduGames Dec 26 '19 at 13:11
  • 1
    @PerduGames It's not in es 2.0 spec, but likely present on a device as an extension OES_vertex_array_object. The code might handle both ways in runtime, binding the vertex streams each time when the vao functionality isn't present. – Vlad Dec 26 '19 at 13:21
  • If there is an extension, I will do it that way. – PerduGames Dec 26 '19 at 13:24
  • Be careful with this extension. There are a lot of OpenGL ES 2.0 devices that don't report it. You can find more info at https://gpuinfo.org . E.g. https://opengles.gpuinfo.org/listreports.php?extension=GL_OES_vertex_array_object&option=not – Vlad Alex Jan 17 '20 at 10:03