OpenGL has functions such as BufferData(int array[])
where array
must be of the format x-y-z x-y-z ...
.
It is simply a sequence of integers where each consecutive 3-tuple is interpreted as a vertex.
Is it safe to represent this as an std::vector, where vertex is declared as:
struct vertex
{
int x, y, z;
};
This would make it semantically more clear what is happening, in my opinion. However, is it possible to guarantee that this would work?
If it is not, is there any other way to provide a more semantic representation of the data?
It may work but it will not be reliable - there could be unnamed padding between the structure members so you cannot guarantee that they are aligned correctly
What is wrong with just using std::vector - this memory is guaranteed by the standard to be correct aligned and sequential.
For example you can use:
[Edit] Mooing Duck pointer out it takes more than 1 set of 3, - so in that case just extend the vector
3 tuples of 3 ints