Let's assume I have the following simplified structure in AoSoA format to represent a vertex or point:
struct VertexData
{
float px[4]; // position x
float py[4]; // position y
};
That is, each instance of VertexData
is storing 4 vertices. Almost all OpenGL examples I've seen use the traditional AoS layout, but that is not an option for me. I can't change the actual structures, and I would also like to avoid converting the data into AoS format before rendering.
So, is it possible to instruct OpenGL to read the vertex data when the data is organized this way, and if so, which GL functions should I look into? The problem as I see it, is to make OpenGL aware of the fact that VertexData.px[i]
is paired with VertexData.py[i]
, and those two values should form a vertex/point.
Clarification 1: In the end, there will be an array of VertexData
, for example: std::vector<VertexData>
. The size of the std::vector
would then be total number of vertices / 4
.
Clarification 2: AoSoA = Array of Structure of Arrays.
Update: See How do I draw vertices that are stored in a SSBO? for on how to draw vertices that are stored in a SSBO in AoSoA format.