开发者

How do I get the length of a VBO to render all vertices when using glDrawArrays()?

I create a VBO in a function and I only want to return the VBO id.

I use glDrawAr开发者_如何学JAVArays in another function and I want it to draw all the vertices in the VBO without needing to also pass the number of vertices. The VBO also contains texture coordinate data.

Thank you.


You need to return it, sorry. Data about the VBO might live somewhere far away from your CPU and be slow to access, so you need to keep locally whatever data you need.


Maybe it could be not useful for you application, you can use glGetBufferParameteriv with argument GL_BUFFER_SIZE: it returns the number of bytes of the buffer object.

It's difficoult to say that this is the solution, since you should know the internal format of the buffer element (and indeed, its size in bytes), in order to have the number of elements composing the buffer object.

For sure, the best solution is to keep most information in a class representing the buffer object, but as I can understand from your question this is hard to implement.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜