From 32668c4ddda9dee698a66513509cfa08da70f3eb Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 3 Oct 2025 14:29:47 -0700 Subject: [PATCH] Palettized textures will always use SDL_SCALEMODE_NEAREST. Our algorithm for pixel art doesn't work on 8-bit images, needs further investigation. Fixes https://github.com/libsdl-org/SDL/issues/14129 --- include/SDL3/SDL_render.h | 3 +-- src/render/SDL_render.c | 9 ++++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/include/SDL3/SDL_render.h b/include/SDL3/SDL_render.h index 23adec34b2..090e689b52 100644 --- a/include/SDL3/SDL_render.h +++ b/include/SDL3/SDL_render.h @@ -1234,8 +1234,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureBlendMode(SDL_Texture *texture, S * The default texture scale mode is SDL_SCALEMODE_LINEAR. * * If the scale mode is not supported, the closest supported mode is chosen. - * Palettized textures will use SDL_SCALEMODE_PIXELART instead of - * SDL_SCALEMODE_LINEAR. + * Palettized textures will always use SDL_SCALEMODE_NEAREST. * * \param texture the texture to update. * \param scaleMode the SDL_ScaleMode to use for texture scaling. diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index 513076f1ae..c53905e6ee 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -1525,9 +1525,8 @@ SDL_Texture *SDL_CreateTextureWithProperties(SDL_Renderer *renderer, SDL_Propert texture->color.b = 1.0f; texture->color.a = 1.0f; texture->blendMode = SDL_ISPIXELFORMAT_ALPHA(format) ? SDL_BLENDMODE_BLEND : SDL_BLENDMODE_NONE; - if (renderer->scale_mode == SDL_SCALEMODE_LINEAR && - SDL_ISPIXELFORMAT_INDEXED(format)) { - texture->scaleMode = SDL_SCALEMODE_PIXELART; + if (SDL_ISPIXELFORMAT_INDEXED(format)) { + texture->scaleMode = SDL_SCALEMODE_NEAREST; } else { texture->scaleMode = renderer->scale_mode; } @@ -2163,11 +2162,11 @@ bool SDL_SetTextureScaleMode(SDL_Texture *texture, SDL_ScaleMode scaleMode) switch (scaleMode) { case SDL_SCALEMODE_NEAREST: - case SDL_SCALEMODE_PIXELART: break; + case SDL_SCALEMODE_PIXELART: case SDL_SCALEMODE_LINEAR: if (SDL_ISPIXELFORMAT_INDEXED(texture->format)) { - scaleMode = SDL_SCALEMODE_PIXELART; + scaleMode = SDL_SCALEMODE_NEAREST; } break; default: