Game Development Reference
In-Depth Information
&m_swapChain
);
When we create the swap chain, we need to use a specific method for Windows
Store applications, which takes the CoreWindow instance that we received when
we created the application as a parameter. This would be where you pass a HWND
Window handle, if you were using the old Win32 API. These handles let Direct3D
connect the resource to the correct window and ensure that it is positioned properly
when composited with the other windows on the screen.
Now we have a swap chain, almost ready for rendering. While we still have the DXGI
device, we can also let it know that we want to enable a power-saving mode that en-
sures only one frame is queued up for display at a time.
dxgiDevice->SetMaximumFrameLatency(1);
This is especially important in Windows Store applications, as your game may be
running on a mobile device, and your players wouldn't want to suddenly lose a lot of
battery rendering frames that they do not need.
Render target, depth stencil, and viewport
The next step is to get a reference to the back buffer in the swap chain, so that we
can make use of it later on. First, we need to get the back buffer texture from the
swap chain, which can be easily done with a call to the GetBuffer() method. This
will give us a pointer to a texture buffer, which we can use to create a render target
view, as follows:
ComPtr<ID3D11Texture2D> backBuffer;
m_swapChain->GetBuffer(
0,
__uuidof(ID3D11Texture2D),
&backBuffer
);
Search WWH ::




Custom Search