]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - palette.c
sv.edicts (and related things) are now dynamically reallocated as more edicts are...
[xonotic/darkplaces.git] / palette.c
index 1978eefe1fded65a6595b0cd1144141d8a51079a..1a481e3ffac671c45413a2683775200c6662d1d3 100644 (file)
--- a/palette.c
+++ b/palette.c
@@ -5,6 +5,7 @@ unsigned int palette_complete[256];
 unsigned int palette_nofullbrights[256];
 unsigned int palette_onlyfullbrights[256];
 unsigned int palette_nocolormapnofullbrights[256];
+unsigned int palette_nocolormap[256];
 unsigned int palette_pantsaswhite[256];
 unsigned int palette_shirtaswhite[256];
 unsigned int palette_alpha[256];
@@ -12,12 +13,6 @@ unsigned int palette_font[256];
 
 qbyte host_basepal[768];
 
-cvar_t v_gamma = {CVAR_SAVE, "v_gamma", "1"};
-cvar_t v_contrast = {CVAR_SAVE, "v_contrast", "1"};
-cvar_t v_brightness = {CVAR_SAVE, "v_brightness", "0"};
-cvar_t v_overbrightbits = {CVAR_SAVE, "v_overbrightbits", "0"};
-cvar_t v_hwgamma = {0, "v_hwgamma", "1"};
-
 void Palette_Setup8to24(void)
 {
        int i;
@@ -40,8 +35,8 @@ void Palette_Setup8to24(void)
        palette_complete[255] = 0; // completely transparent black
 
        // FIXME: fullbright_start should be read from colormap.lmp
-       colormap = COM_LoadFile("gfx/colormap.lmp", true);
-       if (colormap && com_filesize >= 16385)
+       colormap = FS_LoadFile("gfx/colormap.lmp", true);
+       if (colormap && fs_filesize >= 16385)
                fullbright_start = 256 - colormap[16384];
        else
                fullbright_start = 256;
@@ -77,6 +72,14 @@ void Palette_Setup8to24(void)
                palette_nocolormapnofullbrights[i] = palette_complete[0];
        palette_nocolormapnofullbrights[255] = 0;
 
+       for (i = 0;i < 256;i++)
+               palette_nocolormap[i] = palette_complete[i];
+       for (i = pants_start;i < pants_end;i++)
+               palette_nocolormap[i] = palette_complete[0];
+       for (i = shirt_start;i < shirt_end;i++)
+               palette_nocolormap[i] = palette_complete[0];
+       palette_nocolormap[255] = 0;
+
        for (i = 0;i < 256;i++)
                palette_pantsaswhite[i] = palette_complete[0];
        for (i = pants_start;i < pants_end;i++)
@@ -162,69 +165,13 @@ void BuildGammaTable16(float prescale, float gamma, float scale, float base, uns
        }
 }
 
-qboolean hardwaregammasupported = false;
-void VID_UpdateGamma(qboolean force)
-{
-       static float cachegamma = -1, cachebrightness = -1, cachecontrast = -1;
-       static int cacheoverbrightbits = -1, cachehwgamma = -1;
-
-       // LordHavoc: don't mess with gamma tables if running dedicated
-       if (cls.state == ca_dedicated)
-               return;
-
-       if (!force
-        && v_gamma.value == cachegamma
-        && v_contrast.value == cachecontrast
-        && v_brightness.value == cachebrightness
-        && v_overbrightbits.integer == cacheoverbrightbits
-        && v_hwgamma.value == cachehwgamma)
-               return;
-
-       if (v_gamma.value < 0.1)
-               Cvar_SetValue("v_gamma", 0.1);
-       if (v_gamma.value > 5.0)
-               Cvar_SetValue("v_gamma", 5.0);
-
-       if (v_contrast.value < 0.5)
-               Cvar_SetValue("v_contrast", 0.5);
-       if (v_contrast.value > 5.0)
-               Cvar_SetValue("v_contrast", 5.0);
-
-       if (v_brightness.value < 0)
-               Cvar_SetValue("v_brightness", 0);
-       if (v_brightness.value > 0.8)
-               Cvar_SetValue("v_brightness", 0.8);
-
-       cachegamma = v_gamma.value;
-       cachecontrast = v_contrast.value;
-       cachebrightness = v_brightness.value;
-       cacheoverbrightbits = v_overbrightbits.integer;
-
-       hardwaregammasupported = VID_SetGamma((float) (1 << cacheoverbrightbits), cachegamma, cachecontrast, cachebrightness);
-       if (!hardwaregammasupported)
-       {
-               Con_Printf("Hardware gamma not supported.\n");
-               Cvar_SetValue("v_hwgamma", 0);
-       }
-       cachehwgamma = v_hwgamma.integer;
-}
-
-void Gamma_Init(void)
-{
-       Cvar_RegisterVariable(&v_gamma);
-       Cvar_RegisterVariable(&v_brightness);
-       Cvar_RegisterVariable(&v_contrast);
-       Cvar_RegisterVariable(&v_hwgamma);
-       Cvar_RegisterVariable(&v_overbrightbits);
-}
-
 void Palette_Init(void)
 {
        int i;
        float gamma, scale, base;
        qbyte *pal;
        qbyte temp[256];
-       pal = (qbyte *)COM_LoadFile ("gfx/palette.lmp", false);
+       pal = (qbyte *)FS_LoadFile ("gfx/palette.lmp", false);
        if (!pal)
                Sys_Error ("Couldn't load gfx/palette.lmp");
        memcpy(host_basepal, pal, 765);