Game Development Reference
In-Depth Information
Here the only parameter that you need to worry about is the first one, which specifies
the D3D11VertexShader object. The other two lines refer to Shader Model 5
classes, which is far outside the scope of this appendix.
To set a pixel shader you can use pretty much the same method, with the only
difference being that you call the PSSetShader() method instead of the
VSSetShader() .
Now we just need to set the constant buffer on the vertex shader so that it has the
camera data required to perform the transform. To do this, you have to make the fol-
lowing call:
m_d3dContext->VSSetConstantBuffers(
0,
1,
&pConstantBuffer
);
Here you will specify the slot the constant buffer will be placed in, and the number of
buffers within the array. Like the IASetVertexBuffers , you can set multiple buf-
fers at once. Finally, you need to point to the array of buffer pointers. In this case
we only have one element in the array so we just pass the pointer to the pCon-
stantBuffer .
Finally we have everything in place, and we can execute the command to draw this
model to the screen. There are a couple of different draw calls depending on wheth-
er you're using an index buffer, or performing instancing. If you want to draw without
an index buffer, it's a simple call to the following:
m_d3dContext->Draw(
vertCount,
startingVertex
);
This is pretty simple; you have to specify the total number of vertices, and the index
of the first vertex to start drawing from, usually zero.
Search WWH ::




Custom Search