X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=vid_shared.c;h=f799f7dbc8af3d9498849480835fe787b0de6977;hb=685e171914f1c0709b04ca02c97505a4055001f0;hp=719e0203f7e84a1177718bed6f7adcc255328e72;hpb=855932aeb5707c5efb2858c3e51b913d8203ebbe;p=xonotic%2Fdarkplaces.git diff --git a/vid_shared.c b/vid_shared.c index 719e0203..f799f7db 100644 --- a/vid_shared.c +++ b/vid_shared.c @@ -1,104 +1,57 @@ #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) +// 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; +// LordHavoc: ARB texture_env_combine support +qboolean gl_combine_extension = false; + +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"}; +cvar_t gl_combine = {0, "gl_combine", "0"}; + +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 *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 () -{ - 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 qgamma[256]; -static float vid_gamma = 1.0; - -void Check_Gamma (unsigned char *pal) +void VID_CheckCombine(void) { - float inf; - int i; - - if ((i = COM_CheckParm("-gamma"))) - vid_gamma = atof(com_argv[i+1]); - else + // LordHavoc: although texture_env_combine doesn't require multiple TMUs + // (it does require the multitexture extension however), it is useless to + // darkplaces without multiple TMUs... + if (gl_mtexable && strstr(gl_extensions, "GL_ARB_texture_env_combine ")) { -// 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++) - qgamma[i] = i; + gl_combine_extension = true; + Cvar_SetValue("gl_combine", true); + Con_Printf("GL_ARB_texture_env_combine detected\n"); } 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; - qgamma[i] = inf; - } + gl_combine_extension = false; + Cvar_SetValue("gl_combine", false); + Con_Printf("GL_ARB_texture_env_combine not detected\n"); } +} - // gamma correct the palette - //for (i=0 ; i<768 ; i++) - // pal[i] = qgamma[pal[i]]; - // note: 32bit uploads are corrected by the upload functions +void VID_InitCvars(void) +{ + Cvar_RegisterVariable(&vid_mode); + Cvar_RegisterVariable(&vid_mouse); + Cvar_RegisterVariable(&vid_fullscreen); + Cvar_RegisterVariable(&gl_combine); + Cmd_AddCommand("force_centerview", Force_CenterView_f); }