3
votes

I have an OpenGL scene with thousands of vertices and would like to pass them as VBOs/IBOs. Executing the glGetIntegerv(GL_MAX_ELEMENTS_VERTICES, &maxVertices) command reveals a limitation of 2048 max amount of vertices, despite the fact I have a recent video card. In addition to that, an array in C is limited to an int, hence 32k vertices max.

How can I work around these limitations to anyway display all my objects ?

3
An array in C is limited to an int?Flexo
When I use something else than an integer in the brackets (e.g. MyArray[double_variable]), it tells me "Array subscript is not an integer".Laurent Crivello
doubles can't be an array index, but long can be. int and long are both integers. It's rare for int to be as small as 16 bits on platforms with recent videos cards too.Flexo
What OpenGL implementation and platform/compiler is this?Dr. Snoopy
You must be developing on exceedingly old hardware to get a 2048 size on GL_MAX_ELEMENTS_VERTICES.Nicol Bolas

3 Answers

5
votes

The GL_MAX_ELEMENTS_VERTICES constant only applies to the glDrawRangeElements call and even then values larger than that will surely not make glDrawRangeElements slower than glDrawElements. It is not a good idea to manually split your batches into smaller parts, as batches should be as large as possible and draw calls as few as possible. Just forget about this value, it has no real meaning anymore.

And by the way, I'm quite sure your int can hold values much larger than 32k, as on modern platforms (at least those with a graphics device that supports VBOs) an int should be at least 32bits wide (and therefore be able to hold values like 2G/4G). Although on an embedded device (using OpenGL ES) you might still be limited to 16bit vertex indices.

2
votes

Doesn't GL_MAX_ELEMENTS_VERTICES just tell you the most vertices that can be passed to a single call of glDrawRangeElements? Is there a reason you can't split your scene into bits and render the bits one by one?

1
votes

Divide your total number of vertices by 2048 and create than many VBOs

void glGenBuffersARB(GLsizei n, GLuint* ids)

So n would be (total / 2048)+1 and ids would be a GLuint array containing (total / 2048)+1