Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions Source/Managers/WindowMan.cpp
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -155,6 +154,8 @@ void WindowMan::Initialize() {
} else {
SetViewportLetterboxed();
}

SDL_AddEventWatch((SDL_EventFilter)WindowMan::HandleWindowExposedEvent, nullptr);
}

void WindowMan::CreatePrimaryWindow() {
Expand Down Expand Up @@ -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);
}
Expand Down
3 changes: 3 additions & 0 deletions Source/Managers/WindowMan.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down