From 5bc97393aee4124b00db3ab4fbe8d6e26ba88069 Mon Sep 17 00:00:00 2001 From: salmonik Date: Wed, 4 Nov 2026 14:07:49 +0100 Subject: Gamma: clamp slider to the engine's 2.6 cap, defer readback The engine clamps mat_monitorgamma at 2.6, so the 2.8..3.0 end of the slider did nothing. Read the value back one tick later (ClientCmd is queued) and interpose SDL_SetWindowGammaRamp to see whether the engine pushes a ramp at all. --- src/gui.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'src/gui.cpp') diff --git a/src/gui.cpp b/src/gui.cpp index 88e5521..e8bcac7 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -419,8 +419,9 @@ static void build_cards() { "Weapon model field of view (20-120; stock 54).", 20, 120, &g_fov_viewmodel); add_slider(view, "Gamma x10", - "mat_monitorgamma x10: 16 = 1.6, 30 = 3.0, stock is 22.", 16, 30, - &g_gamma); + "mat_monitorgamma x10: 16 = 1.6, 26 = 2.6 (engine max), stock " + "is 22.", + 16, 26, &g_gamma); add_card(2, &g_fullbright, "Fullbright", "Ignore world lighting so dark areas are visible.", true); @@ -2240,6 +2241,28 @@ SDL_WarpMouseGlobal(int x, int y) { real_warp_global(x, y); } +// Diagnostic: tell whether mat_monitorgamma reaches the SDL gamma ramp at all. +static int (*real_set_gamma_ramp)(void *, const unsigned short *, + const unsigned short *, + const unsigned short *) = nullptr; + +extern "C" __attribute__((visibility("default"))) int +SDL_SetWindowGammaRamp(void *window, const unsigned short *r, + const unsigned short *g, const unsigned short *b) { + if (!real_set_gamma_ramp) + real_set_gamma_ramp = (int (*)(void *, const unsigned short *, + const unsigned short *, + const unsigned short *))dlsym( + RTLD_NEXT, "SDL_SetWindowGammaRamp"); + static int logs = 0; + if (logs < 12) { + logs++; + logf("gamma: SDL_SetWindowGammaRamp mid=%u/%u/%u", r ? r[128] : 0, + g ? g[128] : 0, b ? b[128] : 0); + } + return real_set_gamma_ramp ? real_set_gamma_ramp(window, r, g, b) : -1; +} + static unsigned int (*real_get_rel_mouse)(int *, int *) = nullptr; static int (*real_poll_event)(void *) = nullptr; -- cgit v1.2.3