/// <summary> /// Draws indexed, instanced geometry. /// </summary> /// <param name="primType">Type of the primitives to draw.</param> /// <param name="indexCountPerInstance">Number of indices per instance to draw.</param> /// <param name="startIndex">Starting index in the index buffer at which to read vertex indices from.</param> /// <param name="baseVertex">Offset to add to each vertex index in the index buffer.</param> /// <param name="instanceCount">Number of instances to draw.</param> public override void DrawIndexedInstanced(PrimitiveType primType, int indexCountPerInstance, int startIndex, int baseVertex, int instanceCount) { D3D10Helper.CheckDisposed(_graphicsDevice); if (indexCountPerInstance <= 0) { throw new ArgumentOutOfRangeException("vertexCount", "Index count must be greater than zero."); } if (instanceCount <= 0) { throw new ArgumentOutOfRangeException("instanceCount", "Number of instances to draw must be greater than zero."); } if (_currentIndexBuffer == null) { throw new ArgumentNullException("DrawIndexedInstanced requires a valid index buffer."); } else { D3D10Helper.CheckDisposed(_currentIndexBuffer); } //Send any remaining texture/sampler changes to the device. FlushStates(); _graphicsDevice.InputAssembler.SetInputLayout(_currentPass.InputLayoutMap.GetOrCreateLayout(_currentVertexBuffers, _currentVertexBufferCount)); _graphicsDevice.InputAssembler.SetPrimitiveTopology(D3D10Helper.ToD3DPrimitiveType(primType)); _graphicsDevice.DrawIndexedInstanced(indexCountPerInstance, instanceCount, startIndex, startIndex, 0); }
/// <summary> /// Draws non-indexed geometry. /// </summary> /// <param name="primType">Type of the primitives to draw</param> /// <param name="vertexCount">Number of vertices to draw</param> /// <param name="startVertex">Starting index in the vertex buffer at which to read vertices from.</param> public override void Draw(PrimitiveType primType, int vertexCount, int startVertex) { D3D10Helper.CheckDisposed(_graphicsDevice); if (vertexCount <= 0) { throw new ArgumentOutOfRangeException("vertexCount", "Vertex count must be greater than zero."); } //Send any remaining texture/sampler changes to the device. FlushStates(); _graphicsDevice.InputAssembler.SetInputLayout(_currentPass.InputLayoutMap.GetOrCreateLayout(_currentVertexBuffers, _currentVertexBufferCount)); _graphicsDevice.InputAssembler.SetPrimitiveTopology(D3D10Helper.ToD3DPrimitiveType(primType)); _graphicsDevice.Draw(vertexCount, startVertex); }