diff --git a/BasiliskII/src/SDL/video_sdl2.cpp b/BasiliskII/src/SDL/video_sdl2.cpp index daa76a6e..fb7d27f6 100644 --- a/BasiliskII/src/SDL/video_sdl2.cpp +++ b/BasiliskII/src/SDL/video_sdl2.cpp @@ -1618,6 +1618,25 @@ void VideoQuitFullScreen(void) quit_full_screen = true; } +static void ApplyGammaRamp() { + if (sdl_window) { + int result; + const char *s = PrefsFindString("gammaramp"); + if (!s) s = "on"; + 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) { + fprintf(stderr, "SDL_SetWindowGammaRamp returned %d, SDL error: %s\n", result, SDL_GetError()); + } + } +} + static void do_toggle_fullscreen(void) { #ifndef USE_CPU_EMUL_SERVICES @@ -1654,6 +1673,7 @@ static void do_toggle_fullscreen(void) #ifdef SHEEPSHAVER video_set_palette(); #endif + ApplyGammaRamp(); drv->update_palette(); // reset the video refresh handler @@ -1795,16 +1815,11 @@ void SDL_monitor_desc::set_palette(uint8 *pal, int num_in) memcmp(green, last_gamma_green, 512) != 0 || memcmp(blue, last_gamma_blue, 512) != 0); - if (changed && sdl_window) { - int result = SDL_SetWindowGammaRamp(sdl_window, red, green, blue); - - if (result < 0) { - fprintf(stderr, "SDL_SetWindowGammaRamp returned %d, SDL error: %s\n", result, SDL_GetError()); - } - + if (changed) { memcpy(last_gamma_red, red, 512); memcpy(last_gamma_green, green, 512); memcpy(last_gamma_blue, blue, 512); + ApplyGammaRamp(); } return; diff --git a/BasiliskII/src/prefs_items.cpp b/BasiliskII/src/prefs_items.cpp index 7039a5e5..d6e531f8 100644 --- a/BasiliskII/src/prefs_items.cpp +++ b/BasiliskII/src/prefs_items.cpp @@ -78,6 +78,7 @@ prefs_desc common_prefs_items[] = { {"yearofs", TYPE_INT32, 0, "year offset"}, {"dayofs", TYPE_INT32, 0, "day offset"}, {"mag_rate", TYPE_INT32, 0, "rate of magnification"}, + {"gammaramp", TYPE_STRING, false, "gamma ramp (on, off or fullscreen)"}, {NULL, TYPE_END, false, NULL} // End of list }; diff --git a/SheepShaver/src/prefs_items.cpp b/SheepShaver/src/prefs_items.cpp index f3055976..5897affa 100644 --- a/SheepShaver/src/prefs_items.cpp +++ b/SheepShaver/src/prefs_items.cpp @@ -66,6 +66,7 @@ prefs_desc common_prefs_items[] = { {"yearofs", TYPE_INT32, 0, "year offset"}, {"dayofs", TYPE_INT32, 0, "day offset"}, {"mag_rate", TYPE_INT32, 0, "rate of magnification"}, + {"gammaramp", TYPE_STRING, false, "gamma ramp (on, off or fullscreen)"}, {NULL, TYPE_END, false, NULL} // End of list };