From 09c100ff425435709addae2dda1b14a88f2e92e1 Mon Sep 17 00:00:00 2001 From: David Ludwig Date: Mon, 14 Aug 2017 12:48:36 -0400 Subject: [PATCH] partial fix for issue #16: color is incorrect on Linux Thousands of Colors mode is still broken, however, Millions of Colors does work, which did not before this commit. --- BasiliskII/src/SDL/video_sdl.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) mode change 100644 => 100755 BasiliskII/src/SDL/video_sdl.cpp diff --git a/BasiliskII/src/SDL/video_sdl.cpp b/BasiliskII/src/SDL/video_sdl.cpp old mode 100644 new mode 100755 index e4bf0d88..7655420d --- a/BasiliskII/src/SDL/video_sdl.cpp +++ b/BasiliskII/src/SDL/video_sdl.cpp @@ -769,8 +769,24 @@ static SDL_Surface * init_sdl_video(int width, int height, int bpp, Uint32 flags } if (!host_surface) { - host_surface = SDL_CreateRGBSurface(0, width, height, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000); + Uint32 texture_format; + if (SDL_QueryTexture(sdl_texture, &texture_format, NULL, NULL, NULL) != 0) { + printf("ERROR: Unable to get the SDL texture's pixel format: %s\n", SDL_GetError()); + shutdown_sdl_video(); + return NULL; + } + + int bpp; + Uint32 Rmask, Gmask, Bmask, Amask; + if (!SDL_PixelFormatEnumToMasks(texture_format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) { + printf("ERROR: Unable to determine format for host SDL_surface: %s\n", SDL_GetError()); + shutdown_sdl_video(); + return NULL; + } + + host_surface = SDL_CreateRGBSurface(0, width, height, bpp, Rmask, Gmask, Bmask, Amask); if (!host_surface) { + printf("ERROR: Unable to create host SDL_surface: %s\n", SDL_GetError()); shutdown_sdl_video(); return NULL; }