~rabbits/uxn

b5b3177c68b0a96a250dc700f950d48f8232b3e0 — Sevan Janiyan 1 year, 7 months ago 822a7fe
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.
1 files changed, 12 insertions(+), 1 deletions(-)

M src/uxnemu.c
M src/uxnemu.c => src/uxnemu.c +12 -1
@@ 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);