Graphics Reference
In-Depth Information
A swap chain that participates within an XAML composition, such as the
SwapChainPanel
swap chain, is also known as a composition swap chain. The
SwapChainPanel
XAML
element is new to Windows 8.1.
This recipe continues from where we left off with
Preparing the swap chain for Windows
Store apps
.
How to do it…
As with the previous recipe, we will first update the
Common.WinRT
project to support the
creation of a swap chain for the Windows Store app XAML
SwapChainPanel
element.
We will then create a simple
Hello World
sample that demonstrates the integration of
Direct3D into XAML.
1.
Let's begin by creating a new abstract class called
D3DAppSwapChainPanelTarget
within the
Common.WinRT
project, descending from the
D3DApplicationWinRT
class.
public abstract class D3DAppSwapChainPanelTarget
: D3DApplicationWinRT
{
private SwapChainPanel panel;
private ISwapChainPanelNative nativePanel;
public SwapChainPanel SwapChainPanel {
get { return panel; }
}
public D3DAppSwapChainPanelTarget(SwapChainPanel panel)
{
this.panel = panel;
nativePanel = ToDispose(ComObject.As
<SharpDX.DXGI.ISwapChainPanelNative>(panel));
this.panel.CompositionScaleChanged += (s, args) =>
{
ScaleChanged();
};
this.panel.SizeChanged += (sender, args) =>
{
SizeChanged();
};
}
...
}