From 587384756fd922fe570438efa05133ddded2cd5c Mon Sep 17 00:00:00 2001 From: Marcin Serwin Date: Sun, 17 Nov 2024 20:31:07 +0100 Subject: [PATCH] render: use nearest pixel scaling for debug text The debug text font is less legible when scaled linearly. --- src/render/SDL_render.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index 7ca325a9b..93d3aee46 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -5406,10 +5406,14 @@ static bool CreateDebugTextAtlas(SDL_Renderer *renderer) SDL_assert((row < rows) || ((row == rows) && (column == 0))); // make sure we didn't overflow the surface. // Convert temp surface into texture - renderer->debug_char_texture_atlas = SDL_CreateTextureFromSurface(renderer, atlas); + SDL_Texture *texture = SDL_CreateTextureFromSurface(renderer, atlas); + if (texture) { + SDL_SetTextureScaleMode(texture, SDL_SCALEMODE_NEAREST); + renderer->debug_char_texture_atlas = texture; + } SDL_DestroySurface(atlas); - return (renderer->debug_char_texture_atlas != NULL); + return texture != NULL; } static bool DrawDebugCharacter(SDL_Renderer *renderer, float x, float y, Uint32 c)