From 234c66af7364d2a5858905511428501612c50424 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Tue, 1 Apr 2025 09:35:01 -0700
Subject: [PATCH] SDL_SetWindowGammaRamp() is not supported in SDL3
Don't pretend that it does or applications might try to use it, assuming that they can set the brightness on the display.
Fixes https://github.com/libsdl-org/sdl2-compat/issues/445
---
src/sdl2_compat.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c
index 5efee97..a683831 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -4020,14 +4020,16 @@ SDL_CalculateGammaRamp(float gamma, Uint16 *ramp)
SDL_DECLSPEC int SDLCALL
SDL_SetWindowGammaRamp(SDL_Window *window, const Uint16 *r, const Uint16 *g, const Uint16 *b)
{
- Uint16 *gamma;
-
if (!window) {
SDL3_SetError("Invalid window");
return -1;
}
- gamma = (Uint16 *)SDL3_GetPointerProperty(SDL3_GetWindowProperties(window), PROP_WINDOW_GAMMA_RAMP, NULL);
+ SDL3_Unsupported();
+ return -1;
+
+#if 0 /* Leaving this code here in case we need it for a compatibility quirk */
+ Uint16 *gamma = (Uint16 *)SDL3_GetPointerProperty(SDL3_GetWindowProperties(window), PROP_WINDOW_GAMMA_RAMP, NULL);
if (!gamma) {
if (SDL_GetWindowGammaRamp(window, NULL, NULL, NULL) < 0) {
return -1;
@@ -4045,6 +4047,7 @@ SDL_SetWindowGammaRamp(SDL_Window *window, const Uint16 *r, const Uint16 *g, con
SDL_memcpy(&gamma[2*256], b, 256*sizeof(Uint16));
}
return 0;
+#endif
}
static void SDLCALL CleanupFreeableProperty(void *userdata, void *value)