From 46024124e35e01911cf818a731916c889c0e4abe Mon Sep 17 00:00:00 2001 From: Ben Date: Wed, 22 Sep 2021 01:31:50 +0100 Subject: [PATCH] imgui cleanup - still crashes on mod --- Aeon/Core/Display.cpp | 1 + Aeon/Input/Input.cpp | 5 ++--- Aeon/Rendering/ImGui.hpp | 7 +++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Aeon/Core/Display.cpp b/Aeon/Core/Display.cpp index 98de203..707cd68 100644 --- a/Aeon/Core/Display.cpp +++ b/Aeon/Core/Display.cpp @@ -113,6 +113,7 @@ void Display::EndFrame() void Display::Destroy() { + Aeon::Rendering::CleanupImGui(); SDL_DestroyWindow( mWindow ); // dangly balls mWindow = nullptr; diff --git a/Aeon/Input/Input.cpp b/Aeon/Input/Input.cpp index d9a1c90..755f602 100644 --- a/Aeon/Input/Input.cpp +++ b/Aeon/Input/Input.cpp @@ -37,9 +37,6 @@ void Input::PollInput() SDL_PumpEvents(); while ( SDL_PollEvent( &mEvent ) ) { - // Provide to non-event driven subsystem - ImGui_ImplSDL2_ProcessEvent( &mEvent ); - switch ( mEvent.type ) { case SDL_WINDOWEVENT: @@ -69,6 +66,8 @@ void Input::PollInput() mPollKeyboard(); } } + // Provide to non-event driven subsystem + ImGui_ImplSDL2_ProcessEvent( &mEvent ); } // just in case diff --git a/Aeon/Rendering/ImGui.hpp b/Aeon/Rendering/ImGui.hpp index 949f114..6bd40c3 100644 --- a/Aeon/Rendering/ImGui.hpp +++ b/Aeon/Rendering/ImGui.hpp @@ -26,6 +26,13 @@ inline void SetupImGui( const SDL_Window* window, const SDL_GLContext& context ) ImGui_ImplOpenGL3_Init( "#version 450" ); } +inline void CleanupImGui() +{ + ImGui_ImplOpenGL3_Shutdown(); + ImGui_ImplSDL2_Shutdown(); + ImGui::DestroyContext(); +} + } #endif