我有:
public List<VertexPositionColor> chunk_vertices;
public List<int> chunk_indices;
然后
VertexBuffer vertex_buffer;
vertex_buffer = new VertexBuffer(device, VertexPositionColor.VertexDeclaration, test_chunk.chunk_vertices.Count, BufferUsage.WriteOnly);
vertex_buffer.SetData(test_chunk.chunk_vertices);
我试过了:
vertex_buffer.SetData<VertexPositionColor>(test_chunk.chunk_vertices);
和
vertex_buffer.SetData<List<VertexPositionColor>>(test_chunk.chunk_vertices);
答案 0 :(得分:3)
VertexBuffer.SetData
方法需要一个数组,因此将chunk_vertices
更改为数组,或使用以下代码:
vertex_buffer.SetData(test_chunk.chunk_vertices.ToArray());