Primitive Drawing
This section is a little example that guides you through the different steps that are needed to draw primitives.
We are going to accumulate all the commands in a command buffer that is reset the first time.
commands->Reset();
Setting and clearing the render targets
The first thing that need to be done is setting a valid render target and a valid depthbuffer. After setting those surfaces, they are cleared.
commands->SetColorBuffer(renderView);
commands->SetDepthBuffer(depthStentil);
commands->Clear(true, 0xffff0000, true, 1.0f, false, 0);
Activating a shader
The next step is setting a valid shader and its constant buffers. Shader creation is described in the Shaders section.
commands->SetShader(shader, 0, 0);
commands->SetConstantBuffer(cb0);
commands->SetConstantBuffer(cb1);
Binding vertices and indices
In this stage, both the vertex source and the index buffer is bound to the device. If the primitive that we are going to draw didn't need indices you would omit that step.
commands->SetVertices(vertices);
commands->SetIndices(indices);
Draw the primitive
And the last step is drawing the primitive.
commands->DrawIndexed(PrimitiveType_TriangleList, baseVertexIndex, minIndex, numVertices, startIndex,
numIndices);
Committing the commands to the device
Each time we want to render that primitive we apply the previously generated command buffer.
renderSystem->Apply(commands);