Game Development Reference
In-Depth Information
and one of the benefits of Direct3D 11.1 is the ability to just resize the buffers in the
swap chain. However, the really important code here executes if we do not already
have a swap chain.
Many parts of Direct3D rely on creating a description structure that contains the
information required to create the device, and then pass that information to a
Create() method that will handle the rest of the creation. In this case, we will make
use of a DXGI_SWAP_CHAIN_DESC1 structure to describe the swap chain. The fol-
lowing code snippet shows what our structure will look like:
swapChainDesc.Width =
static_cast<UINT>(m_renderTargetSize.Width);
swapChainDesc.Height =
static_cast<UINT>(m_renderTargetSize.Height);
swapChainDesc.Format =
DXGI_FORMAT_B8G8R8A8_UNORM;
swapChainDesc.Stereo = false;
swapChainDesc.SampleDesc.Count = 1;
swapChainDesc.SampleDesc.Quality = 0;
swapChainDesc.BufferUsage =
DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapChainDesc.BufferCount = 2;
swapChainDesc.Scaling = DXGI_SCALING_NONE;
swapChainDesc.SwapEffect =
DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;
There are a lot of new concepts here, so let's work through each option one by one.
The Width and Height properties are self-explanatory; these come directly from
the CoreWindow instance so that we can render at native resolution. If you want to
force a different resolution, this would be where you specify that resolution.
The Format defines the layout of the pixels in the texture. Textures are represented
as an array of colors, which can be packed in many different ways. The most com-
mon way is to lay out the different color channels in a B8G8R8A8 format. This means
that the pixel will have a single byte for each channel: Blue, Green, Red, and Alpha,
in that order. The UNORM tells the system to store each pixel as an unsigned normal-
ized integer. Put together, this forms DXGI_FORMAT_B8G8R8A8_UNORM .
Search WWH ::




Custom Search