Game Development Reference
In-Depth Information
m_d3dDevice->CreateTexture2D(
&depthStencilDesc,
nullptr,
&depthStencil
)
Now that we have a depth buffer texture, we need a depth stencil view
( ID3D11DepthStencilView ) to bind it, as with our render target earlier. We will
use another description structure for it ( CD3D11_DEPTH_STENCIL_VIEW_DESC ).
However, we can get away with just a single parameter and the type of texture; in this
case it is a D3D11_DSV_DIMENSION_TEXTURE2D . We can then create the view,
ready for use, as shown:
m_d3dDevice->CreateDepthStencilView(
depthStencil.Get(),
&depthStencilViewDesc,
&m_depthStencilView
)
Now that we have a device, context, swap chain, render target, and depth buffer, we
just need to describe one more thing before we're ready to kick off the game loop.
The viewport describes the layout of the area we want to render. In most cases,
you will just define the full size of the render target here; however, some situations
may need you to draw to just a small section of the screen, maybe for a split screen
mode. The viewport lets you define the region once and render as normal for that
region, and then define a new viewport for the new region so you can render into it.
To create this viewport, we just need to specify the x and y coordinates of the top-left
corner, as well as the width and height of the viewport. We want to use the entire
screen, so our top-left corner is x = 0, y = 0, and our width and height match our
render target, as shown:
CD3D11_VIEWPORT viewport(
0.0f,
0.0f,
m_renderTargetSize.Width,
Search WWH ::




Custom Search