From cc64ab530cb6733108e52b0341371f8624d304ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Mon, 3 Apr 2023 17:09:50 +0300 Subject: [PATCH] Fix #19811: Use the correct SDL event for window resize handling --- src/openrct2-ui/UiContext.cpp | 5 +++-- .../drawing/engines/HardwareDisplayDrawingEngine.cpp | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/openrct2-ui/UiContext.cpp b/src/openrct2-ui/UiContext.cpp index 8831e26987..c774f38436 100644 --- a/src/openrct2-ui/UiContext.cpp +++ b/src/openrct2-ui/UiContext.cpp @@ -337,14 +337,15 @@ public: ContextQuit(); break; case SDL_WINDOWEVENT: - if (e.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) + if (e.window.event == SDL_WINDOWEVENT_RESIZED) { + LOG_VERBOSE("New Window size: %ux%u\n", e.window.data1, e.window.data2); OnResize(e.window.data1, e.window.data2); } switch (e.window.event) { - case SDL_WINDOWEVENT_SIZE_CHANGED: + case SDL_WINDOWEVENT_RESIZED: case SDL_WINDOWEVENT_MOVED: case SDL_WINDOWEVENT_MAXIMIZED: case SDL_WINDOWEVENT_RESTORED: diff --git a/src/openrct2-ui/drawing/engines/HardwareDisplayDrawingEngine.cpp b/src/openrct2-ui/drawing/engines/HardwareDisplayDrawingEngine.cpp index 1441e5a095..b29a2deb41 100644 --- a/src/openrct2-ui/drawing/engines/HardwareDisplayDrawingEngine.cpp +++ b/src/openrct2-ui/drawing/engines/HardwareDisplayDrawingEngine.cpp @@ -135,16 +135,22 @@ public: char scaleQualityBuffer[4]; snprintf(scaleQualityBuffer, sizeof(scaleQualityBuffer), "%d", static_cast(scaleQuality)); SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "0"); + _screenTexture = SDL_CreateTexture(_sdlRenderer, pixelFormat, SDL_TEXTUREACCESS_STREAMING, width, height); + Guard::Assert(_screenTexture != nullptr, "Failed to create screen texture: %s", SDL_GetError()); + SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, scaleQualityBuffer); uint32_t scale = std::ceil(gConfigGeneral.WindowScale); _scaledScreenTexture = SDL_CreateTexture( _sdlRenderer, pixelFormat, SDL_TEXTUREACCESS_TARGET, width * scale, height * scale); + + Guard::Assert(_scaledScreenTexture != nullptr, "Failed to create scaled screen texture: %s", SDL_GetError()); } else { _screenTexture = SDL_CreateTexture(_sdlRenderer, pixelFormat, SDL_TEXTUREACCESS_STREAMING, width, height); + Guard::Assert(_screenTexture != nullptr, "Failed to create screen texture: %s", SDL_GetError()); } uint32_t format;