2022-11-09 19:54:42 +00:00
|
|
|
|
using MoonWorks;
|
|
|
|
|
using MoonWorks.Graphics;
|
|
|
|
|
|
|
|
|
|
namespace MoonWorks.Test
|
|
|
|
|
{
|
|
|
|
|
class ClearScreen_MultiWindowGame : Game
|
|
|
|
|
{
|
|
|
|
|
private Window secondaryWindow;
|
|
|
|
|
|
2024-03-06 08:15:44 +00:00
|
|
|
|
public ClearScreen_MultiWindowGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), TestUtils.DefaultBackend, 60, true)
|
2022-11-09 19:54:42 +00:00
|
|
|
|
{
|
2024-03-06 08:15:44 +00:00
|
|
|
|
var (windowX, windowY) = MainWindow.Position;
|
|
|
|
|
MainWindow.SetPosition(windowX - 360, windowY);
|
|
|
|
|
|
2022-11-09 19:54:42 +00:00
|
|
|
|
secondaryWindow = new Window(
|
|
|
|
|
new WindowCreateInfo("Secondary Window", 640, 480, ScreenMode.Windowed, PresentMode.FIFO, false, false),
|
|
|
|
|
GraphicsDevice.WindowFlags
|
|
|
|
|
);
|
2024-03-06 08:15:44 +00:00
|
|
|
|
(windowX, windowY) = secondaryWindow.Position;
|
|
|
|
|
secondaryWindow.SetPosition(windowX + 360, windowY);
|
2022-11-09 19:54:42 +00:00
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|