Added Compile-methods to renderpipeline

This commit is contained in:
Michel Fedde 2021-03-24 15:14:52 +01:00
parent 58c5bafa1b
commit eb8e1c639f
3 changed files with 37 additions and 5 deletions

View file

@ -75,14 +75,39 @@ namespace SM.Base.Window
/// </summary> /// </summary>
public virtual void Resize() public virtual void Resize()
{ {
if (Framebuffers == null) return; Recompile();
}
/// <summary>
/// Compiles the framebuffers.
/// </summary>
public void Compile()
{
foreach (var framebuffer in Framebuffers) foreach (var framebuffer in Framebuffers)
framebuffer.Dispose(); framebuffer.Compile();
}
/// <summary>
/// Recompiles the pipeline.
/// </summary>
public void Recompile()
{
if (Framebuffers == null) return;
Dispose();
Thread.Sleep(100); Thread.Sleep(100);
Compile();
}
/// <summary>
/// Disposes unmanaged resources like Framebuffers.
/// </summary>
public void Dispose()
{
foreach (var framebuffer in Framebuffers) foreach (var framebuffer in Framebuffers)
framebuffer.Compile(); framebuffer.Dispose();
} }
/// <summary> /// <summary>

View file

@ -25,7 +25,7 @@ namespace SM_TEST
private static PolyLine line; private static PolyLine line;
static void Main(string[] args) static void Main(string[] args)
{ {
window = new GLWindow(); window = new GLWindow(1280, 720, "0ms", WindowFlags.Window, VSyncMode.Off);
window.ApplySetup(new Window2DSetup()); window.ApplySetup(new Window2DSetup());
window.SetRenderPipeline(new TestRenderPipeline()); window.SetRenderPipeline(new TestRenderPipeline());
@ -40,11 +40,17 @@ namespace SM_TEST
scene.Objects.Add(display); scene.Objects.Add(display);
window.UpdateFrame += WindowOnUpdateFrame; window.UpdateFrame += WindowOnUpdateFrame;
window.RenderFrame += Window_RenderFrame;
window.Run(); window.Run();
Debug.WriteLine("Window Closed"); 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) 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.Vertex.Add(Mouse2D.InWorld(window.ViewportCamera as Camera), 0);
line.Update(); line.Update();
} }
private static void WindowOnLoad(IGenericWindow window) private static void WindowOnLoad(IGenericWindow window)

View file

@ -37,7 +37,7 @@ namespace SM_TEST
PostProcessUtility.ResolveMultisampledBuffers(MainFramebuffer, _postBuffer); PostProcessUtility.ResolveMultisampledBuffers(MainFramebuffer, _postBuffer);
_bloom.Draw(context); //_bloom.Draw(context);
Framebuffer.Screen.Activate(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); Framebuffer.Screen.Activate(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
PostProcessUtility.FinalizeHDR(_postBuffer["color"], .5f); PostProcessUtility.FinalizeHDR(_postBuffer["color"], .5f);