void SetBuffers(DirectXDevice device) { // Setup the Vertex Buffer var vertexBuffer = VertexBuffer.Resource.Buffer; var elementSize = vertexBuffer.ElementSize; device.SetVertexBuffer(0, vertexBuffer, elementSize, VertexBuffer.Start == 0 ? 0 : VertexBuffer.Start * elementSize); // Setup the Vertex Buffer Input layout device.SetVertexInputLayout(VertexBuffer.Resource.Layout); // Setup the index Buffer var indexBuffer = IndexBuffer.Resource; device.SetIndexBuffer(indexBuffer, IsIndex32Bit, IndexBuffer.Start == 0 ? 0 : IndexBuffer.Start * indexBuffer.ElementSize); }
public override void Render() { DirectXDevice device = DeviceService.DirectXDevice; foreach (Shader shader in Technique) { shader.Apply(Technique.Name, UpdateType.SceneFrame); } var updatedData = AggregateIntanceData(); instanceBuffer.SetData(device, updatedData); foreach (ModelMesh modelMesh in Model.Meshes) { foreach (ConstantBuffer cb in Technique[ShaderType.Vertex].SelectBuffers(Technique.Name, UpdateType.InstanceFrame)) { device.SetVertexBuffer(cb.Index, instanceBuffer, elementSize); } modelMesh.DrawIndexedInstanced(device, EntityCount); } }