Browse Source

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
Sam Lantinga 1 week ago
parent
commit
32668c4ddd
2 changed files with 5 additions and 7 deletions
  1. 1 2
      include/SDL3/SDL_render.h
  2. 4 5
      src/render/SDL_render.c

+ 1 - 2
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.

+ 4 - 5
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: