Game Development Reference
In-Depth Information
Setting the buffers and drawing
You generally want to follow the given order for drawing a model:
1. Set the vertex buffer.
2. Set the index buffer.
3. Set the primitive topology.
4. Set the input layout.
5. Set the vertex shader.
6. Set the pixel shader.
7. Set the constant buffer(s).
8. Draw the model.
We've covered how to set buffers, so ensure that they're set at the appropriate times
during the drawing phase. Instead we'll focus on setting the rest of the content.
To set the primitive topology, we need to call the following method:
m_d3dContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
You'll note that again all of these methods define the pipeline stage using two letters
at the start of the method. In this case we're still working with the input assembler;
however, after this you'll notice that we have moved onto the vertex shader and pixel
shader.
Now we need to set the layout using the simple IASetInputLayout() method,
which just takes a pointer to the input layout as a parameter.
After this, the shaders need to be set. To set the vertex shader, you have to call the
following line:
m_d3dContext->VSSetShader(
vertexShader,
nullptr,
0
);
Search WWH ::




Custom Search