Graphics Reference
In-Depth Information
6.
Add a new C# abstract class called D3DApplicationWinRT .
// Implements support for swap chain description for
// Windows Store apps
public abstract class D3DApplicationWinRT
: D3DApplicationBase
{
...
}
7.
In order to reduce the chances of our app being terminated to reclaim system
resources, we will use the new SharpDX.DXGI.Device3.Trim function whenever
our app is suspended (native equivalent is IDXGIDevice3::Trim ). The following
code shows how this is done:
public D3DApplicationWinRT()
: base()
{
// Register application suspending event
Windows.ApplicationModel.Core
.CoreApplication.Suspending += OnSuspending;
}
// When suspending hint that resources may be reclaimed
private void OnSuspending(Object sender, Windows.ApplicationModel.
SuspendingEventArgs e)
{
// Retrieve the DXGI Device3 interface from our
// existing Direct3D device.
using (SharpDX.DXGI.Device3 dxgiDevice = DeviceManager
.Direct3DDevice.QueryInterface<SharpDX.DXGI.Device3>())
{
dxgiDevice.Trim();
}
}
8.
The existing D3DApplicationBase.CreateSwapChainDescription function is
not compatible with Windows Store apps. Therefore, we will override this and create
a SwapChainDescription1 instance that is compatible with Windows Store apps.
The following code shows the changes necessary:
protected override SharpDX.DXGI.SwapChainDescription1
CreateSwapChainDescription()
{
var desc = new SharpDX.DXGI.SwapChainDescription1()
{
Width = Width,
Height = Height,
 
Search WWH ::




Custom Search