]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - vid_shared.c
Removed the gray-out behavior on the gamma settings in the color control menu when...
[xonotic/darkplaces.git] / vid_shared.c
index 7c321c2aa94819089e4898e017747fe06b42c85c..843707b48f7b9ba2f9ea03cd7ca4b62fdad2d620 100644 (file)
@@ -1095,6 +1095,9 @@ void VID_CheckExtensions(void)
        vid.support.ext_texture_edge_clamp = GL_CheckExtension("GL_EXT_texture_edge_clamp", NULL, "-noedgeclamp", false) || GL_CheckExtension("GL_SGIS_texture_edge_clamp", NULL, "-noedgeclamp", false);
        vid.support.ext_texture_filter_anisotropic = GL_CheckExtension("GL_EXT_texture_filter_anisotropic", NULL, "-noanisotropy", false);
        vid.support.ext_texture_srgb = GL_CheckExtension("GL_EXT_texture_sRGB", NULL, "-nosrgb", false);
+       vid.support.arb_texture_float = GL_CheckExtension("GL_ARB_texture_float", NULL, "-notexturefloat", false);
+       vid.support.arb_half_float_pixel = GL_CheckExtension("GL_ARB_half_float_pixel", NULL, "-nohalffloatpixel", false);
+       vid.support.arb_half_float_vertex = GL_CheckExtension("GL_ARB_half_float_vertex", NULL, "-nohalffloatvertex", false);
        vid.support.arb_multisample = GL_CheckExtension("GL_ARB_multisample", multisamplefuncs, "-nomultisample", false);
        vid.allowalphatocoverage = false;
 
@@ -1227,14 +1230,14 @@ void VID_CheckExtensions(void)
 }
 #endif
 
-float VID_JoyState_GetAxis(const vid_joystate_t *joystate, int axis, float sensitivity, float deadzone)
+float VID_JoyState_GetAxis(const vid_joystate_t *joystate, int axis, float fsensitivity, float deadzone)
 {
        float value;
        value = (axis >= 0 && axis < MAXJOYAXIS) ? joystate->axis[axis] : 0.0f;
        value = value > deadzone ? (value - deadzone) : (value < -deadzone ? (value + deadzone) : 0.0f);
        value *= deadzone > 0 ? (1.0f / (1.0f - deadzone)) : 1.0f;
        value = bound(-1, value, 1);
-       return value * sensitivity;
+       return value * fsensitivity;
 }
 
 qboolean VID_JoyBlockEmulatedKeys(int keycode)
@@ -1473,6 +1476,21 @@ static int gamma_forcenextframe = false;
 static float cachegamma, cachebrightness, cachecontrast, cacheblack[3], cachegrey[3], cachewhite[3], cachecontrastboost;
 static int cachecolorenable, cachehwgamma;
 
+void VID_ApplyGammaToColor(const float *rgb, float *out)
+{
+       int i;
+       if (cachecolorenable)
+       {
+               for (i = 0; i < 3; i++)
+                       out[i] = pow(cachecontrastboost * rgb[i] / ((cachecontrastboost - 1) * rgb[i] + 1), 1.0 / invpow(0.5, 1 - cachegrey[i])) * cachewhite[i] + cacheblack[i];
+       }
+       else
+       {
+               for (i = 0; i < 3; i++)
+                       out[i] = pow(cachecontrastboost * rgb[i] / ((cachecontrastboost - 1) * rgb[i] + 1), 1.0 / cachegamma) * cachecontrast + cachebrightness;
+       }
+}
+
 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)