diff --git a/Source/Managers/WindowMan.cpp b/Source/Managers/WindowMan.cpp index 49fe98d19..b5997cd3b 100644 --- a/Source/Managers/WindowMan.cpp +++ b/Source/Managers/WindowMan.cpp @@ -1,7 +1,6 @@ #include "WindowMan.h" #include "RTEError.h" -#include "SDL3/SDL_error.h" -#include "SDL3/SDL_video.h" +#include "SDL3/SDL.h" #include "SettingsMan.h" #include "FrameMan.h" #include "ActivityMan.h" @@ -155,6 +154,8 @@ void WindowMan::Initialize() { } else { SetViewportLetterboxed(); } + + SDL_AddEventWatch((SDL_EventFilter)WindowMan::HandleWindowExposedEvent, nullptr); } void WindowMan::CreatePrimaryWindow() { @@ -674,6 +675,14 @@ void WindowMan::DisplaySwitchOut() const { SDL_SetCursor(nullptr); } +void WindowMan::HandleWindowExposedEvent(void *userdata, SDL_Event *event) { + if (event->type == SDL_EVENT_WINDOW_EXPOSED) { + g_WindowMan.SetViewportLetterboxed(); + g_WindowMan.ClearBackbuffer(false); + g_WindowMan.UploadFrame(); + } +} + void WindowMan::QueueWindowEvent(const SDL_Event& windowEvent) { m_EventQueue.emplace_back(windowEvent); } diff --git a/Source/Managers/WindowMan.h b/Source/Managers/WindowMan.h index 62b891117..3295c1ef4 100644 --- a/Source/Managers/WindowMan.h +++ b/Source/Managers/WindowMan.h @@ -168,6 +168,9 @@ namespace RTE { #pragma endregion #pragma region Concrete Methods + /// SDL_EventFilter to hadnle window exposed events for live resize. + static void HandleWindowExposedEvent(void* userdata, SDL_Event* event); + /// Adds an SDL_Event to the Event queue for processing on Update. /// @param windowEvent The SDL window event to queue. void QueueWindowEvent(const SDL_Event& windowEvent);