I’m wondering about the SDL_PIXELFORMAT_XBGR8888 pixel format of a window surface on macOS running on an M4.
When I SDL_GetWindowPixelFormat I get SDL_PIXELFORMAT_ARGB8888. Why are these two different? I would expect them to be the same.
Since M4 is little endian, this means
- SDL_PIXELFORMAT_ARGB8888 = SDL_PIXELFORMAT_BGRA32
- SDL_PIXELFORMAT_XBGR8888 = SDL_PIXELFORMAT_RGBX32
Most graphic libs use XRGB32 or PRGB32.
So, when I use such a library to draw into a SDL_surface, the colors are wrong.
What’s the best way to either avoid this pixelformat mess, or convert the pixels to SDL_PIXELFORMAT_XBGR8888 surface format just before updating the window?