diff --git a/lib/MoonWorks b/lib/MoonWorks index 9028a8b..8f9aaf6 160000 --- a/lib/MoonWorks +++ b/lib/MoonWorks @@ -1 +1 @@ -Subproject commit 9028a8b1a02d1f73be3d8006f72a8a68acccacdf +Subproject commit 8f9aaf6d612b97d77ff5013e758846894777089a diff --git a/src/Graphics/Containers/RenderTargets.cs b/src/Graphics/Containers/RenderTargets.cs deleted file mode 100644 index bb32ce0..0000000 --- a/src/Graphics/Containers/RenderTargets.cs +++ /dev/null @@ -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 - ); - } - } -} diff --git a/src/Graphics/GraphicsObjects.cs b/src/Graphics/GraphicsObjects.cs deleted file mode 100644 index f8a3f98..0000000 --- a/src/Graphics/GraphicsObjects.cs +++ /dev/null @@ -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 - ); - } - } -} diff --git a/src/MoonWorksMultiWindowGame.cs b/src/MoonWorksMultiWindowGame.cs index d23f2d5..05beb76 100644 --- a/src/MoonWorksMultiWindowGame.cs +++ b/src/MoonWorksMultiWindowGame.cs @@ -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 - { - RenderTarget = GraphicsObjects.RenderTargets.ExampleRenderTarget, - ClearColor = Color.CornflowerBlue, - LoadOp = LoadOp.Clear, - StoreOp = StoreOp.DontCare - } - ); + if (swapchainTexture != null) + { + commandBuffer.BeginRenderPass( + new ColorAttachmentInfo( + swapchainTexture, Color.CornflowerBlue + ) + ); - commandBuffer.EndRenderPass(); - - commandBuffer.QueuePresent( - GraphicsObjects.RenderTargets.ExampleRenderTarget.TextureSlice, - Filter.Nearest, - Window - ); + commandBuffer.EndRenderPass(); + } 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 - { - RenderTarget = GraphicsObjects.RenderTargets.ExtraWindowRenderTarget, - ClearColor = Color.OrangeRed, - LoadOp = LoadOp.Clear, - StoreOp = StoreOp.DontCare - } - ); + if (swapchainTexture != null) + { + commandBuffer.BeginRenderPass( + new ColorAttachmentInfo( + swapchainTexture, Color.OrangeRed + ) + ); - commandBuffer.EndRenderPass(); - - commandBuffer.QueuePresent( - GraphicsObjects.RenderTargets.ExtraWindowRenderTarget.TextureSlice, - Filter.Nearest, - ExtraWindow - ); + commandBuffer.EndRenderPass(); + } GraphicsDevice.Submit(commandBuffer); }