2022-02-09 01:38:20 +00:00
|
|
|
using MoonWorks.Graphics;
|
|
|
|
using MoonWorks;
|
|
|
|
using MoonWorksMultiWindow.Graphics;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
namespace MoonWorksMultiWindow
|
|
|
|
{
|
2022-02-25 06:07:35 +00:00
|
|
|
class MoonWorksMultiWindowGame : Game
|
|
|
|
{
|
|
|
|
private GraphicsObjects GraphicsObjects { get; }
|
2022-02-09 01:38:20 +00:00
|
|
|
|
2022-02-25 21:27:27 +00:00
|
|
|
private Window ExtraWindow { get; }
|
2022-02-09 01:38:20 +00:00
|
|
|
|
2022-02-25 06:07:35 +00:00
|
|
|
public MoonWorksMultiWindowGame(
|
|
|
|
WindowCreateInfo windowCreateInfo,
|
|
|
|
PresentMode presentMode,
|
|
|
|
bool debugMode
|
|
|
|
) : base(windowCreateInfo, presentMode, 60, debugMode)
|
|
|
|
{
|
|
|
|
// Insert your game initialization logic here.
|
|
|
|
GraphicsObjects = new GraphicsObjects(
|
|
|
|
GraphicsDevice,
|
|
|
|
windowCreateInfo.WindowWidth,
|
|
|
|
windowCreateInfo.WindowHeight
|
|
|
|
);
|
2022-02-09 01:38:20 +00:00
|
|
|
|
|
|
|
var extraWindowCreateInfo = new WindowCreateInfo
|
|
|
|
{
|
|
|
|
WindowTitle = "Extra Window",
|
|
|
|
WindowWidth = 1280,
|
|
|
|
WindowHeight = 720,
|
|
|
|
ScreenMode = ScreenMode.Windowed
|
|
|
|
};
|
|
|
|
|
2022-02-25 21:27:27 +00:00
|
|
|
ExtraWindow = new Window(extraWindowCreateInfo);
|
2022-02-25 06:07:35 +00:00
|
|
|
}
|
2022-02-09 01:38:20 +00:00
|
|
|
|
2022-02-25 06:07:35 +00:00
|
|
|
protected override void Update(System.TimeSpan dt)
|
|
|
|
{
|
|
|
|
// Insert your game update logic here.
|
|
|
|
}
|
2022-02-09 01:38:20 +00:00
|
|
|
|
2022-02-25 06:07:35 +00:00
|
|
|
protected override void Draw(System.TimeSpan dt, double alpha)
|
|
|
|
{
|
2022-02-10 05:25:16 +00:00
|
|
|
var mainDraw = Task.Run(MainDraw);
|
|
|
|
var extraDraw = Task.Run(ExtraWindowDraw);
|
|
|
|
|
|
|
|
mainDraw.Wait();
|
|
|
|
extraDraw.Wait();
|
2022-02-25 06:07:35 +00:00
|
|
|
}
|
2022-02-09 01:38:20 +00:00
|
|
|
|
2022-02-25 06:07:35 +00:00
|
|
|
private void MainDraw()
|
2022-02-09 01:38:20 +00:00
|
|
|
{
|
2022-02-25 06:07:35 +00:00
|
|
|
var commandBuffer = GraphicsDevice.AcquireCommandBuffer();
|
|
|
|
|
|
|
|
commandBuffer.BeginRenderPass(
|
|
|
|
new ColorAttachmentInfo
|
|
|
|
{
|
2022-02-25 21:27:27 +00:00
|
|
|
RenderTarget = GraphicsObjects.RenderTargets.ExampleRenderTarget,
|
|
|
|
ClearColor = Color.CornflowerBlue,
|
|
|
|
LoadOp = LoadOp.Clear,
|
|
|
|
StoreOp = StoreOp.DontCare
|
2022-02-25 06:07:35 +00:00
|
|
|
}
|
|
|
|
);
|
2022-02-09 01:38:20 +00:00
|
|
|
|
|
|
|
commandBuffer.EndRenderPass();
|
|
|
|
|
2022-02-25 06:07:35 +00:00
|
|
|
commandBuffer.QueuePresent(
|
|
|
|
GraphicsObjects.RenderTargets.ExampleRenderTarget.TextureSlice,
|
|
|
|
Filter.Nearest,
|
2022-02-09 01:38:20 +00:00
|
|
|
Window
|
2022-02-25 06:07:35 +00:00
|
|
|
);
|
2022-02-09 01:38:20 +00:00
|
|
|
|
2022-02-25 06:07:35 +00:00
|
|
|
GraphicsDevice.Submit(commandBuffer);
|
2022-02-09 01:38:20 +00:00
|
|
|
}
|
|
|
|
|
2022-02-25 06:07:35 +00:00
|
|
|
private void ExtraWindowDraw()
|
2022-02-09 01:38:20 +00:00
|
|
|
{
|
|
|
|
var commandBuffer = GraphicsDevice.AcquireCommandBuffer();
|
|
|
|
|
2022-02-25 06:07:35 +00:00
|
|
|
commandBuffer.BeginRenderPass(
|
|
|
|
new ColorAttachmentInfo
|
|
|
|
{
|
2022-02-25 21:27:27 +00:00
|
|
|
RenderTarget = GraphicsObjects.RenderTargets.ExtraWindowRenderTarget,
|
|
|
|
ClearColor = Color.OrangeRed,
|
|
|
|
LoadOp = LoadOp.Clear,
|
|
|
|
StoreOp = StoreOp.DontCare
|
2022-02-25 06:07:35 +00:00
|
|
|
}
|
|
|
|
);
|
2022-02-09 01:38:20 +00:00
|
|
|
|
|
|
|
commandBuffer.EndRenderPass();
|
|
|
|
|
|
|
|
commandBuffer.QueuePresent(
|
|
|
|
GraphicsObjects.RenderTargets.ExtraWindowRenderTarget.TextureSlice,
|
|
|
|
Filter.Nearest,
|
|
|
|
ExtraWindow
|
|
|
|
);
|
|
|
|
|
2022-02-25 06:07:35 +00:00
|
|
|
GraphicsDevice.Submit(commandBuffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void OnDestroy()
|
|
|
|
{
|
|
|
|
|
2022-02-09 01:38:20 +00:00
|
|
|
}
|
2022-02-25 06:07:35 +00:00
|
|
|
}
|
2022-02-09 01:38:20 +00:00
|
|
|
}
|