From b1ad7b5ba3cef7826196aa81be0c03fe433591f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20L=C3=BCbe=C3=9F?= Date: Mon, 19 Jul 2021 20:06:37 +0200 Subject: [PATCH] Added single stepping --- GlitchyEngine/src/Application.bf | 39 ++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/GlitchyEngine/src/Application.bf b/GlitchyEngine/src/Application.bf index 7067c60..ace9eba 100644 --- a/GlitchyEngine/src/Application.bf +++ b/GlitchyEngine/src/Application.bf @@ -66,23 +66,48 @@ namespace GlitchyEngine break; } } + +#if APP_SINGLESTEP + bool allowFrame = false; + bool disableSingleFrame = false; +#else + const bool allowFrame = true; +#endif public void Run() { while(_running) { - _gameTime.NewFrame(); + if(allowFrame) + { + _gameTime.NewFrame(); + } Input.NewFrame(); + +#if APP_SINGLESTEP + allowFrame = disableSingleFrame || Input.IsKeyPressing(Key.F10); - for(Layer layer in _layerStack) - layer.Update(_gameTime); + if(Input.IsKeyPressing(Key.F11)) + { + disableSingleFrame = !disableSingleFrame; + } +#endif + + if(allowFrame) + { + for(Layer layer in _layerStack) + layer.Update(_gameTime); + } _window.Update(); - - _imGuiLayer.ImGuiRender(); - - _window.Context.SwapChain.Present(); + + if(allowFrame) + { + _imGuiLayer.ImGuiRender(); + + _window.Context.SwapChain.Present(); + } } }