update example to latest moonworks
parent
d8708818cb
commit
929800bc3c
|
@ -1 +1 @@
|
|||
Subproject commit 9028a8b1a02d1f73be3d8006f72a8a68acccacdf
|
||||
Subproject commit 8f9aaf6d612b97d77ff5013e758846894777089a
|
|
@ -1,32 +0,0 @@
|
|||
using MoonWorks.Graphics;
|
||||
|
||||
namespace MoonWorksMultiWindow.Graphics
|
||||
{
|
||||
public class RenderTargets
|
||||
{
|
||||
public RenderTarget ExampleRenderTarget { get; }
|
||||
public RenderTarget ExtraWindowRenderTarget { get; }
|
||||
|
||||
public RenderTargets(
|
||||
GraphicsDevice graphicsDevice,
|
||||
uint renderDimensionsX,
|
||||
uint renderDimensionsY
|
||||
) {
|
||||
ExampleRenderTarget = RenderTarget.CreateBackedRenderTarget(
|
||||
graphicsDevice,
|
||||
renderDimensionsX,
|
||||
renderDimensionsY,
|
||||
TextureFormat.R8G8B8A8,
|
||||
false
|
||||
);
|
||||
|
||||
ExtraWindowRenderTarget = RenderTarget.CreateBackedRenderTarget(
|
||||
graphicsDevice,
|
||||
renderDimensionsX,
|
||||
renderDimensionsY,
|
||||
TextureFormat.R8G8B8A8,
|
||||
false
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
using MoonWorks.Graphics;
|
||||
|
||||
namespace MoonWorksMultiWindow.Graphics
|
||||
{
|
||||
public class GraphicsObjects
|
||||
{
|
||||
public RenderTargets RenderTargets { get; }
|
||||
|
||||
public GraphicsObjects(
|
||||
GraphicsDevice graphicsDevice,
|
||||
uint renderDimensionsX,
|
||||
uint renderDimensionsY
|
||||
)
|
||||
{
|
||||
RenderTargets = new RenderTargets(
|
||||
graphicsDevice,
|
||||
renderDimensionsX,
|
||||
renderDimensionsY
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,14 +1,11 @@
|
|||
using MoonWorks.Graphics;
|
||||
using MoonWorks;
|
||||
using MoonWorksMultiWindow.Graphics;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MoonWorksMultiWindow
|
||||
{
|
||||
class MoonWorksMultiWindowGame : Game
|
||||
{
|
||||
private GraphicsObjects GraphicsObjects { get; }
|
||||
|
||||
private Window ExtraWindow { get; }
|
||||
|
||||
public MoonWorksMultiWindowGame(
|
||||
|
@ -17,13 +14,6 @@ namespace MoonWorksMultiWindow
|
|||
bool debugMode
|
||||
) : base(windowCreateInfo, presentMode, 60, debugMode)
|
||||
{
|
||||
// Insert your game initialization logic here.
|
||||
GraphicsObjects = new GraphicsObjects(
|
||||
GraphicsDevice,
|
||||
windowCreateInfo.WindowWidth,
|
||||
windowCreateInfo.WindowHeight
|
||||
);
|
||||
|
||||
var extraWindowCreateInfo = new WindowCreateInfo
|
||||
{
|
||||
WindowTitle = "Extra Window",
|
||||
|
@ -37,7 +27,25 @@ namespace MoonWorksMultiWindow
|
|||
|
||||
protected override void Update(System.TimeSpan dt)
|
||||
{
|
||||
// Insert your game update logic here.
|
||||
if (Inputs.Keyboard.IsPressed(MoonWorks.Input.Keycode.Up))
|
||||
{
|
||||
Window.SetWindowSize(Window.Width + 50, Window.Height + 50);
|
||||
}
|
||||
|
||||
if (Inputs.Keyboard.IsPressed(MoonWorks.Input.Keycode.Down))
|
||||
{
|
||||
Window.SetWindowSize(Window.Width - 50, Window.Height - 50);
|
||||
}
|
||||
|
||||
if (Inputs.Keyboard.IsPressed(MoonWorks.Input.Keycode.Right))
|
||||
{
|
||||
ExtraWindow.SetWindowSize(ExtraWindow.Width + 50, ExtraWindow.Height + 50);
|
||||
}
|
||||
|
||||
if (Inputs.Keyboard.IsPressed(MoonWorks.Input.Keycode.Left))
|
||||
{
|
||||
ExtraWindow.SetWindowSize(ExtraWindow.Width - 50, ExtraWindow.Height - 50);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Draw(System.TimeSpan dt, double alpha)
|
||||
|
@ -52,24 +60,18 @@ namespace MoonWorksMultiWindow
|
|||
private void MainDraw()
|
||||
{
|
||||
var commandBuffer = GraphicsDevice.AcquireCommandBuffer();
|
||||
var swapchainTexture = commandBuffer.AcquireSwapchainTexture(Window);
|
||||
|
||||
commandBuffer.BeginRenderPass(
|
||||
new ColorAttachmentInfo
|
||||
if (swapchainTexture != null)
|
||||
{
|
||||
RenderTarget = GraphicsObjects.RenderTargets.ExampleRenderTarget,
|
||||
ClearColor = Color.CornflowerBlue,
|
||||
LoadOp = LoadOp.Clear,
|
||||
StoreOp = StoreOp.DontCare
|
||||
}
|
||||
commandBuffer.BeginRenderPass(
|
||||
new ColorAttachmentInfo(
|
||||
swapchainTexture, Color.CornflowerBlue
|
||||
)
|
||||
);
|
||||
|
||||
commandBuffer.EndRenderPass();
|
||||
|
||||
commandBuffer.QueuePresent(
|
||||
GraphicsObjects.RenderTargets.ExampleRenderTarget.TextureSlice,
|
||||
Filter.Nearest,
|
||||
Window
|
||||
);
|
||||
}
|
||||
|
||||
GraphicsDevice.Submit(commandBuffer);
|
||||
}
|
||||
|
@ -77,24 +79,18 @@ namespace MoonWorksMultiWindow
|
|||
private void ExtraWindowDraw()
|
||||
{
|
||||
var commandBuffer = GraphicsDevice.AcquireCommandBuffer();
|
||||
var swapchainTexture = commandBuffer.AcquireSwapchainTexture(ExtraWindow);
|
||||
|
||||
commandBuffer.BeginRenderPass(
|
||||
new ColorAttachmentInfo
|
||||
if (swapchainTexture != null)
|
||||
{
|
||||
RenderTarget = GraphicsObjects.RenderTargets.ExtraWindowRenderTarget,
|
||||
ClearColor = Color.OrangeRed,
|
||||
LoadOp = LoadOp.Clear,
|
||||
StoreOp = StoreOp.DontCare
|
||||
}
|
||||
commandBuffer.BeginRenderPass(
|
||||
new ColorAttachmentInfo(
|
||||
swapchainTexture, Color.OrangeRed
|
||||
)
|
||||
);
|
||||
|
||||
commandBuffer.EndRenderPass();
|
||||
|
||||
commandBuffer.QueuePresent(
|
||||
GraphicsObjects.RenderTargets.ExtraWindowRenderTarget.TextureSlice,
|
||||
Filter.Nearest,
|
||||
ExtraWindow
|
||||
);
|
||||
}
|
||||
|
||||
GraphicsDevice.Submit(commandBuffer);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue