With regards to your questions:
- OpenGL have Buffers, so, it is usefull to store geometry's data in a class? I can edit in live OpenGL buffers, right?
This depends on how often you intend to update the data, and the type of GPU you're using. If you're using a discrete "desktop" GPU (e.g., NVIDIA or ATI/AMD), OpenGL buffers are allocated on the graphics card's memory, and editing (by calling glMapBuffer
or vairants) a buffer usually requires either copying the data from the GPU back to the CPU's memory, or keeping a "shadow copy" of your data in the CPU which is sent to the GPU after editing. Either way, you will likely incur a delay by editing the data in the buffer.
An alternative — and usually better — way to edit the data is to replace a portion of the buffer using glBufferSubData
, which may help reduce the effects of mapping and unmapping the buffer for interactive editing. This call requires an array of data in CPU memory which will be copied to the GPU to replace the data in the buffer. The amount of data you can send with glBufferSubData
must be less than the size of the original buffer.
With respect to keeping data in a class, if you'll be changing the data often, then your best approach is probably to keep a local copy, and then glBufferSubData
to send it to the GPU.
- OpenGL index buffers can handle GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT and GL_UNSIGNED_INT, in my class how can I manage this different types? Did I need to create one vector of unsigned int, one vector of short, …?
No, you only need one buffer of the most appropriate type based on how many vertices you need to index. For example, you can only access 256 vertices using GL_UNSIGNED_BYTE
indices.
- Is it useful to manage unsigned int, unsigned byte and unsigned short for indices? I'm asking that because storing just unsigned short would be less painfull and could allow small and big models.
Once again, the data type you use for indices is really only important for how many vertices you want to access, so if GLushort
is the best storage format, go for it.