Skip to content

Add Windows window live resize #201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 13, 2025
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