开发者

Vertices limitation in OpenGL

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 t开发者_StackOverflow社区o an int, hence 32k vertices max.

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


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.


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?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜