protected void CreateBufferFromFile(Device device, string fileName) { DebugVertexType[] vertices; UInt16[] indices; ModelLoader modelLoader = new ModelLoader(device); modelLoader.LoadPrimitveFromFile(fileName, out vertices, out indices); m_vertexCount = vertices.Length; m_indexCount = indices.Length; BufferDescription vertexBufferDescription = new BufferDescription(Utilities.SizeOf <DebugVertexType>() * m_vertexCount, BindFlags.VertexBuffer, ResourceUsage.Default); m_vertexBuffer = Buffer.Create(device, vertices, vertexBufferDescription); m_indexBuffer = Buffer.Create(device, BindFlags.IndexBuffer, indices); BufferDescription instanceBufferDesc = new BufferDescription() { BindFlags = BindFlags.VertexBuffer, CpuAccessFlags = CpuAccessFlags.Write, OptionFlags = ResourceOptionFlags.None, SizeInBytes = Utilities.SizeOf <PrimitivePerInstanceData>() * MAX_NUM_INSTANCES, Usage = ResourceUsage.Dynamic }; m_instanceBuffer = new Buffer(device, instanceBufferDesc); modelLoader.Dispose(); }