From 5ae0192bc61d10e4e3981e3d899ba8ae0f64be64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20L=C3=BCbe=C3=9F?= Date: Wed, 2 Jun 2021 16:51:45 +0200 Subject: [PATCH] Added DepthStencilTarget to Sandbox2DApp --- Sandbox/src/SandboxApp2D.bf | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Sandbox/src/SandboxApp2D.bf b/Sandbox/src/SandboxApp2D.bf index 1407cf8..c7363e8 100644 --- a/Sandbox/src/SandboxApp2D.bf +++ b/Sandbox/src/SandboxApp2D.bf @@ -43,6 +43,7 @@ namespace Sandbox RasterizerState _rasterizerState ~ _?.ReleaseRef(); GraphicsContext _context ~ _?.ReleaseRef(); + DepthStencilTarget _depthTarget ~ _?.ReleaseRef(); Texture2D _texture ~ _?.ReleaseRef(); Texture2D _ge_logo ~ _?.ReleaseRef(); @@ -71,6 +72,8 @@ namespace Sandbox GlitchyEngine.Renderer.RasterizerStateDescription rsDesc = .(.Solid, .Back, true); _rasterizerState = new RasterizerState(_context, rsDesc); + _depthTarget = new DepthStencilTarget(_context, _context.SwapChain.Width, _context.SwapChain.Height); + _texture = new Texture2D(_context, "content/Textures/Checkerboard.dds"); _ge_logo = new Texture2D(_context, "content/Textures/GE_Logo.dds"); @@ -212,7 +215,8 @@ namespace Sandbox Application.Get().Window.Context.SwapChain.BackbufferViewport.Height; RenderCommand.Clear(null, .(0.2f, 0.2f, 0.2f)); - + + _depthTarget..Clear(1.0f, 0, .Depth).Bind(); // Draw test geometry _context.SetRenderTarget(null); _context.BindRenderTargets(); @@ -275,6 +279,8 @@ namespace Sandbox EventDispatcher dispatcher = scope EventDispatcher(event); dispatcher.Dispatch(scope (e) => OnImGuiRender(e)); + + dispatcher.Dispatch(scope (e) => OnWindowResize(e)); } private bool OnImGuiRender(ImGuiRenderEvent e) @@ -289,6 +295,14 @@ namespace Sandbox return false; } + + private bool OnWindowResize(WindowResizeEvent e) + { + _depthTarget.ReleaseRef(); + _depthTarget = new DepthStencilTarget(_context, _context.SwapChain.Width, _context.SwapChain.Height); + + return false; + } } class SandboxApp2D : Application