Commit 5ea9886bcfabe2a421684d53917ff22f7f1bbcec

UnknownShadow200 2022-09-23T13:19:22

haiku: Fix when screen color depth was 24 bits, SDL_GetWindowSurface would always fail with 'Unknown pixel format' error Note that returning SDL_PIXELFORMAT_BGR24 instead of SDL_PIXELFORMAT_RGB24 seems necessary, otherwise when running with SDL_ACCELERATION=0, the red and blue channels of the window appeared swapped. Note that when running with acceleration enabled, red and blue channel swapping does not happen regardless of whether SDL_PIXEL_FORMAT_RGB24 or SDL_PIXEL_FORMAT_BGR24 is returned. For good measure, I also tested running with acceleration disabled in both 15 and 16 bit color depths, but red and blue channel swapping did not occur

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
diff --git a/src/video/haiku/SDL_bmodes.cc b/src/video/haiku/SDL_bmodes.cc
index 586e2a9..5e51647 100644
--- a/src/video/haiku/SDL_bmodes.cc
+++ b/src/video/haiku/SDL_bmodes.cc
@@ -148,6 +148,10 @@ int32 HAIKU_ColorSpaceToSDLPxFormat(uint32 colorspace)
     case B_RGB16_BIG:
         return SDL_PIXELFORMAT_RGB565;
         break;
+    case B_RGB24:
+    case B_RGB24_BIG:
+        return SDL_PIXELFORMAT_BGR24;
+        break;
     case B_RGB32:
     case B_RGBA32:
     case B_RGB32_BIG: