Select shader by pressing number keys
このコミットが含まれているのは:
1 親
35e21eadbd
コミット
d71bd17bb9
1ファイル変更
+34
-2
@@ -13,6 +13,22 @@ namespace ComputeSharp.SwapChain.D2D1;
|
||||
/// </summary>
|
||||
public sealed partial class App : IFrameworkViewSource, IFrameworkView
|
||||
{
|
||||
/// <summary>
|
||||
/// The collection of available pixel shader effects.
|
||||
/// </summary>
|
||||
private static readonly PixelShaderEffect[] Effects =
|
||||
[
|
||||
new PixelShaderEffect.For<ColorfulInfinity>(static (time, width, height) => new((float)time.TotalSeconds, new int2(width, height))),
|
||||
new PixelShaderEffect.For<FractalTiling>(static (time, width, height) => new((float)time.TotalSeconds, new int2(width, height))),
|
||||
new PixelShaderEffect.For<TwoTiledTruchet>(static (time, width, height) => new((float)time.TotalSeconds, new int2(width, height))),
|
||||
new PixelShaderEffect.For<MengerJourney>(static (time, width, height) => new((float)time.TotalSeconds, new int2(width, height))),
|
||||
new PixelShaderEffect.For<Octagrams>(static (time, width, height) => new((float)time.TotalSeconds, new int2(width, height))),
|
||||
new PixelShaderEffect.For<ProteanClouds>(static (time, width, height) => new((float)time.TotalSeconds, new int2(width, height))),
|
||||
new PixelShaderEffect.For<PyramidPattern>(static (time, width, height) => new((float)time.TotalSeconds, new int2(width, height))),
|
||||
new PixelShaderEffect.For<TriangleGridContouring>(static (time, width, height) => new((float)time.TotalSeconds, new int2(width, height))),
|
||||
new PixelShaderEffect.For<TerracedHills>(static (time, width, height) => new((float)time.TotalSeconds, new int2(width, height)))
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="CoreApplicationView"/> for the current app instance.
|
||||
/// </summary>
|
||||
@@ -23,6 +39,11 @@ public sealed partial class App : IFrameworkViewSource, IFrameworkView
|
||||
/// </summary>
|
||||
private CoreWindow? window;
|
||||
|
||||
/// <summary>
|
||||
/// The currently selected effect (one of the items in <see cref="Effects"/>).
|
||||
/// </summary>
|
||||
private PixelShaderEffect selectedEffect = Effects[0];
|
||||
|
||||
/// <summary>
|
||||
/// The entry point for the application.
|
||||
/// </summary>
|
||||
@@ -63,12 +84,23 @@ public sealed partial class App : IFrameworkViewSource, IFrameworkView
|
||||
|
||||
ApplicationView.GetForCurrentView().TitleBar.StyleTitleBarForExtendedIntoViewMode();
|
||||
|
||||
PixelShaderEffect effect = new PixelShaderEffect.For<ColorfulInfinity>(static (time, width, height) => new((float)time.TotalSeconds, new int2(width, height)));
|
||||
// Switch the shader to use when pressing the number keys
|
||||
this.window!.CharacterReceived += (s, e) =>
|
||||
{
|
||||
if (e.KeyCode is >= '1' and <= '9')
|
||||
{
|
||||
this.selectedEffect = Effects[(int)(e.KeyCode - '1')];
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
};
|
||||
|
||||
CoreWindowApplication application = new();
|
||||
|
||||
application.Draw += (s, e) =>
|
||||
{
|
||||
PixelShaderEffect effect = this.selectedEffect;
|
||||
|
||||
// Set the effect properties
|
||||
effect.ElapsedTime = e.TotalTime;
|
||||
effect.ScreenWidth = (int)e.ScreenWidth;
|
||||
@@ -78,7 +110,7 @@ public sealed partial class App : IFrameworkViewSource, IFrameworkView
|
||||
e.DrawingSession.DrawImage(effect);
|
||||
};
|
||||
|
||||
CoreWindowApplicationRunner.Run(application, this.window!);
|
||||
CoreWindowApplicationRunner.Run(application, this.window);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする