From 55c5c8eace4d69deac87bd81734991509c54af14 Mon Sep 17 00:00:00 2001 From: Andrei Drexler Date: Tue, 10 Sep 2024 01:11:11 +0200 Subject: [PATCH] Clamp gamma to 0.1 --- Quake/gl_vidsdl.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Quake/gl_vidsdl.c b/Quake/gl_vidsdl.c index 3898e6848..6731e6155 100644 --- a/Quake/gl_vidsdl.c +++ b/Quake/gl_vidsdl.c @@ -221,8 +221,24 @@ void VID_SetMouseCursor (mousecursor_t cursor) // //========================================================================== +#define MIN_GAMMA 0.1f + static int fsaa; +/* +================ +VID_Gamma_f -- called when gamma changes +================ +*/ +static void VID_Gamma_f (cvar_t *var) +{ + if (var->value < MIN_GAMMA) + { + Con_SafePrintf ("%s %g is too low, clamping to %g\n", var->name, var->value, MIN_GAMMA); + Cvar_SetValueQuick (var, MIN_GAMMA); + } +} + /* ================ VID_Gamma_Init -- call on init @@ -231,6 +247,7 @@ VID_Gamma_Init -- call on init static void VID_Gamma_Init (void) { Cvar_RegisterVariable (&vid_gamma); + Cvar_SetCallback (&vid_gamma, VID_Gamma_f); Cvar_RegisterVariable (&vid_contrast); }