Game Development Reference
In-Depth Information
ing. And lastly, we set the
CpuAccessFlags
and
OptionsFlags
to
None
as we've
done before.
Next, we create a
DepthStencilViewDescription
to configure the depth stencil
view object. The
Format
property specifies the format, for which we just pass in
the value we set for the
Format
property of the depth stencil texture description
we just filled in. We set the
Dimension
property to
DepthStencilViewDimen-
sion.Texture2D
since we are using a
Texture2D
object for the depth stencil tex-
ture. And the
MipSlice
property is beyond the scope of this text, so we set it to
0
.
The next line of code creates the depth stencil texture object. And after that, the fol-
lowing line creates the
DepthStencilView
object. And the last line tells the output
merger to use our new depth stencil along with our render target.
Note
In this demo we only have one object, so we won't really see the depth stencil in
action. If we had two cubes, with one partially obscured by the other, then we'd
see the depth stencil in action, making the front cube actually get drawn in front
as we want.
With that done, we need to initialize our constant buffers now, so that we can com-
municate various bits of information to the graphics card, such as our projection and
view matrices.
Initializing the constant buffers
Next we will create the
InitConstantBuffers()
method to initialize our constant
buffers:
public void InitConstantBuffers()
{
// Create a buffer description.
BufferDescription bd = new
BufferDescription();