Fix upscaled framebuffer skipping
Skipping it an 1x is wrong: it should only be skipped if the window is an integer multiple of the framebuffer size
This commit is contained in:
parent
f2c0f94e42
commit
5c1012aa8e
2 changed files with 20 additions and 20 deletions
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue