MoonWorksGraphicsTests/Program.cs

133 lines
2.9 KiB
C#
Raw Normal View History

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 18:14:24 +00:00
new ComputeUniformsExample(),
2024-06-06 19:06:37 +00:00
new CopyTextureExample(),
2024-06-06 19:13:01 +00:00
new CubeExample(),
2024-06-06 20:00:14 +00:00
new CullFaceExample(),
2024-06-06 20:09:45 +00:00
new DepthMSAAExample(),
2024-06-06 20:24:11 +00:00
new DrawIndirectExample(),
2024-06-06 21:11:14 +00:00
new GetBufferDataExample(),
2024-06-06 21:19:46 +00:00
new InstancingAndOffsetsExample(),
2024-06-06 21:38:53 +00:00
new MSAACubeExample(),
2024-06-06 21:47:06 +00:00
new MSAAExample(),
2024-06-06 21:58:30 +00:00
new RenderTexture2DArrayExample(),
2024-06-06 22:03:43 +00:00
new RenderTexture2DExample(),
2024-06-06 22:11:11 +00:00
new RenderTextureCubeExample(),
2024-06-06 22:20:20 +00:00
new RenderTextureMipmapsExample(),
2024-06-06 22:28:16 +00:00
new StoreLoadExample(),
2024-06-06 22:34:15 +00:00
new Texture3DCopyExample(),
2024-06-06 22:43:24 +00:00
new Texture3DExample(),
2024-06-06 22:51:29 +00:00
new TexturedAnimatedQuadExample(),
2024-06-06 22:56:42 +00:00
new TexturedQuadExample(),
2024-06-06 23:01:11 +00:00
new TextureMipmapsExample(),
2024-06-06 23:05:36 +00:00
new TriangleVertexBufferExample(),
2024-06-06 23:19:35 +00:00
new VertexSamplerExample(),
2024-06-06 23:24:12 +00:00
new VideoPlayerExample(),
new WindowResizingExample()
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
2024-06-11 17:08:37 +00:00
) : base(
windowCreateInfo,
SwapchainComposition.SDR,
PresentMode.VSync,
frameLimiterSettings,
preferredBackends,
targetTimestep,
debugMode
) {
2024-06-06 21:11:14 +00:00
Logger.LogInfo("Welcome to the MoonWorks Graphics Tests program! Press Q and E to cycle through examples!");
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);
}
2024-06-06 19:06:37 +00:00
protected override void Destroy()
{
Examples[ExampleIndex].Destroy();
}
2024-06-05 21:19:43 +00:00
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-11 17:08:37 +00:00
ScreenMode.Windowed
2024-06-05 21:19:43 +00:00
);
var frameLimiterSettings = new FrameLimiterSettings(
FrameLimiterMode.Capped,
60
);
var game = new Program(
windowCreateInfo,
frameLimiterSettings,
BackendFlags.Vulkan | BackendFlags.D3D11 | BackendFlags.Metal,
60,
debugMode
);
game.Run();
}
}