Game Development Reference
In-Depth Information
minimum and maximum depth values. These are normally set to
0.0f
and
1.0f
re-
spectively.
The next member variable is
m_InputLayout
. The
InputLayout
object tells Dir-
ect3D about the vertex format and shader model we are using. Remember that, a
shader is basically just a small program that is run by the video card.
The
m_VertexShader
variable will hold our vertex shader. The
m_VShaderSignature
variable holds the signature for the vertex shader. A shader
signature is just a list of parameters that are inputted to or outputted from the shader.
And lastly,
m_PixelShader
will hold our pixel shader. We'll get into shaders a bit
later in the chapter.
If you don't fully understand all of these member variables, that's fine. They should
become a little clearer once we start using them. We need to initialize Direct3D now,
so let's get started.
Initializing Direct3D
We are now ready to initialize Direct3D. For this task, we will create a new method
named
InitD3D()
. The following is the code for this method:
public void InitD3D()
{
// Setup the configuration for the
SwapChain.
var swapChainDesc = new
SwapChainDescription()
{
BufferCount = 2, // 2 back buffers
(Triple Buffering)
Usage = Usage.RenderTargetOutput,
OutputHandle = FormObject.Handle,
IsWindowed = true,
ModeDescription = new
ModeDescription(FormObject.Width,