Like in this question, I've loaded some vertex and index data from a format (COLLADA
) where the indices are interleaved. The answer suggested to use buffer textures but also warned about losses in rendering performance, which I want to avoid.
So the problem is to merge all the interleaved index and vertex data into multiple VBOs
and a single index buffer.
The data is given like this
P N P N P N P N P N P N ...
0 0 1 0 2 0 7 1 6 1 5 1 ...
Where each P
refers to a position and each N
to a normal vector.
One way to solve this problem would be to keep track of all the tuples (of two in this case) in a list. If I read the next tuple, I search for this tuple in the list and if it exists then I use this position as the new index data and if it doesn't I construct a new vertex and put the tuple on the list.
Of course this is hideously slow, as it includes comparing those tuples to each existing one.
Is there are more efficient way to accomplish this?