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
main
UnknownShadow200 2022-09-23 13:19:22 +10:00 committed by Sam Lantinga
parent 51fefd1c35
commit 5ea9886bcf
1 changed files with 4 additions and 0 deletions

View File

@ -148,6 +148,10 @@ int32 HAIKU_ColorSpaceToSDLPxFormat(uint32 colorspace)
case B_RGB16_BIG: case B_RGB16_BIG:
return SDL_PIXELFORMAT_RGB565; return SDL_PIXELFORMAT_RGB565;
break; break;
case B_RGB24:
case B_RGB24_BIG:
return SDL_PIXELFORMAT_BGR24;
break;
case B_RGB32: case B_RGB32:
case B_RGBA32: case B_RGBA32:
case B_RGB32_BIG: case B_RGB32_BIG: