From be17ba904475e2fc1019b129f9bca56882b3aae7 Mon Sep 17 00:00:00 2001 From: kanjitalk755 Date: Fri, 18 Sep 2020 10:29:16 +0900 Subject: [PATCH] save initial gamma tables change default gammaramp to off --- BasiliskII/src/SDL/video_sdl2.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/BasiliskII/src/SDL/video_sdl2.cpp b/BasiliskII/src/SDL/video_sdl2.cpp index 0a5f69b4..ba724a08 100644 --- a/BasiliskII/src/SDL/video_sdl2.cpp +++ b/BasiliskII/src/SDL/video_sdl2.cpp @@ -168,6 +168,12 @@ static SDL_mutex *frame_buffer_lock = NULL; #define LOCK_FRAME_BUFFER SDL_LockMutex(frame_buffer_lock) #define UNLOCK_FRAME_BUFFER SDL_UnlockMutex(frame_buffer_lock) +// Initially set gamma tables +static uint16 init_gamma_red[256]; +static uint16 init_gamma_green[256]; +static uint16 init_gamma_blue[256]; +static bool init_gamma_valid; + // Previously set gamma tables static uint16 last_gamma_red[256]; static uint16 last_gamma_green[256]; @@ -1624,19 +1630,20 @@ void VideoQuitFullScreen(void) static void ApplyGammaRamp() { if (sdl_window) { int result; + if (!init_gamma_valid) { + result = SDL_GetWindowGammaRamp(sdl_window, init_gamma_red, init_gamma_green, init_gamma_blue); + if (result < 0) + fprintf(stderr, "SDL_GetWindowGammaRamp returned %d, SDL error: %s\n", result, SDL_GetError()); + init_gamma_valid = true; + } const char *s = PrefsFindString("gammaramp"); - if (!s) s = "on"; + if (!s) s = "off"; if (strcmp(s, "off") && (strcmp(s, "fullscreen") || display_type == DISPLAY_SCREEN)) result = SDL_SetWindowGammaRamp(sdl_window, last_gamma_red, last_gamma_green, last_gamma_blue); - else { - Uint16 ident[256]; - for (int i = 0; i < 256; i++) - ident[i] = (i << 8) | i; - result = SDL_SetWindowGammaRamp(sdl_window, ident, ident, ident); - } - if (result < 0) { + else + result = SDL_SetWindowGammaRamp(sdl_window, init_gamma_red, init_gamma_green, init_gamma_blue); + if (result < 0) fprintf(stderr, "SDL_SetWindowGammaRamp returned %d, SDL error: %s\n", result, SDL_GetError()); - } } }