Max size for Vertex Buffer Objects (OpenGL ES 2.0)

Alvin Heng picture Alvin Heng · Sep 10, 2011 · Viewed 14.8k times · Source

Is there a max size for vertex buffer objects binded to GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER???

Originally, I was drawing a mesh composed of 16 submeshes. For each submesh, I created a vertex buffer and during the rendering phase, I called glDrawElements. This worked fine on the iOS simulator, but when I tried to render to my device, the screen flashes constantly and the meshes aren't displayed.

I then did some reading and found that you shouldn't call glDrawElements too many times during a render phase. I tried to combine all of my submeshes into one vertex buffer. The buffer bound to GL_ARRAY_BUFFER contains 3969 vertices, where each vertex contains 20 floats. So the size of this buffer is 317520 bytes. The indices bound to GL_ELEMENT_ARRAY_BUFFER are 16425 shorts. The size of this buffer is therefore 32850 bytes.

On the OpenGL wiki, it says that "1MB to 4MB is a nice size according to one nVidia document" for a Vertex Buffer Object.

I printed out the result of glGetError after binding each buffer object, and calling glDrawElements, and I don't see any errors. However, my meshes aren't correctly displayed. It seems as though only the first mesh gets correctly drawn. Is there anything fishy in the way I've implemented this? I didn't want to make this question too long so if there's any extra information you need to answer this question let me know. If there's nothing in theory that seems wrong, perhaps I've just made a mistake in implementing it.

Answer

Nicol Bolas picture Nicol Bolas · Sep 10, 2011

There is a maximum size, in the sense that the GPU can always issue a GL_OUT_OF_MEMORY error. But other than that, no.