-
Notifications
You must be signed in to change notification settings - Fork 1
/
MainWindow.xaml.cs
72 lines (64 loc) · 2.45 KB
/
MainWindow.xaml.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using System;
using System.Windows;
using YQCool.ComputeSharp.Wpf.Shaders;
using D3D9 = Silk.NET.Direct3D9;
using D3D12 = TerraFX.Interop.DirectX;
using TWindow = TerraFX.Interop.Windows;
namespace YQCool.ComputeSharp.Wpf;
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
/// <summary>
/// The mapping of available samples to choose from.
/// </summary>
private static readonly IShaderRunner[] Samples =
{
new ShaderRunner<HelloWorld>(static time => new((float) time.TotalSeconds)),
new ShaderRunner<FourColorGradient>(static time => new((float) time.TotalSeconds)),
new ShaderRunner<ColorfulInfinity>(static time => new((float) time.TotalSeconds)),
new ShaderRunner<FractalTiling>(static time => new((float) time.TotalSeconds)),
new ShaderRunner<TwoTiledTruchet>(static time => new((float) time.TotalSeconds)),
new ShaderRunner<MengerJourney>(static time => new((float) time.TotalSeconds)),
new ShaderRunner<Octagrams>(static time => new((float) time.TotalSeconds)),
new ShaderRunner<ProteanClouds>(static time => new((float) time.TotalSeconds)),
new ShaderRunner<ExtrudedTruchetPattern>(static time => new((float) time.TotalSeconds)),
new ShaderRunner<PyramidPattern>(static time => new((float) time.TotalSeconds)),
new ShaderRunner<TriangleGridContouring>(static time => new((float) time.TotalSeconds)),
new ShaderRunner<TerracedHills>(static time => new((float) time.TotalSeconds))
};
private int index;
public MainWindow()
{
InitializeComponent();
ComputeShaderD3DImage.ShaderRunner = Samples[index];
}
protected override void OnClosed(EventArgs e)
{
base.OnClosed(e);
ComputeShaderD3DImage.Dispose();
}
private void PauseButton_OnClick(object sender, RoutedEventArgs e)
{
ComputeShaderD3DImage.IsPaused = !ComputeShaderD3DImage.IsPaused;
}
private void LastButton_OnClick(object sender, RoutedEventArgs e)
{
index--;
if (index < 0)
{
index = Samples.Length - 1;
}
ComputeShaderD3DImage.ShaderRunner = Samples[index];
}
private void NextButton_OnClick(object sender, RoutedEventArgs e)
{
index++;
if (index >= Samples.Length)
{
index = 0;
}
ComputeShaderD3DImage.ShaderRunner = Samples[index];
}
}