-
Notifications
You must be signed in to change notification settings - Fork 45
/
CoreWindowSwapChainGraphicsPresenter.cs
43 lines (38 loc) · 1.84 KB
/
CoreWindowSwapChainGraphicsPresenter.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using SharpGen.Runtime;
using Vortice.DirectX;
using Vortice.DXGI;
using Windows.UI.Core;
namespace DirectX12GameEngine.Graphics
{
public class CoreWindowSwapChainGraphicsPresenter : SwapChainGraphicsPresenter
{
private readonly CoreWindow coreWindow;
public CoreWindowSwapChainGraphicsPresenter(GraphicsDevice device, PresentationParameters presentationParameters, CoreWindow coreWindow)
: base(device, presentationParameters, CreateSwapChain(device, presentationParameters, coreWindow))
{
this.coreWindow = coreWindow;
}
private static IDXGISwapChain3 CreateSwapChain(GraphicsDevice device, PresentationParameters presentationParameters, CoreWindow coreWindow)
{
SwapChainDescription1 swapChainDescription = new SwapChainDescription1
{
Width = presentationParameters.BackBufferWidth,
Height = presentationParameters.BackBufferHeight,
SampleDescription = new SampleDescription(1, 0),
Stereo = presentationParameters.Stereo,
Usage = Usage.RenderTargetOutput,
BufferCount = BufferCount,
Scaling = Scaling.Stretch,
SwapEffect = SwapEffect.FlipSequential,
Format = (Format)presentationParameters.BackBufferFormat,
Flags = SwapChainFlags.None,
AlphaMode = AlphaMode.Unspecified
};
DXGI.CreateDXGIFactory2(false, out IDXGIFactory2 factory);
using ComObject window = new ComObject(coreWindow);
using IDXGISwapChain1 tempSwapChain = factory.CreateSwapChainForCoreWindow(device.NativeDirectCommandQueue, window, swapChainDescription);
factory.Dispose();
return tempSwapChain.QueryInterface<IDXGISwapChain3>();
}
}
}