TillUntil now I´ve, I have been using this way of storinga vertexData structure to store data for VBOa Vertex Buffer Object :
struct vertexData{
Vertex vertices[6];
};
(Vertex - position,color,uvVBO)
This structure; vertexData holds a static array of 6 vertices (2 triangles). Then I´m savingI then save them to a vectorvector of these structuresthe vertexData type, before finally using this vertexData in the buffering method:
struct vertexData {
Vertex vertices[6]; // position, color, UVs
};
std::vector<vertexData> _DATA;
And finally, the buffering function looks like this:
void SpriteBatch::createVBO() {
glBindBuffer(GL_ARRAY_BUFFER,_VBO);
glBufferData(GL_ARRAY_BUFFER,_DATA.size()*sizeof(vertexData),nullptr,GL_DYNAMIC_DRAW);
glBufferSubData(GL_ARRAY_BUFFER,0,_DATA.size()*sizeof(vertexData),_DATA.data());
glBindBuffer(GL_ARRAY_BUFFER,0);
}
This works good, as everything in my vector is contiguous contiguous. However, iI want to work also with other vertex sizes (for, for different shapes - such as polygons,lines..). I tried vectora vector of vectors (to get an opportunityvector types, in oder to work work with dynamically allocated "arrays" )arrays, but it didn´tdid not work, as it wasn´twas not contiguous. Can you give me some tips? I´ve got an idea to code own container but wanted to know how does the big engines deal with this before.
Edit1:
At At first i, I thought about using somea polymorphic class to be stored in vector andas a vector, where every child would have a different size of array, size; but then iI recognized that this vertex buffer doesn´tdoes not work with pointers
The second idea was to create a generic SpriteBatch (forSpriteBatch. For example, a batch for 6 vertices, and then a batch for 2 vertices, etc.) etc.
What is the best way to store Vertex Buffer Object data?