Graphics Reference
In-Depth Information
As this is a desktop application, we use the SwapChain1 constructor that accepts the window
handle to create a swap chain for it. We also pass in the swap chain description structures.
For Windows Store apps, we would instead use the appropriate
constructor that accepts a Windows.UI.Core.CoreWindow instance.
In the case of Windows.UI.Xaml.Controls.SwapChainPanel ,
no window object is provided and the created swap chain is assigned to
the native panel. Details on this are provided in Chapter 11 , Integrating
Direct3D with XAML and Windows 8.1 .
The last parameter of the factory's swap chain creation method allows the application to
restrict the display of information to a particular display device. In this case we are not
restricting the output, so we are passing null .
Finally we present the back buffer using the recommended Present method override for
DXGI 1.2 ( IDXGISwapChain1.Present1 ). The additional PresentParameters parameter
allows an application to optimize presentation by specifying scrolling and dirty rectangles,
which reduces memory bandwidth and power consumption. In this case we just pass through
an empty instance.
There's moreā€¦
There are a number of different ways to initialize your Direct3D device and swap chain.
For example, if you are enumerating the available adapters and allowing a user to select,
which shall be used by the device constructor instead of defaulting to the first, you will
already have created a DXGI factory object and the previous code would look a little different.
The output restriction configuration of the swap chain is an interesting concept and easy to
demonstrate if you have more than one screen. With the previous example in place:
1.
Change null in the last parameter passed to the new SwapChain1(...)
constructor to adapter.Outputs[0] .
2.
Change the swap chain present line to:
swapChain.Present(0, PresentFlags.RestrictToOutput, new
PresentParameters());
 
Search WWH ::




Custom Search