diff --git a/src/Backends/Rendering/OpenGL3.cpp b/src/Backends/Rendering/OpenGL3.cpp index 26af370d..397d325d 100644 --- a/src/Backends/Rendering/OpenGL3.cpp +++ b/src/Backends/Rendering/OpenGL3.cpp @@ -1075,14 +1075,6 @@ void RenderBackend_HandleWindowResize(size_t width, size_t height) upscaled_framebuffer_surface = NULL; } - if (upscale_factor != 1) - { - upscaled_framebuffer_surface = CreateSurface(upscaled_framebuffer_width, upscaled_framebuffer_height * upscale_factor, true); - - if (upscaled_framebuffer_surface == NULL) - Backend_PrintError("Couldn't regenerate upscaled framebuffer"); - } - // Create rect that forces 4:3 no matter what size the window is if (width * upscaled_framebuffer_height >= upscaled_framebuffer_width * height) // Fancy way to do `if (width / height >= upscaled_framebuffer->width / upscaled_framebuffer->height)` without floats { @@ -1102,4 +1094,12 @@ void RenderBackend_HandleWindowResize(size_t width, size_t height) window_surface.width = width; window_surface.height = height; + + if ((window_rect.right - window_rect.left) % framebuffer_surface->width != 0 || (window_rect.bottom - window_rect.top) % framebuffer_surface->height != 0) + { + upscaled_framebuffer_surface = CreateSurface(upscaled_framebuffer_width, upscaled_framebuffer_height * upscale_factor, true); + + if (upscaled_framebuffer_surface == NULL) + Backend_PrintError("Couldn't regenerate upscaled framebuffer"); + } } diff --git a/src/Backends/Rendering/SDLTexture.cpp b/src/Backends/Rendering/SDLTexture.cpp index d85ab086..4995e50d 100644 --- a/src/Backends/Rendering/SDLTexture.cpp +++ b/src/Backends/Rendering/SDLTexture.cpp @@ -430,18 +430,6 @@ void RenderBackend_HandleWindowResize(size_t width, size_t height) upscaled_framebuffer.texture = NULL; } - if (upscale_factor != 1) - { - SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"); - upscaled_framebuffer.texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA32, SDL_TEXTUREACCESS_TARGET, upscaled_framebuffer.width, upscaled_framebuffer.height); - SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "nearest"); - - if (upscaled_framebuffer.texture == NULL) - Backend_PrintError("Couldn't regenerate upscaled framebuffer"); - - SDL_SetTextureBlendMode(upscaled_framebuffer.texture, SDL_BLENDMODE_NONE); - } - // Create rect that forces 4:3 no matter what size the window is if (width * upscaled_framebuffer.height >= upscaled_framebuffer.width * height) // Fancy way to do `if (width / height >= upscaled_framebuffer.width / upscaled_framebuffer.height)` without floats { @@ -456,4 +444,16 @@ void RenderBackend_HandleWindowResize(size_t width, size_t height) window_rect.x = (width - window_rect.w) / 2; window_rect.y = (height - window_rect.h) / 2; + + if (window_rect.w % framebuffer.width != 0 || window_rect.h % framebuffer.height != 0) + { + SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"); + upscaled_framebuffer.texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA32, SDL_TEXTUREACCESS_TARGET, upscaled_framebuffer.width, upscaled_framebuffer.height); + SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "nearest"); + + if (upscaled_framebuffer.texture == NULL) + Backend_PrintError("Couldn't regenerate upscaled framebuffer"); + + SDL_SetTextureBlendMode(upscaled_framebuffer.texture, SDL_BLENDMODE_NONE); + } }