112 lines
3.0 KiB
C#
112 lines
3.0 KiB
C#
using MoonWorks.Graphics;
|
|
using MoonWorks.Window;
|
|
using MoonWorks;
|
|
using MoonWorksMultiWindow.Graphics;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace MoonWorksMultiWindow
|
|
{
|
|
class MoonWorksMultiWindowGame : Game
|
|
{
|
|
private GraphicsObjects GraphicsObjects { get; }
|
|
|
|
private int RenderWidth { get; }
|
|
private int RenderHeight { get; }
|
|
|
|
private OSWindow ExtraWindow { get; }
|
|
|
|
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
|
|
);
|
|
RenderWidth = (int)windowCreateInfo.WindowWidth;
|
|
RenderHeight = (int)windowCreateInfo.WindowHeight;
|
|
|
|
var extraWindowCreateInfo = new WindowCreateInfo
|
|
{
|
|
WindowTitle = "Extra Window",
|
|
WindowWidth = 1280,
|
|
WindowHeight = 720,
|
|
ScreenMode = ScreenMode.Windowed
|
|
};
|
|
|
|
ExtraWindow = new OSWindow(extraWindowCreateInfo);
|
|
}
|
|
|
|
protected override void Update(System.TimeSpan dt)
|
|
{
|
|
// Insert your game update logic here.
|
|
}
|
|
|
|
protected override void Draw(System.TimeSpan dt, double alpha)
|
|
{
|
|
Task mainDraw = Task.Run(MainDraw);
|
|
Task extraDraw = Task.Run(ExtraWindowDraw);
|
|
}
|
|
|
|
private void MainDraw()
|
|
{
|
|
var commandBuffer = GraphicsDevice.AcquireCommandBuffer();
|
|
|
|
commandBuffer.BeginRenderPass(
|
|
GraphicsObjects.RenderPasses.ExampleRenderPass,
|
|
GraphicsObjects.Framebuffers.ExampleFramebuffer,
|
|
new Rect
|
|
{
|
|
X = 0,
|
|
Y = 0,
|
|
W = RenderWidth,
|
|
H = RenderHeight
|
|
},
|
|
Color.CornflowerBlue.ToVector4()
|
|
);
|
|
|
|
commandBuffer.EndRenderPass();
|
|
|
|
commandBuffer.QueuePresent(
|
|
GraphicsObjects.RenderTargets.ExampleRenderTarget.TextureSlice,
|
|
Filter.Nearest,
|
|
Window
|
|
);
|
|
|
|
GraphicsDevice.Submit(commandBuffer);
|
|
}
|
|
|
|
private void ExtraWindowDraw()
|
|
{
|
|
var commandBuffer = GraphicsDevice.AcquireCommandBuffer();
|
|
|
|
commandBuffer.BeginRenderPass(
|
|
GraphicsObjects.RenderPasses.ExtraWindowRenderPass,
|
|
GraphicsObjects.Framebuffers.ExtraWindowFramebuffer,
|
|
new Rect
|
|
{
|
|
X = 0,
|
|
Y = 0,
|
|
W = RenderWidth,
|
|
H = RenderHeight
|
|
},
|
|
Color.OrangeRed.ToVector4()
|
|
);
|
|
|
|
commandBuffer.EndRenderPass();
|
|
|
|
commandBuffer.QueuePresent(
|
|
GraphicsObjects.RenderTargets.ExtraWindowRenderTarget.TextureSlice,
|
|
Filter.Nearest,
|
|
ExtraWindow
|
|
);
|
|
|
|
GraphicsDevice.Submit(commandBuffer);
|
|
}
|
|
}
|
|
}
|