Graphics Reference
In-Depth Information
ID3DllBuffer* pBuffer = 0;
UINT offset = 0;
// Set pBuffer to the desired index buffer reference here, and
// set the offset to an appropriate location in the buffer.
m_pContext->IASetIndexBuffer( pBuffer, DXGI_FORMAT_R32_UINT, offset );
Listing 3.3. How to bind an index buffer to the input assembler stage.
Once a vertex or index buffer is bound to the pipeline, it can be unbound by setting
a NULL pointer value to the corresponding input slot. This is important to remember, es-
pecially when reconfiguring the pipeline in between draw calls. If a multiple vertex buffer
configuration is used in a previous draw call, and the new draw call uses fewer vertex buf-
fers, the unused slots should be filled with NULL to unbind the unused buffers. This is why
the vertex buffer binding method always uses an array sized for the maximum number of
vertex buffers and initializes them to NULL values before filling the desired configuration.
3.3.2 Input Assembler State Configuration
After the appropriate resources have been bound to the vertex and index buffer slots, there
are two other configurations that must be set in the input assembler before it can be used.
The first is the Input Layout object, which is used by the input assembler to know which
input slots to read the per-vertex data from to build complete vertices. The second param-
eter is the primitive topology that should be used by the input assembler to determine how
vertices are grouped together into primitives. These two states, in combination with the
draw method that is used to execute the pipeline, determines how vertex and primitive
data are interpreted by the pipeline. We will explore each of these states in detail and then
consider how they interact with the available draw methods to produce different input
configurations.
Input Layout
The Input Layout object can be thought of as a recipe that tells the input assembler how to
create vertices. Every vertex is composed of a collection of vector attributes, each with up
to four components. With up to 16 vertex buffers available for binding, the input assembler
needs to know where to read each of these components from, as well as understanding what
order to put them in the final assembled vertices. The Input Layout object provides this
information to the input assembler.
To create an Input Layout object, the application must create an array of D3D11_
INPUT_E LEMENT_DESC structures, with one structure for each component of a desired vertex
Search WWH ::




Custom Search