commit b5b3177c68b0a96a250dc700f950d48f8232b3e0
parent 822a7fea5454e3394202bbe7a4d6a00627540cea
Author: Sevan Janiyan <venture37@geeklan.co.uk>
Date: Mon, 15 May 2023 03:08:59 +0100
Switch to using SDL_CreateRGBSurface() SDL_CreateRGBSurfaceWithFormat() was introduced in SDL 2.0.5 whereas SDL_CreateRGBSurface() is available since SDL 2.0. This allows uxn to run on legacy systems where it's not possible to reach SDL 2.0.5 but prior versions are, such as Mac OS X Tiger.
Diffstat:
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/uxnemu.c b/src/uxnemu.c
@@ -273,12 +273,23 @@ static void
capture_screen(void)
{
const Uint32 format = SDL_PIXELFORMAT_RGB24;
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
+ /* SDL_PIXELFORMAT_RGB24 */
+ Uint32 Rmask = 0x000000FF;
+ Uint32 Gmask = 0x0000FF00;
+ Uint32 Bmask = 0x00FF0000;
+#else
+ /* SDL_PIXELFORMAT_BGR24 */
+ Uint32 Rmask = 0x00FF0000;
+ Uint32 Gmask = 0x0000FF00;
+ Uint32 Bmask = 0x000000FF;
+#endif
time_t t = time(NULL);
char fname[64];
int w, h;
SDL_Surface *surface;
SDL_GetRendererOutputSize(gRenderer, &w, &h);
- surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 24, format);
+ surface = SDL_CreateRGBSurface(0, w, h, 24, Rmask, Gmask, Bmask, 0);
SDL_RenderReadPixels(gRenderer, NULL, format, surface->pixels, surface->pitch);
strftime(fname, sizeof(fname), "screenshot-%Y%m%d-%H%M%S.bmp", localtime(&t));
SDL_SaveBMP(surface, fname);