11

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.

Graham Asher
  • 1,344
  • 1
  • 15
  • 30
Alvin Heng
  • 111
  • 1
  • 1
  • 4

3 Answers3

4

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.

Nicol Bolas
  • 378,677
  • 53
  • 635
  • 829
2

See this:

http://www.sunsetlakesoftware.com/2008/08/05/lessons-molecules-opengl-es

There are some natural limits using smaller data types, like obviously ~65000 for using shorts as indexes.

But more importantly there is some additional help in the link, which is a very good tutorial, and includes some anecdotal evidence that shorts up to the natural functional limit work.

Celess
  • 958
  • 8
  • 18
0

I know it is too late to answer this question. However, I wish the answer helps someone!

Based on The Specification of OpenG Graphics System (Version 4.5 (Core Profile) - May 28, 2015), it states: "There is no limit to the number of vertices that may be specified, other than the size of the vertex arrays." please see page 322.

Sorry, also as Nicol Bolas mention here: https://stackoverflow.com/a/7369392/4228827

Cheers, Naif

Community
  • 1
  • 1
Nai
  • 51
  • 7
  • 1
    What does the OpenGL 4.5 spec have to do with OpenGL ES 2.0? – genpfault Sep 15 '17 at 15:42
  • 1
    In fact, the OpenGL ES is based on the OpenGL 2.0 graphics system that why cited it. But I agree, I should have referred to the OpenGL ES specification instead! Thanks for your comment. – Nai Sep 16 '17 at 16:38