]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - vid_shared.c
moved ixtable definition and initialization code to mathlib (and added Mathlib_Init...
[xonotic/darkplaces.git] / vid_shared.c
index 0654fe1575ebaa4440f524a2f0352c64fd760275..8852c35942bcd4c3e9948ee0154d76b8c9256d66 100644 (file)
 
 #include "quakedef.h"
 
-unsigned       d_8to24table[256];
-unsigned char d_15to8table[32768]; // LordHavoc: was 64k elements, now 32k like it should be
-
-void   VID_SetPalette (unsigned char *palette)
-{
-       byte    *out;
-       unsigned short i;
-
-       out = (byte *) d_8to24table; // d_8to24table is accessed as 32bit for speed reasons, but is created as 8bit bytes
-       for (i=0 ; i<255 ; i++)
-       {
-               *out++ = *palette++;
-               *out++ = *palette++;
-               *out++ = *palette++;
-               *out++ = 255;
-       }
-       d_8to24table[255] = 0;
-}
-
-void   VID_Setup15to8Palette ()
+// LordHavoc: these are only set in wgl
+qboolean isG200 = false; // LordHavoc: the Matrox G200 can't do per pixel alpha, and it uses a D3D driver for GL... ugh...
+qboolean isRagePro = false; // LordHavoc: the ATI Rage Pro has limitations with per pixel alpha (the color scaler does not apply to per pixel alpha images...), although not as bad as a G200.
+
+// LordHavoc: compiled vertex array support
+qboolean gl_supportslockarrays = false;
+// LordHavoc: ARB multitexture support
+qboolean gl_mtexable = false;
+int gl_mtex_enum = 0;
+
+cvar_t vid_mode = {0, "vid_mode", "0"};
+cvar_t vid_mouse = {CVAR_SAVE, "vid_mouse", "1"};
+cvar_t vid_fullscreen = {0, "vid_fullscreen", "1"};
+
+void (GLAPIENTRY *qglMTexCoord2f) (GLenum, GLfloat, GLfloat);
+void (GLAPIENTRY *qglSelectTexture) (GLenum);
+void (GLAPIENTRY *qglLockArraysEXT) (GLint first, GLint count);
+void (GLAPIENTRY *qglUnlockArraysEXT) (void);
+
+void Force_CenterView_f (void)
 {
-       byte    *pal;
-       unsigned r,g,b;
-       unsigned v;
-       int     r1,g1,b1;
-       int             j,k,l;
-       unsigned short i;
-
-       // JACK: 3D distance calcs - k is last closest, l is the distance.
-       // FIXME: Precalculate this and cache to disk.
-       for (i = 0;i < 32768;i++)
-       {
-               /* Maps
-                       000000000000000
-                       000000000011111 = Red  = 0x001F
-                       000001111100000 = Blue = 0x03E0
-                       111110000000000 = Grn  = 0x7C00
-               */
-               r = ((i & 0x001F) << 3)+4;
-               g = ((i & 0x03E0) >> 2)+4;
-               b = ((i & 0x7C00) >> 7)+4;
-               pal = (unsigned char *)d_8to24table;
-               for (v = 0, k = 0, l = 1000000000;v < 256;v++, pal += 4)
-               {
-                       r1 = r - pal[0];
-                       g1 = g - pal[1];
-                       b1 = b - pal[2];
-                       j = (r1*r1*2)+(g1*g1*3)+(b1*b1); // LordHavoc: weighting to tune for human eye (added *2 and *3)
-                       if (j < l)
-                       {
-                               k = v;
-                               l = j;
-                       }
-               }
-               d_15to8table[i] = k;
-       }
+       cl.viewangles[PITCH] = 0;
 }
 
-// LordHavoc: gamma correction does not belong in gl_vidnt.c
-byte gamma[256];
-static float vid_gamma = 1.0;
-
-void Check_Gamma (unsigned char *pal)
+void VID_InitCvars(void)
 {
-       float   inf;
-       int             i;
-
-       if (i = COM_CheckParm("-gamma"))
-               vid_gamma = atof(com_argv[i+1]);
-       else
-       {
-//             if ((gl_renderer && strstr(gl_renderer, "Voodoo")) ||
-//                     (gl_vendor && strstr(gl_vendor, "3Dfx")))
-                       vid_gamma = 1;
-//             else if (gl_vendor && strstr(gl_vendor, "ATI"))
-//                     vid_gamma = 1;
-//             else
-//                     vid_gamma = 0.7;
-       }
-
-       if (vid_gamma == 1) // LordHavoc: dodge the math
-       {
-               for (i = 0;i < 256;i++)
-                       gamma[i] = i;
-       }
-       else
-       {
-               for (i = 0;i < 256;i++)
-               {
-                       inf = pow((i+1)/256.0, vid_gamma)*255 + 0.5;
-                       if (inf < 0) inf = 0;
-                       if (inf > 255) inf = 255;
-                       gamma[i] = inf;
-               }
-       }
-
-       // gamma correct the palette
-       for (i=0 ; i<768 ; i++)
-               pal[i] = gamma[pal[i]];
-       // note: 32bit uploads are corrected by the upload functions
+       Cvar_RegisterVariable(&vid_mode);
+       Cvar_RegisterVariable(&vid_mouse);
+       Cvar_RegisterVariable(&vid_fullscreen);
+       Cmd_AddCommand("force_centerview", Force_CenterView_f);
 }