From 5ea9886bcfabe2a421684d53917ff22f7f1bbcec Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Fri, 23 Sep 2022 13:19:22 +1000 Subject: [PATCH] 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 --- src/video/haiku/SDL_bmodes.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/video/haiku/SDL_bmodes.cc b/src/video/haiku/SDL_bmodes.cc index 586e2a93b..5e51647ca 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: