From fec58fc8f6b41f76c3f60a3747e0b6bd069f2701 Mon Sep 17 00:00:00 2001 From: Aki Date: Sat, 24 Dec 2022 01:56:44 +0100 Subject: Session now holds previous scene until end of frame This allows any ongoing function to end, be it draw or update, and allows to call session->set() from within them to change the scene. --- kurator/src/Session.cpp | 3 +++ kurator/src/Session.h | 1 + 2 files changed, 4 insertions(+) diff --git a/kurator/src/Session.cpp b/kurator/src/Session.cpp index 0d55eb3..1d1d513 100644 --- a/kurator/src/Session.cpp +++ b/kurator/src/Session.cpp @@ -15,6 +15,7 @@ namespace kurator void Session::set(std::shared_ptr _scene) { + previous_scene = scene; scene = _scene; } @@ -31,6 +32,8 @@ Session::run() scene->draw(); rlImGuiEnd(); EndDrawing(); + if (previous_scene) + previous_scene.reset(); } } diff --git a/kurator/src/Session.h b/kurator/src/Session.h index 4bb55cf..59aa597 100644 --- a/kurator/src/Session.h +++ b/kurator/src/Session.h @@ -20,6 +20,7 @@ private: bool keep_going = true; Window window; std::shared_ptr scene; + std::shared_ptr previous_scene; }; -- cgit v1.1