Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the size of a VBO in OpenGL-ES?

Tags:

opengl-es

I was sending vertex arrays (of 32 bit floats) to the GPU every time I wanted to draw them, but this wasn't efficient, so I switched to Vertex Buffer Objects to cache my vertex arrays in the GPU.

It's working, but I was wondering if there's a way to determine the size of a given VBO later on without going back to the original vertex arrays? Here's the process I'm struggling with:

  1. I have a vertex array of, for example, six 32 bit floats.
  2. I send my vertex array to the GPU via OpenGL-ES where it's stored in a VBO - to which I retain a handle.
  3. My vertex array is redundant at this point so I delete it.
  4. Later on I use the handle to make OpenGL-ES draw something, but at this point I'd also like to know how to determine the size of the vertex array that was originally used to create the VBO. I now have just the VBO handle - can I re-determine somehow that I'd stored six 32 bit floats in this VBO?

I'm probably missing something really obvious. Thanks for any suggestions!

like image 398
Monte Hurd Avatar asked Sep 29 '10 06:09

Monte Hurd


People also ask

How big can a VBO be?

According to the author each batch HAS TO contains an instance of a VBO (plus a VAO) and he insists strongly on the fact that the maximimum size of a VBO is ranged between 1Mo (1000000 bytes) to 4Mo (4000000 bytes).

What does VBO stand for OpenGL?

A vertex buffer object (VBO) is an OpenGL feature that provides methods for uploading vertex data (position, normal vector, color, etc.) to the video device for non-immediate-mode rendering.

What is Vao and VBO in OpenGL?

A VBO is a buffer of memory which the gpu can access. That's all it is. A VAO is an object that stores vertex bindings. This means that when you call glVertexAttribPointer and friends to describe your vertex format that format information gets stored into the currently bound VAO.

What is a VAO in OpenGL?

A Vertex Array Object (VAO) is an OpenGL Object that stores all of the state needed to supply vertex data (with one minor exception noted below). It stores the format of the vertex data as well as the Buffer Objects (see below) providing the vertex data arrays.


1 Answers

Doh! Just found it:

int nBufferSize = 0;

glGetBufferParameteriv(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, &nBufferSize);

int originalVertexArraySize = ( nBufferSize / sizeof(float) );

like image 116
Monte Hurd Avatar answered Oct 29 '22 18:10

Monte Hurd