- if (!force
- && !gamma_forcenextframe
- && !v_psycho.integer
- && cachehwgamma == (vid_activewindow ? v_hwgamma.integer : 0)
- && v_gamma.value == cachegamma
- && v_contrast.value == cachecontrast
- && v_brightness.value == cachebrightness
- && cachecolorenable == v_color_enable.integer
- && cacheblack[0] == v_color_black_r.value
- && cacheblack[1] == v_color_black_g.value
- && cacheblack[2] == v_color_black_b.value
- && cachegrey[0] == v_color_grey_r.value
- && cachegrey[1] == v_color_grey_g.value
- && cachegrey[2] == v_color_grey_b.value
- && cachewhite[0] == v_color_white_r.value
- && cachewhite[1] == v_color_white_g.value
- && cachewhite[2] == v_color_white_b.value)
+ wantgamma = (vid_activewindow ? v_hwgamma.integer : 0);
+#define BOUNDCVAR(cvar, m1, m2) c = &(cvar);f = bound(m1, c->value, m2);if (c->value != f) Cvar_SetValueQuick(c, f);
+ BOUNDCVAR(v_gamma, 0.1, 5);
+ BOUNDCVAR(v_contrast, 1, 5);
+ BOUNDCVAR(v_brightness, 0, 0.8);
+ BOUNDCVAR(v_color_black_r, 0, 0.8);
+ BOUNDCVAR(v_color_black_g, 0, 0.8);
+ BOUNDCVAR(v_color_black_b, 0, 0.8);
+ BOUNDCVAR(v_color_grey_r, 0, 0.95);
+ BOUNDCVAR(v_color_grey_g, 0, 0.95);
+ BOUNDCVAR(v_color_grey_b, 0, 0.95);
+ BOUNDCVAR(v_color_white_r, 1, 5);
+ BOUNDCVAR(v_color_white_g, 1, 5);
+ BOUNDCVAR(v_color_white_b, 1, 5);
+#undef BOUNDCVAR
+
+ if (force || v_psycho.integer)
+ gamma_forcenextframe = true;
+#define GAMMACHECK(cache, value) if (cache != (value)) gamma_forcenextframe = true;cache = (value)
+ GAMMACHECK(cachehwgamma , wantgamma);
+ GAMMACHECK(cachegamma , v_gamma.value);
+ GAMMACHECK(cachecontrast , v_contrast.value);
+ GAMMACHECK(cachebrightness , v_brightness.value);
+ GAMMACHECK(cachecolorenable, v_color_enable.integer);
+ GAMMACHECK(cacheblack[0] , v_color_black_r.value);
+ GAMMACHECK(cacheblack[1] , v_color_black_g.value);
+ GAMMACHECK(cacheblack[2] , v_color_black_b.value);
+ GAMMACHECK(cachegrey[0] , v_color_grey_r.value);
+ GAMMACHECK(cachegrey[1] , v_color_grey_g.value);
+ GAMMACHECK(cachegrey[2] , v_color_grey_b.value);
+ GAMMACHECK(cachewhite[0] , v_color_white_r.value);
+ GAMMACHECK(cachewhite[1] , v_color_white_g.value);
+ GAMMACHECK(cachewhite[2] , v_color_white_b.value);
+#undef GAMMACHECK
+
+ if (!gamma_forcenextframe)