Game Development Reference
In-Depth Information
that loads the pixel shader. Now, it has
if
statements above it that check the value
of the
m_GraphicsMode
member variable. So basically, depending on which graph-
ics mode you set, it will load and use the appropriate pixel shader. If you look in the
Effects.fx
file in the downloadable code for this demo, you can see that we have
three pixel shaders in there, one for each of our three graphics modes.
Initializing the depth stencil
Anyway, now that we've covered the new member variables and the changes to the
InitShaders()
method, we need to add a couple of entirely new methods. The
first one is the
InitDepthStencil()
method that will initialize our depth stencil for
us:
public void InitDepthStencil()
{
// Create the depth stencil texture
description
Texture2DDescription
DepthStencilTextureDesc =new
Texture2DDescription();DepthStencilTextureDesc.Width
= m_Form.ClientSize.Width;
DepthStencilTextureDesc.Height =
m_Form.ClientSize.Height;
DepthStencilTextureDesc.MipLevels = 1;
DepthStencilTextureDesc.ArraySize = 1;
DepthStencilTextureDesc.Format =
Format.D24_UNorm_S8_UInt;
DepthStencilTextureDesc.SampleDescription
=new SampleDescription(1, 0);
DepthStencilTextureDesc.Usage =
ResourceUsage.Default;
DepthStencilTextureDesc.BindFlags =
BindFlags.DepthStencil;
DepthStencilTextureDesc.CpuAccessFlags =
CpuAccessFlags.None;
DepthStencilTextureDesc.OptionFlags
=ResourceOptionFlags.None;