I’m have a large list of value types that needs to be given to OpenGL. It would be great if this could happen as quickly as possible.
What I’m doing now looks like this:
List<Vertex> VList = new List<Vertex>();
... //Add vertices
Vertex[] VArray;
VList.CopyTo(VArray, VList.Length);
GL.SetData(..., VArray);
This list is easily 10MB big, so copying is slow. Can I do this without copying, like somehow get a pointer to the array used internally by List?
Or do I have to implement my own List class..
EDIT: I forgot to mention that I don’t know the number of elements that will be added to the List.
The IList<T> interface isn’t that difficult to do (well, not so long as Reflector is free and functioning, hint hint).
You can create your own implementation and expose the internal array as a public property.