From eb8e1c639fd734d790149a287dde1ee90df361be Mon Sep 17 00:00:00 2001 From: Michel Fedde Date: Wed, 24 Mar 2021 15:14:52 +0100 Subject: [PATCH] Added Compile-methods to renderpipeline --- SMCode/SM.Base/Window/RenderPipeline.cs | 31 ++++++++++++++++++++++--- SM_TEST/Program.cs | 9 ++++++- SM_TEST/TestRenderPipeline.cs | 2 +- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/SMCode/SM.Base/Window/RenderPipeline.cs b/SMCode/SM.Base/Window/RenderPipeline.cs index f0b5006..a02ab36 100644 --- a/SMCode/SM.Base/Window/RenderPipeline.cs +++ b/SMCode/SM.Base/Window/RenderPipeline.cs @@ -75,14 +75,39 @@ namespace SM.Base.Window /// public virtual void Resize() { - if (Framebuffers == null) return; + Recompile(); + } + + + /// + /// Compiles the framebuffers. + /// + public void Compile() + { foreach (var framebuffer in Framebuffers) - framebuffer.Dispose(); + framebuffer.Compile(); + } + + /// + /// Recompiles the pipeline. + /// + public void Recompile() + { + if (Framebuffers == null) return; + Dispose(); Thread.Sleep(100); + Compile(); + } + + /// + /// Disposes unmanaged resources like Framebuffers. + /// + public void Dispose() + { foreach (var framebuffer in Framebuffers) - framebuffer.Compile(); + framebuffer.Dispose(); } /// diff --git a/SM_TEST/Program.cs b/SM_TEST/Program.cs index 6feb15a..63afed2 100644 --- a/SM_TEST/Program.cs +++ b/SM_TEST/Program.cs @@ -25,7 +25,7 @@ namespace SM_TEST private static PolyLine line; static void Main(string[] args) { - window = new GLWindow(); + window = new GLWindow(1280, 720, "0ms", WindowFlags.Window, VSyncMode.Off); window.ApplySetup(new Window2DSetup()); window.SetRenderPipeline(new TestRenderPipeline()); @@ -40,11 +40,17 @@ namespace SM_TEST scene.Objects.Add(display); window.UpdateFrame += WindowOnUpdateFrame; + window.RenderFrame += Window_RenderFrame; window.Run(); Debug.WriteLine("Window Closed"); } + private static void Window_RenderFrame(object sender, FrameEventArgs e) + { + window.Title = Math.Floor(e.Time * 1000) + "ms"; + } + private static void WindowOnUpdateFrame(object sender, FrameEventArgs e) { @@ -52,6 +58,7 @@ namespace SM_TEST line.Vertex.Add(Mouse2D.InWorld(window.ViewportCamera as Camera), 0); line.Update(); + } private static void WindowOnLoad(IGenericWindow window) diff --git a/SM_TEST/TestRenderPipeline.cs b/SM_TEST/TestRenderPipeline.cs index 9e3d3c3..7191e71 100644 --- a/SM_TEST/TestRenderPipeline.cs +++ b/SM_TEST/TestRenderPipeline.cs @@ -37,7 +37,7 @@ namespace SM_TEST PostProcessUtility.ResolveMultisampledBuffers(MainFramebuffer, _postBuffer); - _bloom.Draw(context); + //_bloom.Draw(context); Framebuffer.Screen.Activate(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); PostProcessUtility.FinalizeHDR(_postBuffer["color"], .5f);