2024-06-05 21:19:43 +00:00
|
|
|
using System;
|
|
|
|
using MoonWorks;
|
|
|
|
using MoonWorks.Graphics;
|
|
|
|
|
|
|
|
namespace MoonWorksGraphicsTests;
|
|
|
|
|
|
|
|
class Program : Game
|
|
|
|
{
|
|
|
|
Example[] Examples =
|
|
|
|
[
|
2024-06-06 05:47:06 +00:00
|
|
|
new ClearScreenExample(),
|
|
|
|
new ClearScreen_MultiWindowExample(),
|
|
|
|
new BasicStencilExample(),
|
|
|
|
new BasicTriangleExample(),
|
|
|
|
new CompressedTexturesExample(),
|
2024-06-05 21:19:43 +00:00
|
|
|
new BasicComputeExample(),
|
2024-06-06 05:47:06 +00:00
|
|
|
new ComputeUniformsExample()
|
2024-06-05 21:19:43 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
int ExampleIndex = 0;
|
|
|
|
|
|
|
|
public Program(
|
|
|
|
WindowCreateInfo windowCreateInfo,
|
|
|
|
FrameLimiterSettings frameLimiterSettings,
|
|
|
|
BackendFlags preferredBackends,
|
|
|
|
int targetTimestep = 60,
|
|
|
|
bool debugMode = false
|
|
|
|
) : base(windowCreateInfo, frameLimiterSettings, preferredBackends, targetTimestep, debugMode)
|
|
|
|
{
|
2024-06-06 05:47:06 +00:00
|
|
|
Examples[ExampleIndex].Init(MainWindow, GraphicsDevice, Inputs);
|
2024-06-05 21:19:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Update(TimeSpan delta)
|
|
|
|
{
|
2024-06-06 05:47:06 +00:00
|
|
|
if (Inputs.Keyboard.IsPressed(MoonWorks.Input.KeyCode.Q))
|
2024-06-05 21:19:43 +00:00
|
|
|
{
|
|
|
|
Examples[ExampleIndex].Destroy();
|
|
|
|
|
|
|
|
ExampleIndex -= 1;
|
|
|
|
if (ExampleIndex < 0)
|
|
|
|
{
|
|
|
|
ExampleIndex = Examples.Length - 1;
|
|
|
|
}
|
|
|
|
|
2024-06-06 05:47:06 +00:00
|
|
|
Examples[ExampleIndex].Init(MainWindow, GraphicsDevice, Inputs);
|
2024-06-05 21:19:43 +00:00
|
|
|
}
|
2024-06-06 05:47:06 +00:00
|
|
|
else if (Inputs.Keyboard.IsPressed(MoonWorks.Input.KeyCode.E))
|
2024-06-05 21:19:43 +00:00
|
|
|
{
|
|
|
|
Examples[ExampleIndex].Destroy();
|
|
|
|
|
|
|
|
ExampleIndex = (ExampleIndex + 1) % Examples.Length;
|
|
|
|
|
2024-06-06 05:47:06 +00:00
|
|
|
Examples[ExampleIndex].Init(MainWindow, GraphicsDevice, Inputs);
|
2024-06-05 21:19:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Examples[ExampleIndex].Update(delta);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Draw(double alpha)
|
|
|
|
{
|
|
|
|
Examples[ExampleIndex].Draw(alpha);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void Main(string[] args)
|
|
|
|
{
|
|
|
|
var debugMode = false;
|
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
debugMode = true;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
var windowCreateInfo = new WindowCreateInfo(
|
|
|
|
"MoonWorksGraphicsTests",
|
2024-06-06 05:47:06 +00:00
|
|
|
640,
|
|
|
|
480,
|
2024-06-05 21:19:43 +00:00
|
|
|
ScreenMode.Windowed,
|
|
|
|
SwapchainComposition.SDR,
|
|
|
|
PresentMode.VSync
|
|
|
|
);
|
|
|
|
|
|
|
|
var frameLimiterSettings = new FrameLimiterSettings(
|
|
|
|
FrameLimiterMode.Capped,
|
|
|
|
60
|
|
|
|
);
|
|
|
|
|
|
|
|
var game = new Program(
|
|
|
|
windowCreateInfo,
|
|
|
|
frameLimiterSettings,
|
|
|
|
BackendFlags.Vulkan | BackendFlags.D3D11 | BackendFlags.Metal,
|
|
|
|
60,
|
|
|
|
debugMode
|
|
|
|
);
|
|
|
|
|
|
|
|
game.Run();
|
|
|
|
}
|
|
|
|
}
|