]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
added variable vid_gammatables_trivial that is true if the gamma ramp is the identity...
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 29 Jan 2008 12:41:02 +0000 (12:41 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 29 Jan 2008 12:41:02 +0000 (12:41 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8044 d7cf8633-e32d-0410-b094-e92efae38249

vid.h
vid_shared.c

diff --git a/vid.h b/vid.h
index 9ba33da5c2fa8bc0e762aecf4a21b9cb3cd3b524..29ab8785fb127aad24269b9aba2e453a8dba14c6 100644 (file)
--- a/vid.h
+++ b/vid.h
@@ -148,7 +148,8 @@ void VID_Restart_f(void);
 
 void VID_Start(void);
 
-extern unsigned int vid_gammaramps_serial; // so other subsystems can poll if gamma parameters have changed; this starts with 0 and gets increased by 1 each time the gamma parameters get changed and VID_BuildGammaTables should be called again
+extern unsigned int vid_gammatables_serial; // so other subsystems can poll if gamma parameters have changed; this starts with 0 and gets increased by 1 each time the gamma parameters get changed and VID_BuildGammaTables should be called again
+extern qboolean vid_gammatables_trivial; // this is set to true if all color control values are at default setting, and it therefore would make no sense to use the gamma table
 void VID_BuildGammaTables(unsigned short *ramps, int rampsize); // builds the current gamma tables into an array (needs 3*rampsize items)
 #endif
 
index f67bb2d3c24424fa96b688d67868fa2d839fbbb0..a11cfc32e1f6640051eeb9b1a32bcb83463f61c7 100644 (file)
@@ -825,7 +825,8 @@ static int gamma_forcenextframe = false;
 static float cachegamma, cachebrightness, cachecontrast, cacheblack[3], cachegrey[3], cachewhite[3], cachecontrastboost;
 static int cachecolorenable, cachehwgamma;
 
-unsigned int vid_gammaramps_serial = 0; // so other subsystems can poll if gamma parameters have changed
+unsigned int vid_gammatables_serial = 0; // so other subsystems can poll if gamma parameters have changed
+qboolean vid_gammatables_trivial = true;
 void VID_BuildGammaTables(unsigned short *ramps, int rampsize)
 {
        if (cachecolorenable)
@@ -909,6 +910,31 @@ void VID_UpdateGamma(qboolean force, int rampsize)
        BOUNDCVAR(v_color_white_b, 1, 5);
 #undef BOUNDCVAR
 
+       // set vid_gammatables_trivial to true if the current settings would generate the identity gamma table
+       vid_gammatables_trivial = false;
+       if(v_color_enable.integer)
+       {
+               if(v_contrastboost.value == 1)
+               if(v_color_black_r.value == 0)
+               if(v_color_black_g.value == 0)
+               if(v_color_black_b.value == 0)
+               if(fabs(v_color_grey_r.value - 0.5) < 1e-6)
+               if(fabs(v_color_grey_g.value - 0.5) < 1e-6)
+               if(fabs(v_color_grey_b.value - 0.5) < 1e-6)
+               if(v_color_white_r.value == 1)
+               if(v_color_white_g.value == 1)
+               if(v_color_white_b.value == 1)
+                       vid_gammatables_trivial = true;
+       }
+       else
+       {
+               if(v_contrastboost.value == 1)
+               if(v_gamma.value == 1)
+               if(v_contrast.value == 1)
+               if(v_brightness.value == 0)
+                       vid_gammatables_trivial = true;
+       }
+
 #define GAMMACHECK(cache, value) if (cache != (value)) gamma_changed = true;cache = (value)
        if(v_psycho.integer)
                gamma_changed = true;
@@ -928,7 +954,7 @@ void VID_UpdateGamma(qboolean force, int rampsize)
        GAMMACHECK(cachewhite[2]   , v_color_white_b.value);
 
        if(gamma_changed)
-               ++vid_gammaramps_serial;
+               ++vid_gammatables_serial;
 
        GAMMACHECK(cachehwgamma    , wantgamma);
 #undef GAMMACHECK