public void Render(DeviceContext context)
{
if (!m_inputLayoutSet)
throw new Exception("Model::Render(): input layout has not be specified, you must call SetInputLayout() before calling Render()");
foreach (ModelMesh mesh in m_meshes)
{
//set mesh specific data
context.InputAssembler.InputLayout = mesh.InputLayout;
context.InputAssembler.PrimitiveTopology = mesh.PrimitiveTopology;
context.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(mesh.VertexBuffer, mesh.VertexSize, 0));
context.InputAssembler.SetIndexBuffer(mesh.IndexBuffer, Format.R32_UInt, 0);
context.PixelShader.SetShaderResource(0, mesh.DiffuseTextureView);
//draw
context.DrawIndexed(mesh.IndexCount, 0, 0);
}
}