Game Development Reference
In-Depth Information
The middle parameter is a D3D11_SUBRESOURCE_DATA object. You can use this
object to point to the data in system memory that you want to load into the buffer by
setting pSysMem to the pointer to your data. The other options just need to be set to
zero for these buffers.
Using the buffers
You now know how to create the vertex and index buffers required for your model;
however, there are a few more parts required before you will see anything on the
screen. Before we get into the other requirements, let's run through how to actually
use the buffers you have created.
In the graphics pipeline, before any of the shaders, we have the input assembler .
This is responsible for handling and working with the vertex data that the shaders will
operate on. We need to use the device context to set the vertex and index buffers on
the input assembler, so that, when we have our input layout and shaders later on,
it will have the data required to render.
The device context has a number of methods for interacting with the different parts
of the pipeline, and each of them has a two-letter acronym at the start, which indic-
ates the part of the pipeline the method operates on. In this case we want to look for
methods beginning with IA, as follows:
IASetVertexBuffers
IASetIndexBuffer
We'll use these two methods to set the buffers on the GPU. Both are pretty straight-
forward, but for reference the following are the prototypes for each of them:
void IASetVertexBuffers(UINT startSlot, UINT
numBuffers,
ID3D11Buffer * const *ppVertexBuffers, const
UINT *pStrides,
const UINT *pOffsets);
Starting from the beginning, startSlot defines the input slot that the first buffer
in your array will be assigned to. In most cases you won't need to specify anything
Search WWH ::




Custom Search