-
Notifications
You must be signed in to change notification settings - Fork 45
/
GraphicsPresenter.cs
56 lines (41 loc) · 1.72 KB
/
GraphicsPresenter.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
44
45
46
47
48
49
50
51
52
53
54
55
56
using System;
namespace DirectX12GameEngine.Graphics
{
public abstract class GraphicsPresenter : IDisposable
{
protected GraphicsPresenter(GraphicsDevice device, PresentationParameters presentationParameters)
{
GraphicsDevice = device;
PresentationParameters = presentationParameters;
DepthStencilBuffer = CreateDepthStencilBuffer();
}
public abstract Texture BackBuffer { get; }
public GraphicsDevice GraphicsDevice { get; }
public abstract object NativePresenter { get; }
public PresentationParameters PresentationParameters { get; }
public Texture DepthStencilBuffer { get; protected set; }
public virtual void BeginDraw(CommandList commandList)
{
}
public virtual void Dispose()
{
DepthStencilBuffer.Dispose();
}
public abstract void Present();
public void Resize(int width, int height)
{
PresentationParameters.BackBufferWidth = width;
PresentationParameters.BackBufferHeight = height;
ResizeBackBuffer(width, height);
ResizeDepthStencilBuffer(width, height);
}
protected virtual Texture CreateDepthStencilBuffer()
{
return Texture.New2D(GraphicsDevice,
PresentationParameters.BackBufferWidth, PresentationParameters.BackBufferHeight, PresentationParameters.DepthStencilFormat,
TextureFlags.DepthStencil, 1, PresentationParameters.Stereo ? (short)2 : (short)1);
}
protected abstract void ResizeBackBuffer(int width, int height);
protected abstract void ResizeDepthStencilBuffer(int width, int height);
}
}