MoonWorksGraphicsTests/ClearScreen_MultiWindow/ClearScreen_MultiWindowGame.cs

58 lines
1.6 KiB
C#
Raw Normal View History

2022-11-09 19:54:42 +00:00
using MoonWorks;
using MoonWorks.Graphics;
namespace MoonWorks.Test
{
class ClearScreen_MultiWindowGame : Game
{
private Window secondaryWindow;
public ClearScreen_MultiWindowGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
{
secondaryWindow = new Window(
new WindowCreateInfo("Secondary Window", 640, 480, ScreenMode.Windowed, PresentMode.FIFO, false, false),
GraphicsDevice.WindowFlags
);
GraphicsDevice.ClaimWindow(secondaryWindow, PresentMode.FIFO);
}
protected override void Update(System.TimeSpan delta) { }
protected override void Draw(double alpha)
{
CommandBuffer cmdbuf;
Texture? backbuffer;
2024-02-23 19:08:15 +00:00
if (MainWindow.Claimed)
2022-11-09 19:54:42 +00:00
{
2024-02-23 19:08:15 +00:00
cmdbuf = GraphicsDevice.AcquireCommandBuffer();
backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
if (backbuffer != null)
{
2024-03-01 23:03:29 +00:00
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, WriteOptions.SafeDiscard, Color.CornflowerBlue));
2024-02-23 19:08:15 +00:00
cmdbuf.EndRenderPass();
}
GraphicsDevice.Submit(cmdbuf);
2022-11-09 19:54:42 +00:00
}
2024-02-23 19:08:15 +00:00
if (secondaryWindow.Claimed)
2022-11-09 19:54:42 +00:00
{
2024-02-23 19:08:15 +00:00
cmdbuf = GraphicsDevice.AcquireCommandBuffer();
backbuffer = cmdbuf.AcquireSwapchainTexture(secondaryWindow);
if (backbuffer != null)
{
2024-03-01 23:03:29 +00:00
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, WriteOptions.SafeDiscard, Color.Aquamarine));
2024-02-23 19:08:15 +00:00
cmdbuf.EndRenderPass();
}
GraphicsDevice.Submit(cmdbuf);
2022-11-09 19:54:42 +00:00
}
}
public static void Main(string[] args)
{
ClearScreen_MultiWindowGame game = new ClearScreen_MultiWindowGame();
game.Run();
}
}
}