From a9c9e54f9c6b3f9b43e29b79bd997b9433b997db Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 6 Nov 2025 11:20:30 -0800
Subject: [PATCH] Clarified why GetPixelFormatForMasks() is needed in
ConvertSurface()
---
src/sdl2_compat.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c
index 9ac4cca..acc72cc 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -4246,6 +4246,8 @@ SDL_ConvertSurface(SDL2_Surface *surface, const SDL2_PixelFormat *format, Uint32
return NULL;
}
+ // SDL2 only relied on the bpp and masks, and Dwarf Fortress doesn't fill out the format field,
+ // so we'll always look up the pixel format from the masks here.
pixel_format = SDL3_GetPixelFormatForMasks(format->BitsPerPixel, format->Rmask, format->Gmask, format->Bmask, format->Amask);
if (pixel_format == SDL_PIXELFORMAT_UNKNOWN) {
SDL3_InvalidParamError("format");