]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
bmodel rotation physics now work
authorlordhavoc <lordhavoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 9 Dec 2000 18:04:45 +0000 (18:04 +0000)
committerlordhavoc <lordhavoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 9 Dec 2000 18:04:45 +0000 (18:04 +0000)
new vid_glx.c (contributed by zinx)
removed DPNEHAHRA engine titling
fixed some lighthalf, fog, and sky related bugs
removed some 3D card hacks
merged GL_Init code for all targets (note: vid_glx.c and vid_3dfxsvga.c may be broken)
split sprite code out in gl_sprites.c
rearranged palette management code
removed all traces of 8bit upload support for now (may be added back)
halved memory usage (although this prevents renderer restarting for the moment)
implemented r_texturestats command
removed old texture upload code
rewrote use of host_parms
rewrote some code relating to host_basepal
bigendian support in pcx loading
changed external texture character equivilant for * from + to # to avoid conflicts with animating textures
removed cruft here and there
force all textures to lowercase to mask potentially silly wad lump names in maps
new crosshairs
more stuff is extern in includes
some general cleanup of the MOVETYPE_PUSH code
rewrote portions of vid_wgl.c
V_UpdatePalette renamed to V_UpdateBlends
removed starting dialog code in wgl
made SV_RecursiveHullCheck accessable in world.h

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@119 d7cf8633-e32d-0410-b094-e92efae38249

44 files changed:
chase.c
cl_main.c
cl_parse.c
client.h
gl_draw.c
gl_models.c
gl_poly.c
gl_poly.h
gl_rmain.c
gl_rmisc.c
gl_rsurf.c
gl_screen.c
gl_textures.c
gl_warp.c
glquake.h
host.c
image.c
in_win.c
model_alias.c
model_brush.c
model_sprite.c
palette.c [new file with mode: 0644]
palette.h [new file with mode: 0644]
quakedef.h
r_crosshairs.c
r_light.c
r_part.c
r_sprites.c [new file with mode: 0644]
render.h
sv_main.c
sv_phys.c
sys_linux.c
sys_win.c
sys_wind.c
vid.h
vid_3dfxsvga.c
vid_glx.c
vid_shared.c
vid_wgl.c
view.c
view.h
winquake.h
world.c
world.h

diff --git a/chase.c b/chase.c
index a254c74c62ea1dcf51ee4e74b73aeb3084466704..8a46d76feb91f15419bc55dc530d71eca2f261da 100644 (file)
--- a/chase.c
+++ b/chase.c
@@ -38,8 +38,6 @@ void Chase_Reset (void)
 //     start position 12 units behind head
 }
 
-extern qboolean SV_RecursiveHullCheck (hull_t *hull, int num, float p1f, float p2f, vec3_t p1, vec3_t p2, trace_t *trace);
-
 void TraceLine (vec3_t start, vec3_t end, vec3_t impact)
 {
        trace_t trace;
index 2656281a43a40755ce3b31f752876a8cf4062e1b..7732166305250383155271fe8f6840b50d44edad 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -782,7 +782,6 @@ void CL_PModel_f (void)
 CL_Fog_f
 ======================
 */
-extern float fog_density, fog_red, fog_green, fog_blue;
 void CL_Fog_f (void)
 {
        if (Cmd_Argc () == 1)
index fe45aeeacf64a0a27f3402fbbdfc07a90609ba75..7810cb5e42794207d5e46b866fd144d46d72347d 100644 (file)
@@ -219,10 +219,6 @@ void CL_KeepaliveMessage (void)
 
 extern qboolean isworldmodel;
 extern char skyname[];
-extern float fog_density;
-extern float fog_red;
-extern float fog_green;
-extern float fog_blue;
 extern void R_SetSkyBox (char *sky);
 extern void FOG_clear();
 extern cvar_t r_farclip;
@@ -756,11 +752,6 @@ extern void SHOWLMP_decodehide();
 extern void SHOWLMP_decodeshow();
 extern void R_SetSkyBox(char* sky);
 
-extern float fog_density;
-extern float fog_red;
-extern float fog_green;
-extern float fog_blue;
-
 /*
 =====================
 CL_ParseServerMessage
index 563f3cd07b262d740a41ead32e83d5cfff5a1dd4..44fbedf9fb194d9970e4e8d9e29bcd76e34c5f75 100644 (file)
--- a/client.h
+++ b/client.h
@@ -341,7 +341,7 @@ void V_StartPitchDrift (void);
 void V_StopPitchDrift (void);
 
 void V_RenderView (void);
-void V_UpdatePalette (void);
+void V_UpdateBlends (void);
 void V_Register (void);
 void V_ParseDamage (void);
 void V_SetContentsColor (int contents);
index 643a5223ac7d070c9187dd362b18005aaee9c0c3..cb4cc1afd74ab215791320a87b98e05f62eb6d72 100644 (file)
--- a/gl_draw.c
+++ b/gl_draw.c
@@ -25,8 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #define GL_COLOR_INDEX8_EXT     0x80E5
 
-extern unsigned char d_15to8table[65536];
-
 cvar_t         qsg_version = {"qsg_version", "1"};
 cvar_t         scr_conalpha = {"scr_conalpha", "1"};
 
@@ -235,8 +233,6 @@ qpic_t      *Draw_CachePic (char *path)
 
 extern void LoadSky_f(void);
 
-extern char *QSG_EXTENSIONS;
-
 /*
 ===============
 Draw_Init
@@ -285,22 +281,12 @@ void GL_Draw_Init (void)
 
        Cmd_AddCommand ("loadsky", &LoadSky_f);
 
-#ifdef NEHAHRA
-#if defined(__linux__)
-       sprintf (engineversion, "DPNehahra Linux   GL %.2f build %3i", (float) VERSION, buildnumber);
-#elif defined(WIN32)
-       sprintf (engineversion, "DPNehahra Windows GL %.2f build %3i", (float) VERSION, buildnumber);
-#else
-       sprintf (engineversion, "DPNehahra Unknown GL %.2f build %3i", (float) VERSION, buildnumber);
-#endif
-#else
 #if defined(__linux__)
        sprintf (engineversion, "DarkPlaces Linux   GL %.2f build %3i", (float) VERSION, buildnumber);
 #elif defined(WIN32)
        sprintf (engineversion, "DarkPlaces Windows GL %.2f build %3i", (float) VERSION, buildnumber);
 #else
        sprintf (engineversion, "DarkPlaces Unknown GL %.2f build %3i", (float) VERSION, buildnumber);
-#endif
 #endif
        for (i = 0;i < 40 && engineversion[i];i++)
                engineversion[i] += 0x80; // shift to orange
index c46691e008a60c4416f85487bdd9e7e3a97b31c4..594ca0faef282ce495347fbdade03b4cfd8274fc 100644 (file)
@@ -70,8 +70,6 @@ void R_AliasLerpVerts(int vertcount, float lerp, trivert2 *verts1, vec3_t scale1
        if (lerp != 0)
        {
                float ilerp, ilerp127, lerp127, scalex1, scalex2, translatex, scaley1, scaley2, translatey, scalez1, scalez2, translatez;
-               if (lerp < 0) lerp = 0;
-               if (lerp > 1) lerp = 1;
                ilerp = 1 - lerp;
                ilerp127 = ilerp * (1.0 / 127.0);
                lerp127 = lerp * (1.0 / 127.0);
@@ -146,8 +144,6 @@ float R_CalcAnimLerp(entity_t *ent, int pose, float lerpscale)
        }
 }
 
-extern cvar_t gl_vertexarrays;
-extern qboolean lighthalf;
 void GL_DrawModelMesh(int skin, byte *colors, maliashdr_t *maliashdr)
 {
        int i;
@@ -630,7 +626,6 @@ void R_DrawQ2AliasFrame (md2mem_t *pheader, float alpha, vec3_t color, entity_t
 
 int modeldlightbits[8];
 extern int r_dlightframecount;
-extern void R_LightPoint (vec3_t color, vec3_t p);
 
 /*
 =================
index 577a8bc1676dd8d8d1a43a7129b88dd6bd9bf31e..1f18658e143c1ca2ac5ffb939a1409acec6e6e58 100644 (file)
--- a/gl_poly.c
+++ b/gl_poly.c
@@ -149,7 +149,6 @@ void transpolyend()
 }
 
 int transpolyindices;
-extern qboolean isG200;
 
 /*
 void transpolyrenderminmax()
@@ -559,14 +558,11 @@ void transpolyrender()
        glDisable(GL_ALPHA_TEST);
 }
 
-extern qboolean isG200;
-
 void wallpolyclear()
 {
        currentwallpoly = currentwallvert = 0;
 }
 
-extern qboolean lighthalf;
 void wallpolyrender()
 {
        int i, j, texnum, lighttexnum;
@@ -786,8 +782,6 @@ void skypolyclear()
        currentskypoly = currentskyvert = 0;
 }
 
-extern qboolean isATI;
-
 extern char skyname[];
 extern int solidskytexture, alphaskytexture;
 void skypolyrender()
@@ -810,7 +804,10 @@ void skypolyrender()
        glDepthMask(1);
        if (!fogenabled && !skyname[0]) // normal quake sky
        {
-               glColor3f(0.5f, 0.5f, 0.5f);
+               if(lighthalf)
+                       glColor3f(0.5f, 0.5f, 0.5f);
+               else
+                       glColor3f(1.0f,1.0f,1.0f);
                glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
                glEnable(GL_TEXTURE_2D);
                glDisable(GL_BLEND);
index 53d6d81327bbf1b0efdbc32ac63f087e5a3198b3..429b97b3af11678e5d6690c2e74aa18fefef357c 100644 (file)
--- a/gl_poly.h
+++ b/gl_poly.h
@@ -1,4 +1,6 @@
 
+extern float fog_density, fog_red, fog_green, fog_blue;
+
 #define TPOLYTYPE_ALPHA 0
 #define TPOLYTYPE_ADD 1
 
index 75cc0c374ad0e4d0ecd44af6b1a3087ef9493dfb..c2836b8718e08983da0b8e498443a099ac395eb7 100644 (file)
@@ -41,8 +41,6 @@ qboolean      envmap;                         // true during envmap command capture
 //int                  particletexture;        // little dot for particles
 //int                  playertextures;         // up to 16 color translated skins
 
-extern qboolean isG200, isRagePro; // LordHavoc: special card hacks
-
 //
 // view origin
 //
@@ -97,8 +95,6 @@ cvar_t        gl_fogstart = {"gl_fogstart", "0"};
 cvar_t gl_fogend = {"gl_fogend","0"};
 cvar_t glfog = {"glfog", "0"};
 
-extern qboolean isRagePro;
-
 qboolean lighthalf;
 
 vec3_t fogcolor;
@@ -129,6 +125,18 @@ void FOG_framebegin()
                        fog_blue = 0;
                }
        }
+       if (fog_density)
+       {
+                       fogcolor[0] = fog_red   = bound(0.0f, fog_red  , 1.0f);
+                       fogcolor[1] = fog_green = bound(0.0f, fog_green, 1.0f);
+                       fogcolor[2] = fog_blue  = bound(0.0f, fog_blue , 1.0f);
+                       if (lighthalf)
+                       {
+                               fogcolor[0] *= 0.5f;
+                               fogcolor[1] *= 0.5f;
+                               fogcolor[2] *= 0.5f;
+                       }
+       }
        if (glfog.value)
        {
                if (!r_render.value)
@@ -163,15 +171,7 @@ void FOG_framebegin()
                {
                        fogenabled = true;
                        fogdensity = -4000.0f / (fog_density * fog_density);
-                       fogcolor[0] = fog_red   = bound(0.0f, fog_red  , 1.0f);
-                       fogcolor[1] = fog_green = bound(0.0f, fog_green, 1.0f);
-                       fogcolor[2] = fog_blue  = bound(0.0f, fog_blue , 1.0f);
-                       if (lighthalf)
-                       {
-                               fogcolor[0] *= 0.5f;
-                               fogcolor[1] *= 0.5f;
-                               fogcolor[2] *= 0.5f;
-                       }
+                       // fog color was already set
                }
                else
                        fogenabled = false;
@@ -265,6 +265,43 @@ void Render_Init()
        R_StartModules();
 }
 
+/*
+===============
+GL_Init
+===============
+*/
+extern char *QSG_EXTENSIONS;
+void GL_Init (void)
+{
+       gl_vendor = glGetString (GL_VENDOR);
+       Con_Printf ("GL_VENDOR: %s\n", gl_vendor);
+       gl_renderer = glGetString (GL_RENDERER);
+       Con_Printf ("GL_RENDERER: %s\n", gl_renderer);
+
+       gl_version = glGetString (GL_VERSION);
+       Con_Printf ("GL_VERSION: %s\n", gl_version);
+       gl_extensions = glGetString (GL_EXTENSIONS);
+       Con_Printf ("GL_EXTENSIONS: %s\n", gl_extensions);
+
+//     Con_Printf ("%s %s\n", gl_renderer, gl_version);
+
+       VID_CheckMultiTexture();
+       VID_CheckVertexArrays();
+
+       // LordHavoc: report supported extensions
+       Con_Printf ("\nQSG extensions: %s\n", QSG_EXTENSIONS);
+
+       glCullFace(GL_FRONT);
+       glEnable(GL_TEXTURE_2D);
+//     glDisable(GL_ALPHA_TEST);
+       glAlphaFunc(GL_GREATER, 0.5);
+
+//     glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
+
+       Palette_Init();
+}
+
+
 /*
 void R_RotateForEntity (entity_t *e)
 {
@@ -285,173 +322,16 @@ float    r_avertexnormals[NUMVERTEXNORMALS][3] = {
 #include "anorms.h"
 };
 
-// LordHavoc: moved this shading stuff up because the sprites need shading stuff
+// LordHavoc: shading stuff
 vec3_t shadevector;
 vec3_t shadecolor;
 
 float  modelalpha;
 
-extern void R_LightPoint (vec3_t color, vec3_t p);
-extern void R_DynamicLightPoint(vec3_t color, vec3_t org, int *dlightbits);
-extern void R_DynamicLightPointNoMask(vec3_t color, vec3_t org);
-
-/*
-=============================================================
-
-  SPRITE MODELS
-
-=============================================================
-*/
-
-/*
-================
-R_GetSpriteFrame
-================
-*/
-void R_GetSpriteFrame (entity_t *currententity, mspriteframe_t **oldframe, mspriteframe_t **newframe, float *framelerp)
-{
-       msprite_t               *psprite;
-       mspritegroup_t  *pspritegroup;
-       int                             i, j, numframes, frame;
-       float                   *pintervals, fullinterval, targettime, time, jtime, jinterval;
-
-       psprite = currententity->model->cache.data;
-       frame = currententity->frame;
-
-       if ((frame >= psprite->numframes) || (frame < 0))
-       {
-               Con_Printf ("R_DrawSprite: no such frame %d\n", frame);
-               frame = 0;
-       }
-
-       if (psprite->frames[frame].type == SPR_SINGLE)
-       {
-               if (currententity->draw_lastmodel == currententity->model && currententity->draw_lerpstart < cl.time)
-               {
-                       if (frame != currententity->draw_pose)
-                       {
-                               currententity->draw_lastpose = currententity->draw_pose;
-                               currententity->draw_pose = frame;
-                               currententity->draw_lerpstart = cl.time;
-                               *framelerp = 0;
-                       }
-                       else
-                               *framelerp = (cl.time - currententity->draw_lerpstart) * 10.0;
-               }
-               else // uninitialized
-               {
-                       currententity->draw_lastmodel = currententity->model;
-                       currententity->draw_lastpose = currententity->draw_pose = frame;
-                       currententity->draw_lerpstart = cl.time;
-                       *framelerp = 0;
-               }
-               *oldframe = psprite->frames[currententity->draw_lastpose].frameptr;
-               *newframe = psprite->frames[frame].frameptr;
-       }
-       else
-       {
-               pspritegroup = (mspritegroup_t *)psprite->frames[frame].frameptr;
-               pintervals = pspritegroup->intervals;
-               numframes = pspritegroup->numframes;
-               fullinterval = pintervals[numframes-1];
-
-               time = cl.time + currententity->syncbase;
-
-       // when loading in Mod_LoadSpriteGroup, we guaranteed all interval values
-       // are positive, so we don't have to worry about division by 0
-               targettime = time - ((int)(time / fullinterval)) * fullinterval;
-
-               // LordHavoc: since I can't measure the time properly when it loops from numframes-1 to 0,
-               //            I instead measure the time of the first frame, hoping it is consistent
-               j = numframes-1;jtime = 0;jinterval = pintervals[1] - pintervals[0];
-               for (i=0 ; i<(numframes-1) ; i++)
-               {
-                       if (pintervals[i] > targettime)
-                               break;
-                       j = i;jinterval = pintervals[i] - jtime;jtime = pintervals[i];
-               }
-               *framelerp = (targettime - jtime) / jinterval;
-
-               *oldframe = pspritegroup->frames[j];
-               *newframe = pspritegroup->frames[i];
-       }
-}
-
-void GL_DrawSpriteImage (mspriteframe_t *frame, vec3_t origin, vec3_t up, vec3_t right, int red, int green, int blue, int alpha)
-{
-       // LordHavoc: rewrote this to use the transparent poly system
-       transpolybegin(frame->gl_texturenum, 0, frame->gl_fogtexturenum, currententity->effects & EF_ADDITIVE ? TPOLYTYPE_ADD : TPOLYTYPE_ALPHA);
-       transpolyvert(origin[0] + frame->down * up[0] + frame->left * right[0], origin[1] + frame->down * up[1] + frame->left * right[1], origin[2] + frame->down * up[2] + frame->left * right[2], 0, 1, red, green, blue, alpha);
-       transpolyvert(origin[0] + frame->up * up[0] + frame->left * right[0], origin[1] + frame->up * up[1] + frame->left * right[1], origin[2] + frame->up * up[2] + frame->left * right[2], 0, 0, red, green, blue, alpha);
-       transpolyvert(origin[0] + frame->up * up[0] + frame->right * right[0], origin[1] + frame->up * up[1] + frame->right * right[1], origin[2] + frame->up * up[2] + frame->right * right[2], 1, 0, red, green, blue, alpha);
-       transpolyvert(origin[0] + frame->down * up[0] + frame->right * right[0], origin[1] + frame->down * up[1] + frame->right * right[1], origin[2] + frame->down * up[2] + frame->right * right[2], 1, 1, red, green, blue, alpha);
-       transpolyend();
-}
-
-extern qboolean isG200, isRagePro, lighthalf;
-
-/*
-=================
-R_DrawSpriteModel
-
-=================
-*/
-void R_DrawSpriteModel (entity_t *e)
-{
-       mspriteframe_t  *oldframe, *newframe;
-       float                   lerp, ilerp;
-       vec3_t                  forward, right, up, org;
-       msprite_t               *psprite;
-
-       // don't even bother culling, because it's just a single
-       // polygon without a surface cache
-       R_GetSpriteFrame (e, &oldframe, &newframe, &lerp);
-       if (lerp < 0) lerp = 0;
-       if (lerp > 1) lerp = 1;
-       if (isRagePro) // LordHavoc: no alpha scaling supported on per pixel alpha images on ATI Rage Pro... ACK!
-               lerp = 1;
-       ilerp = 1.0 - lerp;
-       psprite = e->model->cache.data;
-
-       if (psprite->type == SPR_ORIENTED)
-       {       // bullet marks on walls
-               AngleVectors (e->angles, forward, right, up);
-               VectorSubtract(e->origin, vpn, org);
-       }
-       else
-       {       // normal sprite
-               VectorCopy(vup, up);
-               VectorCopy(vright, right);
-               VectorCopy(e->origin, org);
-       }
-       if (e->scale != 1)
-       {
-               VectorScale(up, e->scale, up);
-               VectorScale(right, e->scale, right);
-       }
-
-       if (e->model->flags & EF_FULLBRIGHT || e->effects & EF_FULLBRIGHT)
-       {
-               shadecolor[0] = e->colormod[0] * 255;
-               shadecolor[1] = e->colormod[1] * 255;
-               shadecolor[2] = e->colormod[2] * 255;
-       }
-       else
-       {
-               R_LightPoint (shadecolor, e->origin);
-               R_DynamicLightPointNoMask(shadecolor, e->origin);
-       }
-
-       // LordHavoc: interpolated sprite rendering
-       if (ilerp != 0)
-               GL_DrawSpriteImage(oldframe, org, up, right, shadecolor[0],shadecolor[1],shadecolor[2],e->alpha*255*ilerp);
-       if (lerp != 0)
-               GL_DrawSpriteImage(newframe, org, up, right, shadecolor[0],shadecolor[1],shadecolor[2],e->alpha*255*lerp);
-}
-
 //==================================================================================
 
 void R_DrawBrushModel (entity_t *e);
+void R_DrawSpriteModel (entity_t *e);
 
 /*
 =============
index df8ffdd3d27f41bb4ae4280d169e2379f2635880..0d9df6360433dee87c11d2243b68f1e280bbe975 100644 (file)
@@ -159,9 +159,6 @@ void GL_Misc_Init (void)
        R_RegisterModule("GL_Misc", gl_misc_start, gl_misc_shutdown);
 }
 
-//qboolean VID_Is8bit(void);
-//void GL_Upload8_EXT (byte *data, int width, int height,  qboolean mipmap, qboolean alpha);
-
 void R_ClearParticles (void);
 void GL_BuildLightmaps (void);
 
index 27cd761d4c08a0bf47eae9d796c7f1b47f190468..21d9d646bc5976db6ae0b4bd23115bfff41e6136 100644 (file)
@@ -21,8 +21,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include "quakedef.h"
 
-extern int                     skytexturenum;
-
 int            lightmap_textures;
 
 signed blocklights[18*18*3]; // LordHavoc: *3 for colored lighting
@@ -91,7 +89,6 @@ void GL_Surf_Init()
        R_RegisterModule("GL_Surf", gl_surf_start, gl_surf_shutdown);
 }
 
-extern qboolean lighthalf;
 /*
 ===============
 R_BuildLightMap
index 09e5ae0346bf637610fa1e6691d2681db2f52c8f..624a9db635f77317e2b60489417202e3c7b990bc 100644 (file)
@@ -750,7 +750,7 @@ int SCR_ModalMessage (char *text)
 ===============
 SCR_BringDownConsole
 
-Brings the console down and fades the palettes back to normal
+Brings the console down and fades the blends back to normal
 ================
 */
 void SCR_BringDownConsole (void)
@@ -762,7 +762,7 @@ void SCR_BringDownConsole (void)
        for (i=0 ; i<20 && scr_conlines != scr_con_current ; i++)
                SCR_UpdateScreen ();
 
-       cl.cshifts[0].percent = 0;              // no area contents palette on next frame
+       cl.cshifts[0].percent = 0;              // no area contents blend on next frame
 }
 
 void DrawCrosshair(int num);
@@ -916,7 +916,7 @@ void SCR_UpdateScreen (void)
        else
        {
                if (crosshair.value)
-                       DrawCrosshair(crosshair.value);
+                       DrawCrosshair(crosshair.value - 1);
                
                SCR_DrawRam ();
                SCR_DrawNet ();
@@ -942,7 +942,7 @@ void SCR_UpdateScreen (void)
                Draw_String(vid.width - (12*8), 0, temp, 9999);
        }
 
-       V_UpdatePalette ();
+       V_UpdateBlends ();
 
        GL_BrightenScreen();
 
index 83444e528b8814091230ae112bc1ba4ad7ae5228..f90f8781276aa55eb9a74b7854cdd95bfd086c99 100644 (file)
@@ -17,6 +17,7 @@ int           texels;
 typedef struct
 {
        int             texnum;
+       int             totaltexels;
        byte    *texels[MAXMIPS];
        unsigned short texelsize[MAXMIPS][2];
        char    identifier[64];
@@ -98,6 +99,33 @@ void Draw_TextureMode_f (void)
        }
 }
 
+void GL_TextureStats_Print(char *name, int total, int crc, int mip, int alpha)
+{
+       char n[64];
+       int c = 0;
+       if (!name[0])
+               name = "<unnamed>";
+       while (name[c] && c < 28)
+               n[c++] = name[c];
+       while (c < 28)
+               n[c++] = ' ';
+       n[c] = 0;
+       Con_Printf("%s %5i %04X %s %s\n", n, total, crc, mip ? "yes" : "no ", alpha ? "yes  " : "no   ");
+}
+
+void GL_TextureStats_f(void)
+{
+       int i, t = 0;
+       gltexture_t *glt;
+       Con_Printf("name                        kbytes crc  mip alpha\n");
+       for (i = 0, glt = gltextures;i < numgltextures;i++, glt++)
+       {
+               GL_TextureStats_Print(glt->identifier, ((glt->totaltexels * 4) + 512) >> 10, glt->crc, glt->mipmap, glt->alpha);
+               t += glt->totaltexels;
+       }
+       Con_Printf("%i textures, totalling %.3f mbytes\n", numgltextures, t / 1024.0 / 1024.0);
+}
+
 extern int buildnumber;
 
 char engineversion[40];
@@ -117,6 +145,7 @@ void gl_textures_shutdown()
 
 void GL_Textures_Init (void)
 {
+       Cmd_AddCommand("r_texturestats", GL_TextureStats_f);
        Cvar_RegisterVariable (&gl_max_size);
        Cvar_RegisterVariable (&gl_picmip);
        Cvar_RegisterVariable (&gl_lerpimages);
@@ -153,9 +182,6 @@ int GL_FindTexture (char *identifier)
        return -1;
 }
 
-extern byte qgamma[];
-
-// LordHavoc: gamma correction and improved resampling
 void GL_ResampleTextureLerpLine (byte *in, byte *out, int inwidth, int outwidth)
 {
        int             j, xi, oldx = 0, f, fstep, l1, l2, endx;
@@ -177,10 +203,6 @@ void GL_ResampleTextureLerpLine (byte *in, byte *out, int inwidth, int outwidth)
                        *out++ = (byte) ((in[1] * l1 + in[5] * l2) >> 16);
                        *out++ = (byte) ((in[2] * l1 + in[6] * l2) >> 16);
                        *out++ = (byte) ((in[3] * l1 + in[7] * l2) >> 16);
-//                     *out++ = qgamma[(byte) ((in[0] * l1 + in[4] * l2) >> 16)];
-//                     *out++ = qgamma[(byte) ((in[1] * l1 + in[5] * l2) >> 16)];
-//                     *out++ = qgamma[(byte) ((in[2] * l1 + in[6] * l2) >> 16)];
-//                     *out++ =        (byte) ((in[3] * l1 + in[7] * l2) >> 16) ;
                }
                else // last pixel of the line has no pixel to lerp to
                {
@@ -188,10 +210,6 @@ void GL_ResampleTextureLerpLine (byte *in, byte *out, int inwidth, int outwidth)
                        *out++ = in[1];
                        *out++ = in[2];
                        *out++ = in[3];
-//                     *out++ = qgamma[in[0]];
-//                     *out++ = qgamma[in[1]];
-//                     *out++ = qgamma[in[2]];
-//                     *out++ =        in[3] ;
                }
        }
 }
@@ -203,7 +221,6 @@ GL_ResampleTexture
 */
 void GL_ResampleTexture (void *indata, int inwidth, int inheight, void *outdata,  int outwidth, int outheight)
 {
-       // LordHavoc: gamma correction and greatly improved resampling
        if (gl_lerpimages.value)
        {
                int             i, j, yi, oldy, f, fstep, l1, l2, endy = (inheight-1);
@@ -285,347 +302,18 @@ void GL_ResampleTexture (void *indata, int inwidth, int inheight, void *outdata,
        }
 }
 
-/*
-================
-GL_Resample8BitTexture -- JACK
-================
-*/
-/*
-void GL_Resample8BitTexture (unsigned char *in, int inwidth, int inheight, unsigned char *out,  int outwidth, int outheight)
-{
-       int             i, j;
-       unsigned        char *inrow;
-       unsigned        frac, fracstep;
-
-       fracstep = inwidth*0x10000/outwidth;
-       for (i=0 ; i<outheight ; i++, out += outwidth)
-       {
-               inrow = in + inwidth*(i*inheight/outheight);
-               frac = fracstep >> 1;
-               for (j=0 ; j<outwidth ; j+=4)
-               {
-                       out[j  ] = inrow[frac>>16];frac += fracstep;
-                       out[j+1] = inrow[frac>>16];frac += fracstep;
-                       out[j+2] = inrow[frac>>16];frac += fracstep;
-                       out[j+3] = inrow[frac>>16];frac += fracstep;
-               }
-       }
-}
-*/
-
-
-/*
-================
-GL_MipMap
-
-Operates in place, quartering the size of the texture
-================
-*/
-/*
-void GL_MipMap (byte *in, int width, int height)
-{
-       int             i, j;
-       byte    *out;
-
-       width <<=2;
-       height >>= 1;
-       out = in;
-       for (i=0 ; i<height ; i++, in+=width)
-       {
-               for (j=0 ; j<width ; j+=8, out+=4, in+=8)
-               {
-                       out[0] = (in[0] + in[4] + in[width+0] + in[width+4])>>2;
-                       out[1] = (in[1] + in[5] + in[width+1] + in[width+5])>>2;
-                       out[2] = (in[2] + in[6] + in[width+2] + in[width+6])>>2;
-                       out[3] = (in[3] + in[7] + in[width+3] + in[width+7])>>2;
-               }
-       }
-}
-*/
-
-/*
-================
-GL_MipMap8Bit
-
-Mipping for 8 bit textures
-================
-*/
-/*
-void GL_MipMap8Bit (byte *in, int width, int height)
-{
-       int             i, j;
-       unsigned short     r,g,b;
-       byte    *out, *at1, *at2, *at3, *at4;
-
-       height >>= 1;
-       out = in;
-       for (i=0 ; i<height ; i++, in+=width)
-       {
-               for (j=0 ; j<width ; j+=2, out+=1, in+=2)
-               {
-                       at1 = (byte *) (d_8to24table + in[0]);
-                       at2 = (byte *) (d_8to24table + in[1]);
-                       at3 = (byte *) (d_8to24table + in[width+0]);
-                       at4 = (byte *) (d_8to24table + in[width+1]);
-
-                       r = (at1[0]+at2[0]+at3[0]+at4[0]); r>>=5;
-                       g = (at1[1]+at2[1]+at3[1]+at4[1]); g>>=5;
-                       b = (at1[2]+at2[2]+at3[2]+at4[2]); b>>=5;
-
-                       out[0] = d_15to8table[(r<<0) + (g<<5) + (b<<10)];
-               }
-       }
-}
-*/
-
-/*
-===============
-GL_Upload32
-===============
-*/
-/*
-void GL_Upload32 (void *data, int width, int height,  qboolean mipmap, qboolean alpha)
-{
-       int samples, scaled_width, scaled_height, i;
-       byte *in, *out, *scaled;
-
-       for (scaled_width = 1 ; scaled_width < width ; scaled_width<<=1)
-               ;
-       for (scaled_height = 1 ; scaled_height < height ; scaled_height<<=1)
-               ;
-
-       scaled_width >>= (int)gl_picmip.value;
-       scaled_height >>= (int)gl_picmip.value;
-
-       if (scaled_width > gl_max_size.value)
-               scaled_width = gl_max_size.value;
-       if (scaled_height > gl_max_size.value)
-               scaled_height = gl_max_size.value;
-
-       if (alpha)
-       {
-               alpha = false;
-               in = data;
-               for (i = 3;i < width*height*4;i += 4)
-                       if (in[i] != 255)
-                       {
-                               alpha = true;
-                               break;
-                       }
-       }
-
-       samples = alpha ? gl_alpha_format : gl_solid_format;
-
-       texels += scaled_width * scaled_height;
-
-       scaled = malloc(scaled_width*scaled_height*4);
-       if (scaled_width == width && scaled_height == height)
-       {
-               // LordHavoc: gamma correct while copying
-               in = (byte *)data;
-               out = (byte *)scaled;
-               for (i = 0;i < width*height;i++)
-               {
-                       *out++ = qgamma[*in++];
-                       *out++ = qgamma[*in++];
-                       *out++ = qgamma[*in++];
-                       *out++ = *in++;
-               }
-       }
-       else
-               GL_ResampleTexture (data, width, height, scaled, scaled_width, scaled_height);
-
-       glTexImage2D (GL_TEXTURE_2D, 0, samples, scaled_width, scaled_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, scaled);
-       if (mipmap)
-       {
-               int             miplevel;
-
-               miplevel = 0;
-               while (scaled_width > 1 || scaled_height > 1)
-               {
-                       GL_MipMap ((byte *)scaled, scaled_width, scaled_height);
-                       scaled_width >>= 1;
-                       scaled_height >>= 1;
-                       if (scaled_width < 1)
-                               scaled_width = 1;
-                       if (scaled_height < 1)
-                               scaled_height = 1;
-                       miplevel++;
-                       glTexImage2D (GL_TEXTURE_2D, miplevel, samples, scaled_width, scaled_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, scaled);
-               }
-       }
-
-       if (mipmap)
-       {
-               glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min);
-               glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max);
-       }
-       else
-       {
-               glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_max);
-               glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max);
-       }
-       free(scaled);
-}
-
-void GL_Upload8_EXT (byte *data, int width, int height,  qboolean mipmap)
+void GL_FreeTexels(gltexture_t *glt)
 {
-       int             scaled_width, scaled_height;
-       byte    *scaled = NULL;
-
-       for (scaled_width = 1 ; scaled_width < width ; scaled_width<<=1)
-               ;
-       for (scaled_height = 1 ; scaled_height < height ; scaled_height<<=1)
-               ;
-
-       scaled_width >>= (int)gl_picmip.value;
-       scaled_height >>= (int)gl_picmip.value;
-
-       if (scaled_width > gl_max_size.value)
-               scaled_width = gl_max_size.value;
-       if (scaled_height > gl_max_size.value)
-               scaled_height = gl_max_size.value;
-
-       texels += scaled_width * scaled_height;
-
-       if (scaled_width == width && scaled_height == height)
-       {
-               if (!mipmap)
-               {
-                       glTexImage2D (GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT, scaled_width, scaled_height, 0, GL_COLOR_INDEX , GL_UNSIGNED_BYTE, data);
-                       goto done;
-               }
-               scaled = malloc(scaled_width*scaled_height*4);
-               memcpy (scaled, data, width*height);
-       }
-       else
-       {
-               scaled = malloc(scaled_width*scaled_height*4);
-               GL_Resample8BitTexture (data, width, height, (void*) scaled, scaled_width, scaled_height);
-       }
-
-       glTexImage2D (GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT, scaled_width, scaled_height, 0, GL_COLOR_INDEX, GL_UNSIGNED_BYTE, scaled);
-       if (mipmap)
-       {
-               int             miplevel;
-
-               miplevel = 0;
-               while (scaled_width > 1 || scaled_height > 1)
-               {
-                       GL_MipMap8Bit ((byte *)scaled, scaled_width, scaled_height);
-                       scaled_width >>= 1;
-                       scaled_height >>= 1;
-                       if (scaled_width < 1)
-                               scaled_width = 1;
-                       if (scaled_height < 1)
-                               scaled_height = 1;
-                       miplevel++;
-                       glTexImage2D (GL_TEXTURE_2D, miplevel, GL_COLOR_INDEX8_EXT, scaled_width, scaled_height, 0, GL_COLOR_INDEX, GL_UNSIGNED_BYTE, scaled);
-               }
-       }
-done: ;
-
-
-       if (mipmap)
-       {
-               glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min);
-               glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max);
-       }
-       else
-       {
-               glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_max);
-               glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max);
-       }
-       free(scaled);
-}
-*/
-
-extern qboolean VID_Is8bit();
-
-/*
-===============
-GL_Upload8
-===============
-*/
-/*
-void GL_Upload8 (byte *data, int width, int height,  qboolean mipmap, qboolean alpha)
-{
-       static  unsigned *trans;
-       int                     i, s;
-       qboolean        noalpha;
-       int                     p;
-       byte    *indata;
-       int             *outdata;
-
-       s = width*height;
-       trans = malloc(s*4);
-       // if there are no transparent pixels, make it a 3 component
-       // texture even if it was specified as otherwise
-       if (alpha)
-       {
-               noalpha = true;
-               for (i=0 ; i<s ; i++)
-               {
-                       p = data[i];
-                       if (p != 255)
-                               trans[i] = d_8to24table[p];
-                       else
-                       {
-                               trans[i] = 0; // force to black
-                               noalpha = false;
-                       }
-               }
-
-               if (noalpha)
-               {
-                       if (VID_Is8bit() && (data!=scrap_texels[0]))
-                       {
-                               GL_Upload8_EXT (data, width, height, mipmap);
-                               free(trans);
-                               return;
-                       }
-                       alpha = false;
-               }
-       }
-       else
-       {
-               // LordHavoc: dodge the copy if it will be uploaded as 8bit
-               if (VID_Is8bit() && (data!=scrap_texels[0]))
-               {
-                       GL_Upload8_EXT (data, width, height, mipmap);
-                       free(trans);
-                       return;
-               }
-               //if (s&3)
-               //      Sys_Error ("GL_Upload8: s&3");
-               indata = data;
-               outdata = trans;
-               if (s&1)
-                       *outdata++ = d_8to24table[*indata++];
-               if (s&2)
-               {
-                       *outdata++ = d_8to24table[*indata++];
-                       *outdata++ = d_8to24table[*indata++];
-               }
-               for (i = 0;i < s;i+=4)
-               {
-                       *outdata++ = d_8to24table[*indata++];
-                       *outdata++ = d_8to24table[*indata++];
-                       *outdata++ = d_8to24table[*indata++];
-                       *outdata++ = d_8to24table[*indata++];
-               }
-       }
-
-       GL_Upload32 (trans, width, height, mipmap, alpha);
-       free(trans);
+       if (glt->texels[0])
+               free(glt->texels[0]);
+       glt->texels[0] = 0;
 }
-*/
 
 void GL_AllocTexels(gltexture_t *glt, int width, int height, int mipmapped)
 {
        int i, w, h, size, done;
        if (glt->texels[0])
-               free(glt->texels[0]);
+               GL_FreeTexels(glt);
        glt->texelsize[0][0] = width;
        glt->texelsize[0][1] = height;
        if (mipmapped)
@@ -654,6 +342,7 @@ void GL_AllocTexels(gltexture_t *glt, int width, int height, int mipmapped)
                                break;
                        }
                }
+               glt->totaltexels = size;
                while (i < MAXMIPS)
                        glt->texels[i++] = NULL;
                glt->texels[0] = malloc(size);
@@ -662,7 +351,9 @@ void GL_AllocTexels(gltexture_t *glt, int width, int height, int mipmapped)
        }
        else
        {
-               glt->texels[0] = malloc(width*height*4);
+               size = width*height*4;
+               glt->totaltexels = size;
+               glt->texels[0] = malloc(size);
                for (i = 1;i < MAXMIPS;i++)
                        glt->texels[i] = NULL;
        }
@@ -902,6 +593,7 @@ GL_LoadTexture_setup:
        for (mip = 1;mip < MAXMIPS && glt->texels[mip];mip++)
                GL_MipReduce(glt->texels[mip-1], glt->texels[mip], glt->texelsize[mip-1][0], glt->texelsize[mip-1][1], 1, 1);
        GL_UploadTexture(glt);
+       GL_FreeTexels(glt);
 
 //     if (bytesperpixel == 1) // 8bit
 //             GL_Upload8 (data, width, height, mipmap, alpha);
index ecafc3aa271c9bc4a928b72c35218e8202afa83a..9a1f70e7f335ee7de235e70cb82ac67fa1a5b916 100644 (file)
--- a/gl_warp.c
+++ b/gl_warp.c
@@ -176,17 +176,12 @@ void GL_SubdivideSurface (msurface_t *fa)
 
 
 
-extern qboolean lighthalf;
-
 int skyboxside[6];
 
 char skyname[256];
 
 // LordHavoc: moved LoadTGA and LoadPCX to gl_draw.c
 
-extern int image_width, image_height;
-
-byte* loadimagepixels (char* filename, qboolean complain, int matchwidth, int matchheight);
 /*
 ==================
 R_LoadSkyBox
index 37a53bebd3c32c2cd8e037bba739be543308b967..c7830ee882ee5770c92753f9448c878ded2da20f 100644 (file)
--- a/glquake.h
+++ b/glquake.h
@@ -137,6 +137,12 @@ extern qboolean gl_mtexable;
 
 // LordHavoc: ARB multitexure support
 extern int             gl_mtex_enum;
+
+// for platforms (wgl) that do not use GLAPIENTRY
+#ifndef GLAPIENTRY
+#define GLAPIENTRY APIENTRY
+#endif
+
 // Micro$oft dropped GL support beyond 1.1, so...
 #ifdef WIN32
 
@@ -155,44 +161,22 @@ extern int                gl_mtex_enum;
 
 // LordHavoc: vertex array defines
 #define GL_VERTEX_ARRAY                                        0x8074
-//#define GL_NORMAL_ARRAY                                      0x8075
+#define GL_NORMAL_ARRAY                                        0x8075
 #define GL_COLOR_ARRAY                                 0x8076
-//#define GL_INDEX_ARRAY                                       0x8077
 #define GL_TEXTURE_COORD_ARRAY                 0x8078
-//#define GL_EDGE_FLAG_ARRAY                           0x8079
-/*
-#define GL_V2F                                                 0x2A20
-#define GL_V3F                                                 0x2A21
-#define GL_C4UB_V2F                                            0x2A22
-#define GL_C4UB_V3F                                            0x2A23
-#define GL_C3F_V3F                                             0x2A24
-#define GL_N3F_V3F                                             0x2A25
-#define GL_C4F_N3F_V3F                                 0x2A26
-#define GL_T2F_V3F                                             0x2A27
-#define GL_T4F_V4F                                             0x2A28
-#define GL_T2F_C4UB_V3F                                        0x2A29
-#define GL_T2F_C3F_V3F                                 0x2A2A
-#define GL_T2F_N3F_V3F                                 0x2A2B
-#define GL_T2F_C4F_N3F_V3F                             0x2A2C
-#define GL_T4F_C4F_N3F_V4F                             0x2A2D
-*/
 
-//extern void (APIENTRY *qglPolygonOffset)(GLfloat factor, GLfloat units);
-extern void (APIENTRY *qglVertexPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
-//extern void (APIENTRY *qglNormalPointer)(GLenum type, GLsizei stride, const GLvoid *ptr);
-extern void (APIENTRY *qglColorPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
-//extern void (APIENTRY *qglIndexPointer)(GLenum type, GLsizei stride, const GLvoid *ptr);
-extern void (APIENTRY *qglTexCoordPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
-//extern void (APIENTRY *qglEdgeFlagPointer)(GLsizei stride, const GLvoid *ptr);
-//extern void (APIENTRY *qglGetPointerv)(GLenum pname, void **params);
-extern void (APIENTRY *qglArrayElement)(GLint i);
-//extern void (APIENTRY *qglDrawArrays)(GLenum mode, GLint first, GLsizei count);
-extern void (APIENTRY *qglDrawElements)(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
-//extern void (APIENTRY *qglInterleavedArrays)(GLenum format, GLsizei stride, const GLvoid *pointer);
-
-extern void (APIENTRY *qglMTexCoord2f) (GLenum, GLfloat, GLfloat);
-extern void (APIENTRY *qglSelectTexture) (GLenum);
-extern void (APIENTRY *glColorTableEXT)(int, int, int, int, int, const void*);
+//extern void (GLAPIENTRY *qglPolygonOffset)(GLfloat factor, GLfloat units);
+extern void (GLAPIENTRY *qglVertexPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
+//extern void (GLAPIENTRY *qglNormalPointer)(GLenum type, GLsizei stride, const GLvoid *ptr);
+extern void (GLAPIENTRY *qglColorPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
+extern void (GLAPIENTRY *qglTexCoordPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
+extern void (GLAPIENTRY *qglArrayElement)(GLint i);
+//extern void (GLAPIENTRY *qglDrawArrays)(GLenum mode, GLint first, GLsizei count);
+extern void (GLAPIENTRY *qglDrawElements)(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
+
+extern void (GLAPIENTRY *qglMTexCoord2f) (GLenum, GLfloat, GLfloat);
+extern void (GLAPIENTRY *qglSelectTexture) (GLenum);
+//extern void (GLAPIENTRY *glColorTableEXT)(int, int, int, int, int, const void*);
 
 #else
 
@@ -200,20 +184,16 @@ extern void (APIENTRY *glColorTableEXT)(int, int, int, int, int, const void*);
 #define qglVertexPointer glVertexPointer
 //#define qglNormalPointer glNormalPointer
 #define qglColorPointer glColorPointer
-//#define qglIndexPointer glIndexPointer
 #define qglTexCoordPointer glTexCoordPointer
-//#define qglEdgeFlagPointer glEdgeFlagPointer
-//#define qglGetPointerv glGetPointerv
 #define qglArrayElement glArrayElement
 //#define qglDrawArrays glDrawArrays
 #define qglDrawElements glDrawElements
-//#define qglInterleavedArrays glInterleavedArrays
 
-extern void (*qglMTexCoord2f) (GLenum, GLfloat, GLfloat);
-extern void (*qglSelectTexture) (GLenum);
-#ifndef MESA
-extern void (*glColorTableEXT)(int, int, int, int, int, const void*);
-#endif
+extern void (GLAPIENTRY *qglMTexCoord2f) (GLenum, GLfloat, GLfloat);
+extern void (GLAPIENTRY *qglSelectTexture) (GLenum);
+//#ifndef MESA
+//extern void (GLAPIENTRY *glColorTableEXT)(int, int, int, int, int, const void*);
+//#endif
 
 #endif
 
@@ -241,6 +221,9 @@ extern vec_t fogdensity;
 
 #include "r_modules.h"
 
+extern cvar_t gl_vertexarrays;
+extern qboolean lighthalf;
+
 extern void R_DrawAliasModel (entity_t *ent, int cull, float alpha, model_t *clmodel, int frame, int skin, vec3_t org, int effects, int flags, int colormap);
 
 extern cvar_t r_render;
diff --git a/host.c b/host.c
index 15ee313810dc9cb220bf2aecca3709d19621b88f..59b4db59dd9e068e4ae1803f6f739e7bc05a0efe 100644 (file)
--- a/host.c
+++ b/host.c
@@ -52,8 +52,6 @@ client_t      *host_client;                   // current client
 
 jmp_buf        host_abortserver;
 
-byte           *host_basepal;
-
 cvar_t host_framerate = {"host_framerate","0"};        // set for slow motion
 cvar_t host_speeds = {"host_speeds","0"};                      // set for running times
 cvar_t slowmo = {"slowmo", "1.0"};                                     // LordHavoc: framerate independent slowmo
@@ -733,7 +731,7 @@ extern int vcrFile;
 #define        VCR_SIGNATURE   0x56435231
 // "VCR1"
 
-void Host_InitVCR (quakeparms_t *parms)
+void Host_InitVCR ()
 {
        int             i, len, n;
        char    *p;
@@ -753,7 +751,7 @@ void Host_InitVCR (quakeparms_t *parms)
 
                Sys_FileRead (vcrFile, &com_argc, sizeof(int));
                com_argv = malloc(com_argc * sizeof(char *));
-               com_argv[0] = parms->argv[0];
+               com_argv[0] = host_parms.argv[0];
                for (i = 0; i < com_argc; i++)
                {
                        Sys_FileRead (vcrFile, &len, sizeof(int));
@@ -762,8 +760,8 @@ void Host_InitVCR (quakeparms_t *parms)
                        com_argv[i+1] = p;
                }
                com_argc++; /* add one for arg[0] */
-               parms->argc = com_argc;
-               parms->argv = com_argv;
+               host_parms.argc = com_argc;
+               host_parms.argv = com_argv;
        }
 
        if ( (n = COM_CheckParm("-record")) != 0)
@@ -798,7 +796,7 @@ void Render_Init();
 Host_Init
 ====================
 */
-void Host_Init (quakeparms_t *parms)
+void Host_Init ()
 {
 
        if (standard_quake)
@@ -807,23 +805,21 @@ void Host_Init (quakeparms_t *parms)
                minimum_memory = MINIMUM_MEMORY_LEVELPAK;
 
        if (COM_CheckParm ("-minmemory"))
-               parms->memsize = minimum_memory;
-
-       host_parms = *parms;
+               host_parms.memsize = minimum_memory;
 
-       if (parms->memsize < minimum_memory)
-               Sys_Error ("Only %4.1f megs of memory available, can't execute game", parms->memsize / (float)0x100000);
+       if (host_parms.memsize < minimum_memory)
+               Sys_Error ("Only %4.1f megs of memory available, can't execute game", host_parms.memsize / (float)0x100000);
 
-       com_argc = parms->argc;
-       com_argv = parms->argv;
+       com_argc = host_parms.argc;
+       com_argv = host_parms.argv;
 
-       Memory_Init (parms->membase, parms->memsize);
+       Memory_Init (host_parms.membase, host_parms.memsize);
        Cbuf_Init ();
        Cmd_Init ();    
        V_Init ();
        Chase_Init ();
-       Host_InitVCR (parms);
-       COM_Init (parms->basedir);
+       Host_InitVCR ();
+       COM_Init (host_parms.basedir);
        Host_InitLocal ();
        W_LoadWadFile ("gfx.wad");
        Key_Init ();
@@ -835,21 +831,18 @@ void Host_Init (quakeparms_t *parms)
        SV_Init ();
 
        Con_Printf ("Exe: "__TIME__" "__DATE__"\n");
-       Con_Printf ("%4.1f megabyte heap\n",parms->memsize/ (1024*1024.0));
+       Con_Printf ("%4.1f megabyte heap\n",host_parms.memsize/(1024*1024.0));
        
        R_InitTextures ();              // needed even for dedicated servers
  
        if (cls.state != ca_dedicated)
        {
-               host_basepal = (byte *)COM_LoadHunkFile ("gfx/palette.lmp", false);
-               if (!host_basepal)
-                       Sys_Error ("Couldn't load gfx/palette.lmp");
-               host_basepal[765] = host_basepal[766] = host_basepal[767] = 0; // LordHavoc: force the transparent color to black
+               Palette_Init("gfx/palette.lmp");
 
 #ifndef _WIN32 // on non win32, mouse comes before video for security reasons
                IN_Init ();
 #endif
-               VID_Init (host_basepal);
+               VID_Init ();
 
                Render_Init();
                S_Init ();
diff --git a/image.c b/image.c
index 368bb1f802d79135c4b44c4a3eb00ec000f50107..a0bd89a3bc26cd5ea24ee43bd43d1dd7dcea6d03 100644 (file)
--- a/image.c
+++ b/image.c
@@ -42,7 +42,6 @@ void Image_Copy8bitRGBA(byte *in, byte *out, int pixels, int *pal)
                iout[0] = pal[in[0]];
 }
 
-extern byte qgamma[];
 void Image_CopyRGBAGamma(byte *in, byte *out, int pixels)
 {
        while (pixels--)
@@ -103,12 +102,17 @@ byte* LoadPCX (FILE *f, int matchwidth, int matchheight)
 
        pcx = &pcxbuf;
 
-       if (pcx->manufacturer != 0x0a
-               || pcx->version != 5
-               || pcx->encoding != 1
-               || pcx->bits_per_pixel != 8
-               || pcx->xmax > 320
-               || pcx->ymax > 256)
+       // LordHavoc: big-endian support ported from QF newtree
+       pcx->xmax = LittleShort (pcx->xmax);
+       pcx->xmin = LittleShort (pcx->xmin);
+       pcx->ymax = LittleShort (pcx->ymax);
+       pcx->ymin = LittleShort (pcx->ymin);
+       pcx->hres = LittleShort (pcx->hres);
+       pcx->vres = LittleShort (pcx->vres);
+       pcx->bytes_per_line = LittleShort (pcx->bytes_per_line);
+       pcx->palette_type = LittleShort (pcx->palette_type);
+
+       if (pcx->manufacturer != 0x0a || pcx->version != 5 || pcx->encoding != 1 || pcx->bits_per_pixel != 8 || pcx->xmax > 320 || pcx->ymax > 256)
        {
                Con_Printf ("Bad pcx file\n");
                return NULL;
@@ -139,19 +143,29 @@ byte* LoadPCX (FILE *f, int matchwidth, int matchheight)
                        {
                                runLength = dataByte & 0x3F;
                                dataByte = fgetc(f);
+                               if (runLength)
+                               {
+                                       x += runLength;
+                                       while(runLength--)
+                                       {
+                                               pix[0] = palette[dataByte*3];
+                                               pix[1] = palette[dataByte*3+1];
+                                               pix[2] = palette[dataByte*3+2];
+                                               pix[3] = 255;
+                                               pix += 4;
+                                       }
+                               }
                        }
                        else
-                               runLength = 1;
-
-                       while(runLength-- > 0)
                        {
+                               x++;
                                pix[0] = palette[dataByte*3];
                                pix[1] = palette[dataByte*3+1];
                                pix[2] = palette[dataByte*3+2];
                                pix[3] = 255;
                                pix += 4;
-                               x++;
                        }
+
                }
        }
        fclose(f);
@@ -399,14 +413,10 @@ byte* loadimagepixels (char* filename, qboolean complain, int matchwidth, int ma
        char    basename[128], name[128];
        byte    *image_rgba, *c;
        COM_StripExtension(filename, basename); // strip the extension to allow TGA skins on Q2 models despite the .pcx in the skin name
-       // replace *'s with +, so commandline utils don't get confused when dealing with the external files
-       c = basename;
-       while (*c)
-       {
+       // replace *'s with #, so commandline utils don't get confused when dealing with the external files
+       for (c = basename;*c;c++)
                if (*c == '*')
-                       *c = '+';
-               c++;
-       }
+                       *c = '#';
        sprintf (name, "textures/%s.tga", basename);
        COM_FOpenFile (name, &f, true);
        if (f)
index 2641749e01f6b30334b8ef31b01f79fcf94db5bd..139766d3f5e1154a3aea267fafdcaaecf3ed9baf 100644 (file)
--- a/in_win.c
+++ b/in_win.c
@@ -874,6 +874,7 @@ PDWORD RawValuePointer (int axis)
        case JOY_AXIS_V:
                return &ji.dwVpos;
        }
+       return NULL; // LordHavoc: hush compiler warning
 }
 
 
index d4fe29716cb2ca922009129b81e597a9675eef69..4d4e5885e7887fa79818ba526bce62aa50bbde14 100644 (file)
@@ -29,25 +29,8 @@ void Mod_AliasInit (void)
 {
 }
 
-//aliashdr_t   *pheader;
-
-//typedef struct
-//{
-//     int v[3];
-//     vec3_t normal;
-//} temptris_t;
-//temptris_t *temptris;
-//stvert_t     stverts[MAXALIASVERTS];
-//mtriangle_t  triangles[MAXALIASTRIS];
-
-// a pose is a single set of vertexes.  a frame may be
-// an animating sequence of poses
-//trivertx_t   *poseverts[MAXALIASFRAMES];
 int                    posenum;
 
-byte           **player_8bit_texels_tbl;
-byte           *player_8bit_texels;
-
 float          aliasbboxmin[3], aliasbboxmax[3]; // LordHavoc: proper bounding box considerations
 
 #define MAXVERTS 8192
@@ -175,8 +158,6 @@ typedef struct
        short           x, y;
 } floodfill_t;
 
-extern unsigned d_8to24table[];
-
 // must be a power of 2
 #define FLOODFILL_FIFO_SIZE 0x1000
 #define FLOODFILL_FIFO_MASK (FLOODFILL_FIFO_SIZE - 1)
index 913e9b3d6a1053a72cd6b0c8bd384558961f0b91..d5c8c3e386a1ddcd58e2572010025a0c803db5c5 100644 (file)
@@ -110,7 +110,7 @@ void Mod_LoadTextures (lump_t *l)
        texture_t       *anims[10];
        texture_t       *altanims[10];
        dmiptexlump_t *m;
-       byte *data;
+       byte    *data;
 
        if (!l->filelen)
        {
@@ -142,7 +142,17 @@ void Mod_LoadTextures (lump_t *l)
                tx = Hunk_AllocName (sizeof(texture_t), loadname );
                loadmodel->textures[i] = tx;
 
-               memcpy (tx->name, mt->name, sizeof(tx->name));
+               // LordHavoc: force all names to lowercase and make sure they are terminated while copying
+               for (j = 0;mt->name[j] && j < 15;j++)
+               {
+                       if (mt->name[j] >= 'A' && mt->name[j] <= 'Z')
+                               tx->name[j] = mt->name[j] + ('a' - 'A');
+                       else
+                               tx->name[j] = mt->name[j];
+               }
+               for (;j < 16;j++)
+                       tx->name[j] = 0;
+
                tx->width = mt->width;
                tx->height = mt->height;
                for (j=0 ; j<MIPLEVELS ; j++)
@@ -151,7 +161,7 @@ void Mod_LoadTextures (lump_t *l)
                bytesperpixel = 4;
                fullbrights = FALSE;
                transparent = TRUE;
-               data = loadimagepixels(mt->name, FALSE, 0, 0); //tx->width, tx->height);
+               data = loadimagepixels(tx->name, FALSE, 0, 0); //tx->width, tx->height);
                if (!data) // no external texture found
                {
                        freeimage = FALSE;
@@ -160,7 +170,7 @@ void Mod_LoadTextures (lump_t *l)
                        if (!hlbsp && mt->offsets[0]) // texture included
                        {
                                data = (byte *)((int) mt + mt->offsets[0]);
-                               if (r_fullbrights.value && mt->name[0] != '*')
+                               if (r_fullbrights.value && tx->name[0] != '*')
                                {
                                        for (j = 0;j < tx->width*tx->height;j++)
                                                if (data[j] >= 224) // fullbright
@@ -181,7 +191,7 @@ void Mod_LoadTextures (lump_t *l)
                        tx->width = image_width;
                        tx->height = image_height;
                }
-               if (!hlbsp && !strncmp(mt->name,"sky",3) && tx->width == 256 && tx->height == 128) // LordHavoc: HL sky textures are entirely unrelated
+               if (!hlbsp && !strncmp(tx->name,"sky",3) && tx->width == 256 && tx->height == 128) // LordHavoc: HL sky textures are entirely unrelated
                {
                        tx->transparent = FALSE;
                        R_InitSky (data, bytesperpixel);
@@ -212,26 +222,6 @@ void Mod_LoadTextures (lump_t *l)
                }
                if (freeimage)
                        free(data);
-
-               /*
-               pixels = mt->width*mt->height/64*85;
-               tx = Hunk_AllocName (sizeof(texture_t) +pixels, loadname );
-               loadmodel->textures[i] = tx;
-
-               memcpy (tx->name, mt->name, sizeof(tx->name));
-               tx->width = mt->width;
-               tx->height = mt->height;
-               for (j=0 ; j<MIPLEVELS ; j++)
-                       tx->offsets[j] = mt->offsets[j] + sizeof(texture_t) - sizeof(miptex_t);
-               // the pixels immediately follow the structures
-               memcpy ( tx+1, mt+1, pixels);
-               
-
-               if (!strncmp(mt->name,"sky",3)) 
-                       R_InitSky (tx);
-               else
-                       tx->gl_texturenum = GL_LoadTexture (mt->name, tx->width, tx->height, (byte *)(tx+1), true, false, 1);
-               */
        }
 
 //
index b228149acb884aa6eb4b18bfef5f4c185b5ec9f2..eaff930db14855196e87efb8e2f3d309d24b0a98 100644 (file)
@@ -245,17 +245,9 @@ void Mod_LoadSpriteModel (model_t *mod, void *buffer)
                psprite->frames[i].type = frametype;
 
                if (frametype == SPR_SINGLE)
-               {
-                       pframetype = (dspriteframetype_t *)
-                                       Mod_LoadSpriteFrame (pframetype + 1,
-                                                                                &psprite->frames[i].frameptr, i, bytesperpixel);
-               }
+                       pframetype = (dspriteframetype_t *) Mod_LoadSpriteFrame (pframetype + 1, &psprite->frames[i].frameptr, i, bytesperpixel);
                else
-               {
-                       pframetype = (dspriteframetype_t *)
-                                       Mod_LoadSpriteGroup (pframetype + 1,
-                                                                                &psprite->frames[i].frameptr, i, bytesperpixel);
-               }
+                       pframetype = (dspriteframetype_t *) Mod_LoadSpriteGroup (pframetype + 1, &psprite->frames[i].frameptr, i, bytesperpixel);
        }
 
        mod->type = mod_sprite;
diff --git a/palette.c b/palette.c
new file mode 100644 (file)
index 0000000..60969b1
--- /dev/null
+++ b/palette.c
@@ -0,0 +1,98 @@
+
+#include "quakedef.h"
+
+unsigned int d_8to24table[256];
+//byte d_15to8table[32768];
+byte host_basepal[768];
+byte qgamma[256];
+static float vid_gamma = 1.0;
+
+void Palette_Setup8to24()
+{
+       byte *in, *out;
+       unsigned short i;
+
+       in = host_basepal;
+       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++ = *in++;
+               *out++ = *in++;
+               *out++ = *in++;
+               *out++ = 255;
+       }
+       d_8to24table[255] = 0; // completely transparent black
+}
+
+/*
+void   Palette_Setup15to8()
+{
+       byte    *pal;
+       unsigned r,g,b;
+       unsigned v;
+       int     r1,g1,b1;
+       int             j,k,l;
+       unsigned short i;
+
+       for (i = 0;i < 32768;i++)
+       {
+               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+g1*g1+b1*b1;
+                       if (j < l)
+                       {
+                               k = v;
+                               l = j;
+                       }
+               }
+               d_15to8table[i] = k;
+       }
+}
+*/
+
+void Palette_Gamma ()
+{
+       float   inf;
+       int             i;
+
+       vid_gamma = 1;
+       if ((i = COM_CheckParm("-gamma")))
+               vid_gamma = atof(com_argv[i+1]);
+
+       if (vid_gamma == 1) // LordHavoc: dodge the math
+       {
+               for (i = 0;i < 256;i++)
+                       qgamma[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;
+                       qgamma[i] = inf;
+               }
+       }
+}
+
+void Palette_Init()
+{
+       byte *pal;
+       pal = (byte *)COM_LoadMallocFile ("gfx/palette.lmp", false);
+       if (!pal)
+               Sys_Error ("Couldn't load gfx/palette.lmp");
+       memcpy(host_basepal, pal, 765);
+       free(pal);
+       host_basepal[765] = host_basepal[766] = host_basepal[767] = 0; // LordHavoc: force the transparent color to black
+       Palette_Setup8to24();
+//     Palette_Setup15to8();
+       Palette_Gamma();
+}
diff --git a/palette.h b/palette.h
new file mode 100644 (file)
index 0000000..ff8dc79
--- /dev/null
+++ b/palette.h
@@ -0,0 +1,8 @@
+
+extern unsigned int d_8to24table[256];
+//extern byte d_15to8table[32768];
+extern byte host_basepal[768];
+extern byte qgamma[256];
+extern float vid_gamma;
+
+void Palette_Init();
index a04938be7583bd102d8f9cad2adea45a2af7b738..899886de0ef01cf5f590c0b797c43ed3b79a3697 100644 (file)
@@ -263,7 +263,6 @@ extern      cvar_t          developer;
 
 extern qboolean        host_initialized;               // true if into command execution
 extern double          host_frametime;
-extern byte            *host_basepal;
 extern int                     host_framecount;        // incremented every frame, never reset
 extern double          realtime;                       // not bounded in any way, changed at
                                                                                // start of every frame, never reset
@@ -273,7 +272,7 @@ extern      double          sv_frametime;
 void Host_ClearMemory (void);
 void Host_ServerFrame (void);
 void Host_InitCommands (void);
-void Host_Init (quakeparms_t *parms);
+void Host_Init ();
 void Host_Shutdown(void);
 void Host_Error (char *error, ...);
 void Host_EndGame (char *message, ...);
@@ -303,4 +302,5 @@ void Chase_Update (void);
 
 void fractalnoise(unsigned char *noise, int size, int startgrid);
 
+#include "palette.h"
 #include "image.h"
index e2be86746516be0ed02e2e3ee77115123a5e8181..5416a693c05c42b3cff473651f6761d66fc837f4 100644 (file)
@@ -5,11 +5,29 @@ cvar_t crosshair_alpha = {"crosshair_alpha", "1.0", true};
 cvar_t crosshair_flashspeed = {"crosshair_flashspeed", "2", true};
 cvar_t crosshair_flashrange = {"crosshair_flashrange", "0.1", true};
 
-#define NUMCROSSHAIRS 1
+#define NUMCROSSHAIRS 5
 
 int crosshairtex[NUMCROSSHAIRS];
 
-char crosshairtex1[16*16] =
+byte *crosshairtexdata[NUMCROSSHAIRS] =
+{
+       "0000000000000000"
+       "0000000000000000"
+       "0000000000000000"
+       "0003300000033000"
+       "0003550000553000"
+       "0000577007750000"
+       "0000077007700000"
+       "0000000000000000"
+       "0000000000000000"
+       "0000077007700000"
+       "0000577007750000"
+       "0003550000553000"
+       "0003300000033000"
+       "0000000000000000"
+       "0000000000000000"
+       "0000000000000000"
+       ,
        "0000000000000000"
        "0000000000000000"
        "0000000000000000"
@@ -26,18 +44,77 @@ char crosshairtex1[16*16] =
        "0000000000000000"
        "0000000000000000"
        "0000000000000000"
-;
+       ,
+       "0000000000000000"
+       "0000000770000000"
+       "0000000770000000"
+       "0000000000000000"
+       "0000000000000000"
+       "0000000440000000"
+       "0000000440000000"
+       "0770044004400770"
+       "0770044004400770"
+       "0000000440000000"
+       "0000000440000000"
+       "0000000000000000"
+       "0000000770000000"
+       "0000000770000000"
+       "0000000000000000"
+       "0000000000000000"
+       ,
+       "0000000000000000"
+       "0000000000000000"
+       "0000000000000000"
+       "0000000000000000"
+       "0000000000000000"
+       "0000000000000000"
+       "0000000000000000"
+       "0000000000000000"
+       "0000000077777770"
+       "0000000075200000"
+       "0000000072000000"
+       "0000000070000000"
+       "0000000070000000"
+       "0000000070000000"
+       "0000000000000000"
+       "0000000000000000"
+       ,
+       "0000000000000000"
+       "0000000000000000"
+       "0000000000000000"
+       "0000000000000000"
+       "0000000000000000"
+       "0000000070000000"
+       "0000000000000000"
+       "0000000040000000"
+       "0000070404070000"
+       "0000000040000000"
+       "0000000000000000"
+       "0000000070000000"
+       "0000000000000000"
+       "0000000000000000"
+       "0000000000000000"
+       "0000000000000000"
+};
 
-void r_crosshairs_start()
+void crosshairload(int num, byte *in)
 {
        int i;
-       byte data[64*64][4];
+       byte data[16*16][4];
        for (i = 0;i < 16*16;i++)
        {
                data[i][0] = data[i][1] = data[i][2] = 255;
-               data[i][3] = (crosshairtex1[i] - '0') * 255 / 7;
+               data[i][3] = (in[i] - '0') * 255 / 7;
        }
-       crosshairtex[0] = GL_LoadTexture("crosshair0", 16, 16, &data[0][0], false, true, 4);
+       crosshairtex[num] = GL_LoadTexture(va("crosshair%02d", num), 16, 16, &data[0][0], false, true, 4);
+}
+
+void r_crosshairs_start()
+{
+       int i;
+       for (i = 0;i < NUMCROSSHAIRS;i++)
+               crosshairload(i, crosshairtexdata[i]);
+//     crosshairtex[1] = crosshairload(crosshairtex2);
 }
 
 void r_crosshairs_shutdown()
index 3bbf6b560da283ff7b90c15921683e9539067516..63dfe2669302b45b22131f4055d99e0a19ef4205 100644 (file)
--- a/r_light.c
+++ b/r_light.c
@@ -628,7 +628,6 @@ extern float *aliasvert;
 extern float *aliasvertnorm;
 extern byte *aliasvertcolor;
 extern float modelalpha;
-extern qboolean lighthalf;
 extern int modeldlightbits[8];
 void R_LightModel(int numverts, vec3_t center, vec3_t basecolor)
 {
index 1051a145c3de664558eea295ccc6e1ba437a0bb9..356c38a7a3e5223632c5701ee80f928677c3568c 100644 (file)
--- a/r_part.c
+++ b/r_part.c
@@ -940,8 +940,6 @@ void R_RocketTrail2 (vec3_t start, vec3_t end, int color, entity_t *ent)
 }
 
 
-extern qboolean lighthalf;
-
 /*
 ===============
 R_DrawParticles
diff --git a/r_sprites.c b/r_sprites.c
new file mode 100644 (file)
index 0000000..512dad1
--- /dev/null
@@ -0,0 +1,146 @@
+#include "quakedef.h"
+
+/*
+================
+R_GetSpriteFrame
+================
+*/
+void R_GetSpriteFrame (entity_t *currententity, mspriteframe_t **oldframe, mspriteframe_t **newframe, float *framelerp)
+{
+       msprite_t               *psprite;
+       mspritegroup_t  *pspritegroup;
+       int                             i, j, numframes, frame;
+       float                   *pintervals, fullinterval, targettime, time, jtime, jinterval;
+
+       psprite = currententity->model->cache.data;
+       frame = currententity->frame;
+
+       if ((frame >= psprite->numframes) || (frame < 0))
+       {
+               Con_Printf ("R_DrawSprite: no such frame %d\n", frame);
+               frame = 0;
+       }
+
+       if (psprite->frames[frame].type == SPR_SINGLE)
+       {
+               if (currententity->draw_lastmodel == currententity->model && currententity->draw_lerpstart < cl.time)
+               {
+                       if (frame != currententity->draw_pose)
+                       {
+                               currententity->draw_lastpose = currententity->draw_pose;
+                               currententity->draw_pose = frame;
+                               currententity->draw_lerpstart = cl.time;
+                               *framelerp = 0;
+                       }
+                       else
+                               *framelerp = (cl.time - currententity->draw_lerpstart) * 10.0;
+               }
+               else // uninitialized
+               {
+                       currententity->draw_lastmodel = currententity->model;
+                       currententity->draw_lastpose = currententity->draw_pose = frame;
+                       currententity->draw_lerpstart = cl.time;
+                       *framelerp = 0;
+               }
+               *oldframe = psprite->frames[currententity->draw_lastpose].frameptr;
+               *newframe = psprite->frames[frame].frameptr;
+       }
+       else
+       {
+               pspritegroup = (mspritegroup_t *)psprite->frames[frame].frameptr;
+               pintervals = pspritegroup->intervals;
+               numframes = pspritegroup->numframes;
+               fullinterval = pintervals[numframes-1];
+
+               time = cl.time + currententity->syncbase;
+
+       // when loading in Mod_LoadSpriteGroup, we guaranteed all interval values
+       // are positive, so we don't have to worry about division by 0
+               targettime = time - ((int)(time / fullinterval)) * fullinterval;
+
+               // LordHavoc: since I can't measure the time properly when it loops from numframes-1 to 0,
+               //            I instead measure the time of the first frame, hoping it is consistent
+               j = numframes-1;jtime = 0;jinterval = pintervals[1] - pintervals[0];
+               for (i=0 ; i<(numframes-1) ; i++)
+               {
+                       if (pintervals[i] > targettime)
+                               break;
+                       j = i;jinterval = pintervals[i] - jtime;jtime = pintervals[i];
+               }
+               *framelerp = (targettime - jtime) / jinterval;
+
+               *oldframe = pspritegroup->frames[j];
+               *newframe = pspritegroup->frames[i];
+       }
+}
+
+void GL_DrawSpriteImage (mspriteframe_t *frame, vec3_t origin, vec3_t up, vec3_t right, int red, int green, int blue, int alpha)
+{
+       // LordHavoc: rewrote this to use the transparent poly system
+       transpolybegin(frame->gl_texturenum, 0, frame->gl_fogtexturenum, currententity->effects & EF_ADDITIVE ? TPOLYTYPE_ADD : TPOLYTYPE_ALPHA);
+       transpolyvert(origin[0] + frame->down * up[0] + frame->left * right[0], origin[1] + frame->down * up[1] + frame->left * right[1], origin[2] + frame->down * up[2] + frame->left * right[2], 0, 1, red, green, blue, alpha);
+       transpolyvert(origin[0] + frame->up * up[0] + frame->left * right[0], origin[1] + frame->up * up[1] + frame->left * right[1], origin[2] + frame->up * up[2] + frame->left * right[2], 0, 0, red, green, blue, alpha);
+       transpolyvert(origin[0] + frame->up * up[0] + frame->right * right[0], origin[1] + frame->up * up[1] + frame->right * right[1], origin[2] + frame->up * up[2] + frame->right * right[2], 1, 0, red, green, blue, alpha);
+       transpolyvert(origin[0] + frame->down * up[0] + frame->right * right[0], origin[1] + frame->down * up[1] + frame->right * right[1], origin[2] + frame->down * up[2] + frame->right * right[2], 1, 1, red, green, blue, alpha);
+       transpolyend();
+}
+
+/*
+=================
+R_DrawSpriteModel
+
+=================
+*/
+void R_DrawSpriteModel (entity_t *e)
+{
+       mspriteframe_t  *oldframe, *newframe;
+       float                   lerp, ilerp;
+       vec3_t                  forward, right, up, org, color;
+       msprite_t               *psprite;
+
+       // don't even bother culling, because it's just a single
+       // polygon without a surface cache
+       R_GetSpriteFrame (e, &oldframe, &newframe, &lerp);
+       if (lerp < 0) lerp = 0;
+       if (lerp > 1) lerp = 1;
+       if (isRagePro) // LordHavoc: no alpha scaling supported on per pixel alpha images on ATI Rage Pro... ACK!
+               lerp = 1;
+       ilerp = 1.0 - lerp;
+       psprite = e->model->cache.data;
+
+       if (psprite->type == SPR_ORIENTED)
+       {       // bullet marks on walls
+               AngleVectors (e->angles, forward, right, up);
+               VectorSubtract(e->origin, vpn, org);
+       }
+       else
+       {       // normal sprite
+               VectorCopy(vup, up);
+               VectorCopy(vright, right);
+               VectorCopy(e->origin, org);
+       }
+       if (e->scale != 1)
+       {
+               VectorScale(up, e->scale, up);
+               VectorScale(right, e->scale, right);
+       }
+
+       if (e->model->flags & EF_FULLBRIGHT || e->effects & EF_FULLBRIGHT)
+       {
+               color[0] = e->colormod[0] * 255;
+               color[1] = e->colormod[1] * 255;
+               color[2] = e->colormod[2] * 255;
+       }
+       else
+       {
+               R_LightPoint (color, e->origin);
+               R_DynamicLightPointNoMask(color, e->origin);
+       }
+
+       // LordHavoc: interpolated sprite rendering
+       if (ilerp != 0)
+               GL_DrawSpriteImage(oldframe, org, up, right, color[0],color[1],color[2],e->alpha*255*ilerp);
+       if (lerp != 0)
+               GL_DrawSpriteImage(newframe, org, up, right, color[0],color[1],color[2],e->alpha*255*lerp);
+}
+
index 88b8b245811ab9a9115b4e0d943682cdc2f8afbf..5bc09aff444cb554811a8031f77d2cdb2dce8169 100644 (file)
--- a/render.h
+++ b/render.h
@@ -126,34 +126,38 @@ extern vec3_t     r_origin, vpn, vright, vup;
 
 extern struct texture_s        *r_notexture_mip;
 
-void R_Init (void);
-void R_InitTextures (void);
-void R_InitEfrags (void);
-void R_RenderView (void);              // must set r_refdef first
-void R_ViewChanged (vrect_t *pvrect, int lineadj, float aspect);
+extern void R_Init (void);
+extern void R_InitTextures (void);
+extern void R_InitEfrags (void);
+extern void R_RenderView (void);               // must set r_refdef first
+extern void R_ViewChanged (vrect_t *pvrect, int lineadj, float aspect);
                                                                // called whenever r_refdef or vid change
 // LordHavoc: changed this for sake of GLQuake
-void R_InitSky (byte *src, int bytesperpixel); // called at level load
-//void R_InitSky (struct texture_s *mt);       // called at level load
+extern void R_InitSky (byte *src, int bytesperpixel);  // called at level load
+//extern void R_InitSky (struct texture_s *mt);        // called at level load
 
-void R_AddEfrags (entity_t *ent);
-void R_RemoveEfrags (entity_t *ent);
+extern void R_AddEfrags (entity_t *ent);
+extern void R_RemoveEfrags (entity_t *ent);
 
-void R_NewMap (void);
+extern void R_NewMap (void);
 
 
-void R_ParseParticleEffect (void);
-void R_RunParticleEffect (vec3_t org, vec3_t dir, int color, int count);
-void R_RocketTrail (vec3_t start, vec3_t end, int type, entity_t *ent);
-void R_RocketTrail2 (vec3_t start, vec3_t end, int type, entity_t *ent);
-void R_SparkShower (vec3_t org, vec3_t dir, int count);
-void R_BloodPuff (vec3_t org);
+extern void R_ParseParticleEffect (void);
+extern void R_RunParticleEffect (vec3_t org, vec3_t dir, int color, int count);
+extern void R_RocketTrail (vec3_t start, vec3_t end, int type, entity_t *ent);
+extern void R_RocketTrail2 (vec3_t start, vec3_t end, int type, entity_t *ent);
+extern void R_SparkShower (vec3_t org, vec3_t dir, int count);
+extern void R_BloodPuff (vec3_t org);
 
-void R_EntityParticles (entity_t *ent);
-void R_BlobExplosion (vec3_t org);
-void R_ParticleExplosion (vec3_t org, int smoke);
-void R_ParticleExplosion2 (vec3_t org, int colorStart, int colorLength);
-void R_LavaSplash (vec3_t org);
-void R_TeleportSplash (vec3_t org);
+extern void R_EntityParticles (entity_t *ent);
+extern void R_BlobExplosion (vec3_t org);
+extern void R_ParticleExplosion (vec3_t org, int smoke);
+extern void R_ParticleExplosion2 (vec3_t org, int colorStart, int colorLength);
+extern void R_LavaSplash (vec3_t org);
+extern void R_TeleportSplash (vec3_t org);
 
-void R_PushDlights (void);
+extern void R_PushDlights (void);
+
+extern void R_DynamicLightPoint(vec3_t color, vec3_t org, int *dlightbits);
+extern void R_DynamicLightPointNoMask(vec3_t color, vec3_t org);
+extern void R_LightPoint (vec3_t color, vec3_t p);
index ee8f980052182c83dface86e86639924f7ad82c9..4514e973742fc27af451e5f0ef2f99f3acb20694 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -192,11 +192,7 @@ void SV_SendServerinfo (client_t *client)
        char                    message[2048];
 
        MSG_WriteByte (&client->message, svc_print);
-#ifdef NEHAHRA
-       sprintf (message, "%c\nDPNEHAHRA VERSION %4.2f SERVER (%i CRC)", 2, VERSION, pr_crc);
-#else
        sprintf (message, "%c\nDARKPLACES VERSION %4.2f SERVER (%i CRC)", 2, VERSION, pr_crc);
-#endif
        MSG_WriteString (&client->message,message);
 
        MSG_WriteByte (&client->message, svc_serverinfo);
index 56f1d1906148f378608b8d60619406681a1cbcd9..ffe1ce9c2b667086abbede91b1852bc94c4c4ac9 100644 (file)
--- a/sv_phys.c
+++ b/sv_phys.c
@@ -449,6 +449,24 @@ void SV_PushMove (edict_t *pusher, float movetime)
        vec3_t          moved_from[MAX_EDICTS];
        float           savesolid;
 
+       switch ((int) pusher->v.solid)
+       {
+       // LordHavoc: valid pusher types
+       case SOLID_BSP:
+       case SOLID_BBOX:
+       case SOLID_SLIDEBOX:
+       case SOLID_CORPSE: // LordHavoc: this would be weird...
+               break;
+       // LordHavoc: no collisions
+       case SOLID_NOT:
+       case SOLID_TRIGGER:
+               VectorMA (pusher->v.origin, movetime, pusher->v.velocity, pusher->v.origin);
+               pusher->v.ltime += movetime;
+               SV_LinkEdict (pusher, false);
+               return;
+       default:
+               Host_Error("SV_PushMove: unrecognized solid type %f\n", pusher->v.solid);
+       }
        if (!pusher->v.velocity[0] && !pusher->v.velocity[1] && !pusher->v.velocity[2])
        {
                pusher->v.ltime += movetime;
@@ -537,8 +555,7 @@ void SV_PushMove (edict_t *pusher, float movetime)
                                SV_LinkEdict (pusher, false);
                                pusher->v.ltime -= movetime;
 
-                               // if the pusher has a "blocked" function, call it
-                               // otherwise, just stay in place until the obstacle is gone
+                               // if the pusher has a "blocked" function, call it, otherwise just stay in place until the obstacle is gone
                                if (pusher->v.blocked)
                                {
                                        pr_global_struct->self = EDICT_TO_PROG(pusher);
@@ -547,6 +564,7 @@ void SV_PushMove (edict_t *pusher, float movetime)
                                }
                                
                                // move back any entities we already moved
+                               num_moved--; // LordHavoc: pop off check, because it was already restored
                                for (i=0 ; i<num_moved ; i++)
                                {
                                        VectorCopy (moved_from[i], moved_edict[i]->v.origin);
@@ -571,10 +589,11 @@ void SV_PushRotate (edict_t *pusher, float movetime)
        int                     i, e;
        edict_t         *check;
        vec3_t          move, a, amove;
-       vec3_t          entorig, pushorig;
+       vec3_t          entorigin, entangles, pushorigin, pushangles;
        int                     num_moved;
        edict_t         *moved_edict[MAX_EDICTS];
        vec3_t          moved_from[MAX_EDICTS];
+       vec3_t          angled_from[MAX_EDICTS];
        vec3_t          org, org2;
        vec3_t          forward, right, up;
        float           savesolid;
@@ -591,7 +610,8 @@ void SV_PushRotate (edict_t *pusher, float movetime)
        VectorSubtract (vec3_origin, amove, a);
        AngleVectors (a, forward, right, up);
 
-       VectorCopy (pusher->v.angles, pushorig);
+       VectorCopy (pusher->v.origin, pushorigin);
+       VectorCopy (pusher->v.angles, pushangles);
        
 // move the pusher to it's final position
 
@@ -608,21 +628,20 @@ void SV_PushRotate (edict_t *pusher, float movetime)
                if (check->free)
                        continue;
                if (check->v.movetype == MOVETYPE_PUSH
-               || check->v.movetype == MOVETYPE_NONE
-               || check->v.movetype == MOVETYPE_FOLLOW
-               || check->v.movetype == MOVETYPE_NOCLIP)
+                || check->v.movetype == MOVETYPE_NONE
+                || check->v.movetype == MOVETYPE_FOLLOW
+                || check->v.movetype == MOVETYPE_NOCLIP)
                        continue;
 
        // if the entity is standing on the pusher, it will definately be moved
-               if ( ! ( ((int)check->v.flags & FL_ONGROUND)
-               && PROG_TO_EDICT(check->v.groundentity) == pusher) )
+               if (!(((int)check->v.flags & FL_ONGROUND) && PROG_TO_EDICT(check->v.groundentity) == pusher))
                {
-                       if ( check->v.absmin[0] >= pusher->v.absmax[0]
-                       || check->v.absmin[1] >= pusher->v.absmax[1]
-                       || check->v.absmin[2] >= pusher->v.absmax[2]
-                       || check->v.absmax[0] <= pusher->v.absmin[0]
-                       || check->v.absmax[1] <= pusher->v.absmin[1]
-                       || check->v.absmax[2] <= pusher->v.absmin[2] )
+                       if (check->v.absmin[0] >= pusher->v.absmax[0]
+                        || check->v.absmin[1] >= pusher->v.absmax[1]
+                        || check->v.absmin[2] >= pusher->v.absmax[2]
+                        || check->v.absmax[0] <= pusher->v.absmin[0]
+                        || check->v.absmax[1] <= pusher->v.absmin[1]
+                        || check->v.absmax[2] <= pusher->v.absmin[2])
                                continue;
 
                // see if the ent's bbox is inside the pusher's final position
@@ -634,8 +653,10 @@ void SV_PushRotate (edict_t *pusher, float movetime)
                if (check->v.movetype != MOVETYPE_WALK)
                        check->v.flags = (int)check->v.flags & ~FL_ONGROUND;
                
-               VectorCopy (check->v.origin, entorig);
+               VectorCopy (check->v.origin, entorigin);
                VectorCopy (check->v.origin, moved_from[num_moved]);
+               VectorCopy (check->v.angles, entangles);
+               VectorCopy (check->v.angles, angled_from[num_moved]);
                moved_edict[num_moved] = check;
                num_moved++;
 
@@ -652,6 +673,8 @@ void SV_PushRotate (edict_t *pusher, float movetime)
                SV_PushEntity (check, move);
                pusher->v.solid = savesolid; // LordHavoc: restore to correct solid type
 
+               VectorAdd (check->v.angles, amove, check->v.angles);
+
        // if it is still inside the pusher, block
                if (SV_TestEntityPosition (check))
                {       // fail the move
@@ -664,15 +687,16 @@ void SV_PushRotate (edict_t *pusher, float movetime)
                                continue;
                        }
                        
-                       VectorCopy (entorig, check->v.origin);
+                       VectorCopy (entorigin, check->v.origin);
+                       VectorCopy (entangles, check->v.angles);
                        SV_LinkEdict (check, true);
 
-                       VectorCopy (pushorig, pusher->v.angles);
+                       VectorCopy (pushorigin, pusher->v.origin);
+                       VectorCopy (pushangles, pusher->v.angles);
                        SV_LinkEdict (pusher, false);
                        pusher->v.ltime -= movetime;
 
-                       // if the pusher has a "blocked" function, call it
-                       // otherwise, just stay in place until the obstacle is gone
+                       // if the pusher has a "blocked" function, call it, otherwise just stay in place until the obstacle is gone
                        if (pusher->v.blocked)
                        {
                                pr_global_struct->self = EDICT_TO_PROG(pusher);
@@ -681,23 +705,17 @@ void SV_PushRotate (edict_t *pusher, float movetime)
                        }
                        
                // move back any entities we already moved
+                       num_moved--; // LordHavoc: pop off check, because it was already restored
                        for (i=0 ; i<num_moved ; i++)
                        {
                                VectorCopy (moved_from[i], moved_edict[i]->v.origin);
-                               VectorSubtract (moved_edict[i]->v.angles, amove, moved_edict[i]->v.angles);
+                               VectorCopy (angled_from[i], moved_edict[i]->v.angles);
                                SV_LinkEdict (moved_edict[i], false);
                        }
                        return;
                }
-               else
-               {
-                       VectorAdd (check->v.angles, amove, check->v.angles);
-               }
        }
-
-       
 }
-//#endif
 
 /*
 ================
@@ -713,6 +731,7 @@ void SV_Physics_Pusher (edict_t *ent)
 
        oldltime = ent->v.ltime;
        
+       /*
        thinktime = ent->v.nextthink;
        if (thinktime < ent->v.ltime + host_frametime)
        {
@@ -730,6 +749,23 @@ void SV_Physics_Pusher (edict_t *ent)
                else
                        SV_PushMove (ent, movetime);    // advances ent->v.ltime if not blocked
        }
+       */
+       if (ent->v.avelocity[0] || ent->v.avelocity[1] || ent->v.avelocity[2])
+               SV_PushRotate (ent, host_frametime);
+       else
+       {
+               thinktime = ent->v.nextthink;
+               if (thinktime < ent->v.ltime + host_frametime)
+               {
+                       movetime = thinktime - ent->v.ltime;
+                       if (movetime < 0)
+                               movetime = 0;
+               }
+               else
+                       movetime = host_frametime;
+               if (movetime)
+                       SV_PushMove (ent, movetime);    // advances ent->v.ltime if not blocked
+       }
                
        if (thinktime > oldltime && thinktime <= ent->v.ltime)
        {
@@ -1354,25 +1390,33 @@ void SV_Physics (void)
                        continue;
 
                if (pr_global_struct->force_retouch)
-               {
                        SV_LinkEdict (ent, true);       // force retouch even for stationary
-               }
 
                if (i > 0 && i <= svs.maxclients)
+               {
                        SV_Physics_Client (ent, i);
-               else if (ent->v.movetype == MOVETYPE_PUSH)
+                       continue;
+               }
+
+               switch ((int) ent->v.movetype)
+               {
+               case MOVETYPE_PUSH:
                        SV_Physics_Pusher (ent);
-               else if (ent->v.movetype == MOVETYPE_NONE)
+                       break;
+               case MOVETYPE_NONE:
                        SV_Physics_None (ent);
-               else if (ent->v.movetype == MOVETYPE_FOLLOW)
+                       break;
+               case MOVETYPE_FOLLOW:
                        SV_Physics_Follow (ent);
-               else if (ent->v.movetype == MOVETYPE_NOCLIP)
+                       break;
+               case MOVETYPE_NOCLIP:
                        SV_Physics_Noclip (ent);
-               else if (ent->v.movetype == MOVETYPE_STEP)
+                       break;
+               case MOVETYPE_STEP:
                        SV_Physics_Step (ent);
+                       break;
                // LordHavoc: added support for MOVETYPE_WALK on normal entities! :)
-               else if (ent->v.movetype == MOVETYPE_WALK)
-               {
+               case MOVETYPE_WALK:
                        if (SV_RunThink (ent))
                        {
                                if (!SV_CheckWater (ent) && ! ((int)ent->v.flags & FL_WATERJUMP) )
@@ -1380,15 +1424,18 @@ void SV_Physics (void)
                                SV_CheckStuck (ent);
                                SV_WalkMove (ent);
                        }
-               }
-               else if (ent->v.movetype == MOVETYPE_TOSS 
-               || ent->v.movetype == MOVETYPE_BOUNCE
-               || ent->v.movetype == MOVETYPE_BOUNCEMISSILE
-               || ent->v.movetype == MOVETYPE_FLY
-               || ent->v.movetype == MOVETYPE_FLYMISSILE)
+                       break;
+               case MOVETYPE_TOSS:
+               case MOVETYPE_BOUNCE:
+               case MOVETYPE_BOUNCEMISSILE:
+               case MOVETYPE_FLY:
+               case MOVETYPE_FLYMISSILE:
                        SV_Physics_Toss (ent);
-               else
-                       Host_Error ("SV_Physics: bad movetype %i", (int)ent->v.movetype);                       
+                       break;
+               default:
+                       Host_Error ("SV_Physics: bad movetype %i", (int)ent->v.movetype);
+                       break;
+               }
        }
        
        if (pr_global_struct->force_retouch)
index c24d4cf05f46a2c0a9a680a4133540c2f311d2c4..45c1e5dbafe15fe35b2cf2a82088b2936fbfd925 100644 (file)
@@ -396,7 +396,6 @@ int main (int c, char **v)
 {
 
        double          time, oldtime, newtime;
-       quakeparms_t parms;
        extern int vcrFile;
        extern int recording;
        int j;
@@ -406,31 +405,31 @@ int main (int c, char **v)
 //     signal(SIGFPE, floating_point_exception_handler);
        signal(SIGFPE, SIG_IGN);
 
-       memset(&parms, 0, sizeof(parms));
+       memset(&host_parms, 0, sizeof(host_parms));
 
        COM_InitArgv(c, v);
-       parms.argc = com_argc;
-       parms.argv = com_argv;
+       host_parms.argc = com_argc;
+       host_parms.argv = com_argv;
 
-       parms.memsize = 24*1024*1024;
+       host_parms.memsize = 24*1024*1024;
 
        j = COM_CheckParm("-mem");
        if (j)
-               parms.memsize = (int) (atof(com_argv[j+1]) * 1024 * 1024);
-       parms.membase = malloc (parms.memsize);
-       if (!parms.membase)
+               host_parms.memsize = (int) (atof(com_argv[j+1]) * 1024 * 1024);
+       host_parms.membase = malloc (host_parms.memsize);
+       if (!host_parms.membase)
        {
                printf("Unable to allocate heap memory\n");
                return 1;
        }
 
-       parms.basedir = basedir;
+       host_parms.basedir = basedir;
 // caching is disabled by default, use -cachedir to enable
-//     parms.cachedir = cachedir;
+//     host_parms.cachedir = cachedir;
 
        fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
 
-       Host_Init(&parms);
+       Host_Init();
 
        Sys_Init();
 
index e7013094a2259aefd73e09a1e9b2153f4422bd7e..d0f0d7930a6fc3786105185dfdf7a04633662122 100644 (file)
--- a/sys_win.c
+++ b/sys_win.c
@@ -65,6 +65,7 @@ volatile int                                  sys_checksum;
 Sys_PageIn
 ================
 */
+/*
 void Sys_PageIn (void *ptr, int size)
 {
        byte    *x;
@@ -84,6 +85,7 @@ void Sys_PageIn (void *ptr, int size)
                }
        }
 }
+*/
 
 
 /*
@@ -628,17 +630,13 @@ HINSTANCE global_hInstance;
 int                    global_nCmdShow;
 char           *argv[MAX_NUM_ARGVS];
 static char    *empty_string = "";
-HWND           hwnd_dialog;
-
 
 int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
 {
-       quakeparms_t    parms;
        double                  time, oldtime, newtime/*, timediff*/;
        MEMORYSTATUS    lpBuffer;
        static  char    cwd[1024];
        int                             t;
-       RECT                    rect;
 
     /* previous instances do not exist in Win32 */
     if (hPrevInstance)
@@ -656,21 +654,21 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin
        if (cwd[strlen(cwd)-1] == '/')
                cwd[strlen(cwd)-1] = 0;
 
-       parms.basedir = cwd;
-       parms.cachedir = NULL;
+       host_parms.basedir = cwd;
+       host_parms.cachedir = NULL;
 
-       parms.argc = 1;
+       host_parms.argc = 1;
        argv[0] = empty_string;
 
-       while (*lpCmdLine && (parms.argc < MAX_NUM_ARGVS))
+       while (*lpCmdLine && (host_parms.argc < MAX_NUM_ARGVS))
        {
                while (*lpCmdLine && ((*lpCmdLine <= 32) || (*lpCmdLine > 126)))
                        lpCmdLine++;
 
                if (*lpCmdLine)
                {
-                       argv[parms.argc] = lpCmdLine;
-                       parms.argc++;
+                       argv[host_parms.argc] = lpCmdLine;
+                       host_parms.argc++;
 
                        while (*lpCmdLine && ((*lpCmdLine > 32) && (*lpCmdLine <= 126)))
                                lpCmdLine++;
@@ -684,79 +682,45 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin
                }
        }
 
-       parms.argv = argv;
+       host_parms.argv = argv;
 
-       COM_InitArgv (parms.argc, parms.argv);
+       COM_InitArgv (host_parms.argc, host_parms.argv);
 
-       parms.argc = com_argc;
-       parms.argv = com_argv;
+       host_parms.argc = com_argc;
+       host_parms.argv = com_argv;
 
        isDedicated = (COM_CheckParm ("-dedicated") != 0);
 
-       if (!isDedicated)
-       {
-               hwnd_dialog = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, NULL);
-
-               if (hwnd_dialog)
-               {
-                       if (GetWindowRect (hwnd_dialog, &rect))
-                       {
-                               if (rect.left > (rect.top * 2))
-                               {
-                                       SetWindowPos (hwnd_dialog, 0,
-                                               (rect.left / 2) - ((rect.right - rect.left) / 2),
-                                               rect.top, 0, 0,
-                                               SWP_NOZORDER | SWP_NOSIZE);
-                               }
-                       }
-
-                       ShowWindow (hwnd_dialog, SW_SHOWDEFAULT);
-                       UpdateWindow (hwnd_dialog);
-                       SetForegroundWindow (hwnd_dialog);
-               }
-       }
-
 // take the greater of all the available memory or half the total memory,
 // but at least 8 Mb and no more than 16 Mb, unless they explicitly
 // request otherwise
-       parms.memsize = lpBuffer.dwAvailPhys;
+       host_parms.memsize = lpBuffer.dwAvailPhys;
 
-       if (parms.memsize < MINIMUM_WIN_MEMORY)
-               parms.memsize = MINIMUM_WIN_MEMORY;
+       if (host_parms.memsize < MINIMUM_WIN_MEMORY)
+               host_parms.memsize = MINIMUM_WIN_MEMORY;
 
-       if (parms.memsize < (lpBuffer.dwTotalPhys >> 1))
-               parms.memsize = lpBuffer.dwTotalPhys >> 1;
+       if (host_parms.memsize < (lpBuffer.dwTotalPhys >> 1))
+               host_parms.memsize = lpBuffer.dwTotalPhys >> 1;
 
-       if (parms.memsize > MAXIMUM_WIN_MEMORY)
-               parms.memsize = MAXIMUM_WIN_MEMORY;
+       if (host_parms.memsize > MAXIMUM_WIN_MEMORY)
+               host_parms.memsize = MAXIMUM_WIN_MEMORY;
 
-       if (COM_CheckParm ("-heapsize"))
+       if ((t = COM_CheckParm("-heapsize")))
        {
-               t = COM_CheckParm("-heapsize") + 1;
-
+               t++;
                if (t < com_argc)
-                       parms.memsize = atoi (com_argv[t]) * 1024;
+                       host_parms.memsize = atoi (com_argv[t]) * 1024;
        }
-
-       if (COM_CheckParm ("-mem"))
+       else if ((t = COM_CheckParm("-mem")) || (t = COM_CheckParm("-winmem")))
        {
-               t = COM_CheckParm("-mem") + 1;
-
-               if (t < com_argc)
-                       parms.memsize = atoi (com_argv[t]) * 1048576;
-       }
-
-       if (COM_CheckParm ("-winmem"))
-       {
-               t = COM_CheckParm("-winmem") + 1;
-
+               t++;
                if (t < com_argc)
-                       parms.memsize = atoi (com_argv[t]) * 1048576;
+                       host_parms.memsize = atoi (com_argv[t]) * 1048576;
        }
 
-       parms.membase = malloc (parms.memsize);
+       host_parms.membase = malloc (host_parms.memsize);
 
-       if (!parms.membase)
+       if (!host_parms.membase)
                Sys_Error ("Not enough memory free; check disk space\n");
 
 //     Sys_PageIn (parms.membase, parms.memsize);
@@ -804,7 +768,7 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin
        S_BlockSound ();
 
        Sys_Printf ("Host_Init\n");
-       Host_Init (&parms);
+       Host_Init ();
 
        oldtime = Sys_FloatTime ();
 
index 95d7e5d8211073ed3cc803c2bb51728ebd85e4ab..ec32703f922a963f4ed28d8f5552c7b9113fa60e 100644 (file)
@@ -263,20 +263,18 @@ char      *newargv[256];
 int main (int argc, char **argv)
 {
     MSG        msg;
-       quakeparms_t    parms;
        double                  time, oldtime;
        static  char    cwd[1024];
 
-       memset (&parms, 0, sizeof(parms));
+       memset (&host_parms, 0, sizeof(host_parms));
 
-       parms.memsize = 16384*1024;
-       parms.membase = malloc (parms.memsize);
+       host_parms.memsize = 16384*1024;
+       host_parms.membase = malloc (parms.memsize);
 
        _getcwd (cwd, sizeof(cwd));
        if (cwd[strlen(cwd)-1] == '\\')
                cwd[strlen(cwd)-1] = 0;
-       parms.basedir = cwd; //"f:/quake";
-//     parms.basedir = "f:\\quake";
+       host_parms.basedir = cwd;
 
        COM_InitArgv (argc, argv);
 
@@ -290,11 +288,11 @@ int main (int argc, char **argv)
                COM_InitArgv (argc, argv);
        }
 
-       parms.argc = argc;
-       parms.argv = argv;
+       host_parms.argc = argc;
+       host_parms.argv = argv;
 
        printf ("Host_Init\n");
-       Host_Init (&parms);
+       Host_Init ();
 
        oldtime = Sys_FloatTime ();
 
diff --git a/vid.h b/vid.h
index 1ba61753c9556cc74b4e634705f6758970b7155b..5126c8891dc55aa5202b674a922691b94c82ab86 100644 (file)
--- a/vid.h
+++ b/vid.h
@@ -42,22 +42,25 @@ typedef struct
 } viddef_t;
 
 extern viddef_t        vid;                            // global video state
-extern unsigned short  d_8to16table[256];
-extern unsigned        d_8to24table[256];
 extern void (*vid_menudrawfn)(void);
 extern void (*vid_menukeyfn)(int key);
 
-void   VID_SetPalette (unsigned char *palette);
-// called at startup
+extern qboolean isG200;
+extern qboolean isRagePro;
+extern qboolean gl_mtexable;
+extern qboolean gl_arrays;
 
-void   VID_Init (unsigned char *palette);
-// Called at startup to set up translation tables, takes 256 8 bit RGB values
-// the palette data will go away after the call, so it must be copied off if
-// the video driver will need it again
+void GL_Init (void);
+
+void VID_CheckMultiTexture();
+void VID_CheckVertexArrays();
+
+void   VID_Init ();
+// Called at startup
 
 void   VID_Shutdown (void);
 // Called at shutdown
 
-int VID_SetMode (int modenum, unsigned char *palette);
+int VID_SetMode (int modenum);
 // sets the mode; only used by the Quake engine for resetting to mode 0 (the
 // base mode) on memory allocation failures
index 7be5d671f19f2c3026c1a429fa2cbcebc54cca18..326e59cfea64798682b6ced61edbcc95efe401a6 100644 (file)
 #include <GL/fxmesa.h>
 #include <glide/sst1vid.h>
 
-#define WARP_WIDTH              320
-#define WARP_HEIGHT             200
 
-
-//unsigned short       d_8to16table[256];
 unsigned               d_8to24table[256];
 unsigned char  d_15to8table[65536];
 
@@ -75,17 +71,12 @@ const char *gl_renderer;
 const char *gl_version;
 const char *gl_extensions;
 
-void (*qglColorTableEXT) (int, int, int, int, int, const void*);
-void (*qgl3DfxSetPaletteEXT) (GLuint *);
 void (*qglMTexCoord2f) (GLenum, GLfloat, GLfloat);
 void (*qglSelectTexture) (GLenum);
 
 int gl_mtex_enum = 0;
 
 // LordHavoc: in GLX these are never set, simply provided to make the rest of the code work
-qboolean is8bit = false;
-qboolean isPermedia = false;
-qboolean isATI = false;
 qboolean isG200 = false;
 qboolean isRagePro = false;
 qboolean gl_mtexable = false;
@@ -131,13 +122,17 @@ void InitSig(void)
        signal(SIGTERM, signal_handler);
 }
 
+// LordHavoc: FIXME or something?
+void VID_CheckVertexArrays()
+{
+}
+
 /*
-       CheckMultiTextureExtensions
+       VID_CheckMultitexture
 
        Check for ARB, SGIS, or EXT multitexture support
 */
-void
-CheckMultiTextureExtensions ( void )
+void VID_CheckMultitexture()
 {
        Con_Printf ("Checking for multitexture... ");
        if (COM_CheckParm ("-nomtex"))
@@ -158,16 +153,17 @@ CheckMultiTextureExtensions ( void )
                qglSelectTexture = (void *)dlsym(dlhand, "glActiveTextureARB");
                gl_mtex_enum = GL_TEXTURE0_ARB;
                gl_mtexable = true;
-       } else if (strstr(gl_extensions, "GL_SGIS_multitexture "))
+       }
+       else if (strstr(gl_extensions, "GL_SGIS_multitexture "))
        {
                Con_Printf ("GL_SGIS_multitexture\n");
                qglMTexCoord2f = (void *)dlsym(dlhand, "glMTexCoord2fSGIS");
                qglSelectTexture = (void *)dlsym(dlhand, "glSelectTextureSGIS");
                gl_mtex_enum = TEXTURE0_SGIS;
                gl_mtexable = true;
-       } else {
-               Con_Printf ("none found\n");
        }
+       else
+               Con_Printf ("none found\n");
        dlclose(dlhand);
        dlhand = NULL;          
 }
@@ -175,43 +171,8 @@ CheckMultiTextureExtensions ( void )
 
 typedef void (GLAPIENTRY *gl3DfxSetDitherModeEXT_FUNC) (GrDitherMode_t mode);
 
-/*
-===============
-GL_Init
-===============
-*/
-void GL_Init (void)
+void VID_SetupDithering()
 {
-       gl_vendor = glGetString (GL_VENDOR);
-       Con_Printf ("GL_VENDOR: %s\n", gl_vendor);
-       gl_renderer = glGetString (GL_RENDERER);
-       Con_Printf ("GL_RENDERER: %s\n", gl_renderer);
-
-       gl_version = glGetString (GL_VERSION);
-       Con_Printf ("GL_VERSION: %s\n", gl_version);
-       gl_extensions = glGetString (GL_EXTENSIONS);
-       Con_Printf ("GL_EXTENSIONS: %s\n", gl_extensions);
-
-       CheckMultiTextureExtensions ();
-
-       glCullFace(GL_FRONT);
-       glEnable(GL_TEXTURE_2D);
-
-       glEnable(GL_ALPHA_TEST);
-       glAlphaFunc(GL_GREATER, 0.666);
-
-       glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
-       glShadeModel (GL_FLAT);
-
-       glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-       glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-       glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
-       glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
-
-       glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
-       glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-
        Con_Printf ("Dithering: ");
 
        dlhand = dlopen (NULL, RTLD_LAZY);
@@ -339,83 +300,7 @@ findres(int *width, int *height)
        return GR_RESOLUTION_640x480;
 }
 
-qboolean VID_Is8bit(void)
-{
-       return is8bit;
-}
-
-typedef void (GLAPIENTRY *glColorTableEXT_FUNC) (GLenum, GLenum, GLsizei, 
-               GLenum, GLenum, const GLvoid *);
-typedef void (GLAPIENTRY *gl3DfxSetPaletteEXT_FUNC) (GLuint *pal);
-
-void VID_Init8bitPalette()
-{
-       // Check for 8bit Extensions and initialize them.
-       int i;
-
-       dlhand = dlopen (NULL, RTLD_LAZY);
-
-       Con_SafePrintf ("8-bit GL extensions: ");
-
-       if (dlhand == NULL) {
-               Con_SafePrintf ("unable to check.\n");
-               return;
-       }
-
-       if (COM_CheckParm("-no8bit")) {
-               Con_SafePrintf("disabled.\n");
-               return;
-       }
-
-       if (strstr(gl_extensions, "3DFX_set_global_palette") && (qgl3DfxSetPaletteEXT = dlsym(dlhand, "gl3DfxSetPaletteEXT")) != NULL)
-       {
-               GLubyte table[256][4];
-               char *oldpal;
-
-               Con_SafePrintf("3DFX_set_global_palette.\n");
-               glEnable( GL_SHARED_TEXTURE_PALETTE_EXT );
-               oldpal = (char *) d_8to24table; //d_8to24table3dfx;
-               for (i=0;i<256;i++)
-               {
-                       table[i][2] = *oldpal++;
-                       table[i][1] = *oldpal++;
-                       table[i][0] = *oldpal++;
-                       table[i][3] = 255;
-                       oldpal++;
-               }
-               qgl3DfxSetPaletteEXT((GLuint *)table);
-               is8bit = true;
-       } else if (strstr(gl_extensions, "GL_EXT_shared_texture_palette")) {
-               char thePalette[256*3];
-               char *oldPalette, *newPalette;
-               glColorTableEXT_FUNC load_texture = NULL;
-
-               Con_SafePrintf("GL_EXT_shared.\n");
-               load_texture = (void *) dlsym(dlhand, "glColorTableEXT");
-
-               glEnable( GL_SHARED_TEXTURE_PALETTE_EXT );
-               oldPalette = (char *) d_8to24table; //d_8to24table3dfx;
-               newPalette = thePalette;
-               for (i=0;i<256;i++) {
-                       *newPalette++ = *oldPalette++;
-                       *newPalette++ = *oldPalette++;
-                       *newPalette++ = *oldPalette++;
-                       oldPalette++;
-               }
-               load_texture(GL_SHARED_TEXTURE_PALETTE_EXT, GL_RGB, 256, GL_RGB, GL_UNSIGNED_BYTE, (void *) thePalette);
-               is8bit = true;
-       } else {
-               Con_SafePrintf ("not found.\n");
-       }
-
-       dlclose(dlhand);
-       dlhand = NULL;
-}
-
-extern void Check_Gamma (unsigned char *pal);
-void VID_Setup15to8Palette ();
-
-void VID_Init(unsigned char *palette)
+void VID_Init()
 {
        int i;
        GLint attribs[32];
@@ -476,18 +361,7 @@ void VID_Init(unsigned char *palette)
 
        GL_Init();
 
-       snprintf(gldir, sizeof(gldir), "%s/glquake", com_gamedir);
-       Sys_mkdir (gldir);
-
-       VID_SetPalette(palette);
-
-       Check_Gamma(palette);
-
-       // Check for 3DFX Extensions and initialize them.
-       VID_Init8bitPalette();
-
-       if (is8bit) // LordHavoc: avoid calculating 15to8 table if it won't be used
-               VID_Setup15to8Palette ();
+       VID_SetupDithering(); // 3DFX specific
 
        Con_SafePrintf ("Video mode %dx%d initialized.\n", width, height);
 
index 16e012ab16a410e11117551ca53af04a90ba1993..7e0f945044dd98e14f9b8ad16a5d4e8c2d949926 100644 (file)
--- a/vid_glx.c
+++ b/vid_glx.c
@@ -37,9 +37,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include <X11/extensions/xf86dga.h>
 #include <X11/extensions/xf86vmode.h>
 
-#define WARP_WIDTH              320
-#define WARP_HEIGHT             200
-
 static Display *dpy = NULL;
 static int scrnum;
 static Window win;
@@ -51,7 +48,6 @@ static GLXContext ctx = NULL;
 #define X_MASK (KEY_MASK | MOUSE_MASK | VisibilityChangeMask | StructureNotifyMask )
 
 
-unsigned short d_8to16table[256];
 unsigned               d_8to24table[256];
 unsigned char  d_15to8table[65536];
 
@@ -59,10 +55,11 @@ cvar_t      vid_mode = {"vid_mode","0",false};
  
 viddef_t       vid;                            // global video state
 
-static qboolean        mouse_avail;
-static qboolean        mouse_active;
-static int   mx, my;
-static int     old_mouse_x, old_mouse_y;
+static qboolean        mouse_avail = true;
+static qboolean        mouse_active = false;
+static float   mouse_x, mouse_y;
+static float   old_mouse_x, old_mouse_y;
+static int p_mouse_x, p_mouse_y;
 
 static cvar_t in_mouse = {"in_mouse", "1", false};
 static cvar_t in_dgamouse = {"in_dgamouse", "1", false};
@@ -91,8 +88,6 @@ const char *gl_renderer;
 const char *gl_version;
 const char *gl_extensions;
 
-void (*qglColorTableEXT) (int, int, int, int, int, const void*);
-void (*qgl3DfxSetPaletteEXT) (GLuint *);
 void (*qglMTexCoord2f) (GLenum, GLfloat, GLfloat);
 void (*qglSelectTexture) (GLenum);
 
@@ -102,149 +97,117 @@ void (*qglSelectTexture) (GLenum);
 int gl_mtex_enum = 0;
 
 // LordHavoc: in GLX these are never set, simply provided to make the rest of the code work
-qboolean is8bit = false;
-qboolean isPermedia = false;
-qboolean isATI = false;
 qboolean isG200 = false;
 qboolean isRagePro = false;
 qboolean gl_mtexable = false;
 qboolean gl_arrays = false;
 
 /*-----------------------------------------------------------------------*/
-void D_BeginDirectRect (int x, int y, byte *pbitmap, int width, int height)
-{
-}
-
-void D_EndDirectRect (int x, int y, int width, int height)
+static int
+XLateKey(XKeyEvent *ev/*, qboolean modified*/)
 {
-}
-
-static int XLateKey(XKeyEvent *ev)
-{
-
-       int key;
-       char buf[64];
+       char tmp[2];
+       int key = 0;
        KeySym keysym;
 
-       key = 0;
-
-       XLookupString(ev, buf, sizeof buf, &keysym, 0);
-
-       switch(keysym)
-       {
-               case XK_KP_Page_Up:      
-               case XK_Page_Up:         key = K_PGUP; break;
-
-               case XK_KP_Page_Down: 
-               case XK_Page_Down:       key = K_PGDN; break;
-
-               case XK_KP_Home: 
-               case XK_Home:    key = K_HOME; break;
-
-               case XK_KP_End:  
-               case XK_End:     key = K_END; break;
+/*     if (!modified) {*/
+               keysym = XLookupKeysym(ev, 0);
+/*     } else {
+               XLookupString(ev, tmp, 1, &keysym, NULL);
+       }*/
 
-               case XK_KP_Left: 
-               case XK_Left:    key = K_LEFTARROW; break;
+       switch(keysym) {
+               case XK_KP_Page_Up:     key = KP_PGUP; break;
+               case XK_Page_Up:        key = K_PGUP; break;
 
-               case XK_KP_Right: 
-               case XK_Right:  key = K_RIGHTARROW;             break;
+               case XK_KP_Page_Down:   key = KP_PGDN; break;
+               case XK_Page_Down:      key = K_PGDN; break;
 
-               case XK_KP_Down: 
-               case XK_Down:    key = K_DOWNARROW; break;
+               case XK_KP_Home:        key = KP_HOME; break;
+               case XK_Home:           key = K_HOME; break;
 
-               case XK_KP_Up:   
-               case XK_Up:              key = K_UPARROW;        break;
+               case XK_KP_End:         key = KP_END; break;
+               case XK_End:            key = K_END; break;
 
-               case XK_Escape: key = K_ESCAPE;         break;
+               case XK_KP_Left:        key = KP_LEFTARROW; break;
+               case XK_Left:           key = K_LEFTARROW; break;
 
-               case XK_KP_Enter: 
-               case XK_Return: key = K_ENTER;           break;
+               case XK_KP_Right:       key = KP_RIGHTARROW; break;
+               case XK_Right:          key = K_RIGHTARROW; break;
 
-               case XK_Tab:            key = K_TAB;                     break;
+               case XK_KP_Down:        key = KP_DOWNARROW; break;
+               case XK_Down:           key = K_DOWNARROW; break;
 
-               case XK_F1:              key = K_F1;                            break;
+               case XK_KP_Up:          key = KP_UPARROW; break;
+               case XK_Up:                     key = K_UPARROW; break;
 
-               case XK_F2:              key = K_F2;                            break;
+               case XK_Escape:         key = K_ESCAPE; break;
 
-               case XK_F3:              key = K_F3;                            break;
+               case XK_KP_Enter:       key = KP_ENTER; break;
+               case XK_Return:         key = K_ENTER; break;
 
-               case XK_F4:              key = K_F4;                            break;
+               case XK_Tab:            key = K_TAB; break;
 
-               case XK_F5:              key = K_F5;                            break;
+               case XK_F1:                     key = K_F1; break;
+               case XK_F2:                     key = K_F2; break;
+               case XK_F3:                     key = K_F3; break;
+               case XK_F4:                     key = K_F4; break;
+               case XK_F5:                     key = K_F5; break;
+               case XK_F6:                     key = K_F6; break;
+               case XK_F7:                     key = K_F7; break;
+               case XK_F8:                     key = K_F8; break;
+               case XK_F9:                     key = K_F9; break;
+               case XK_F10:            key = K_F10; break;
+               case XK_F11:            key = K_F11; break;
+               case XK_F12:            key = K_F12; break;
 
-               case XK_F6:              key = K_F6;                            break;
+               case XK_BackSpace:      key = K_BACKSPACE; break;
 
-               case XK_F7:              key = K_F7;                            break;
+               case XK_KP_Delete:      key = KP_DEL; break;
+               case XK_Delete:         key = K_DEL; break;
 
-               case XK_F8:              key = K_F8;                            break;
+               case XK_Pause:          key = K_PAUSE; break;
 
-               case XK_F9:              key = K_F9;                            break;
-
-               case XK_F10:            key = K_F10;                     break;
+               case XK_Shift_L:
+               case XK_Shift_R:        key = K_SHIFT; break;
 
-               case XK_F11:            key = K_F11;                     break;
+               case XK_Execute:
+               case XK_Control_L:
+               case XK_Control_R:      key = K_CTRL; break;
 
-               case XK_F12:            key = K_F12;                     break;
+               case XK_Mode_switch:
+               case XK_Alt_L:
+               case XK_Meta_L:
+               case XK_Alt_R:
+               case XK_Meta_R:         key = K_ALT; break;
 
-               case XK_BackSpace: key = K_BACKSPACE; break;
+               case XK_Caps_Lock:      key = K_CAPSLOCK; break;
+               case XK_KP_Begin:       key = KP_5; break;
 
-               case XK_KP_Delete: 
-               case XK_Delete: key = K_DEL; break;
+               case XK_Insert:         key = K_INS; break;
+               case XK_KP_Insert:      key = KP_INS; break;
 
-               case XK_Pause:  key = K_PAUSE;           break;
+               case XK_KP_Multiply:    key = KP_MULTIPLY; break;
+               case XK_KP_Add:         key = KP_PLUS; break;
+               case XK_KP_Subtract:    key = KP_MINUS; break;
+               case XK_KP_Divide:      key = KP_DIVIDE; break;
 
-               case XK_Shift_L:
-               case XK_Shift_R:        key = K_SHIFT;          break;
-
-               case XK_Execute: 
-               case XK_Control_L: 
-               case XK_Control_R:      key = K_CTRL;            break;
-
-               case XK_Alt_L:  
-               case XK_Meta_L: 
-               case XK_Alt_R:  
-               case XK_Meta_R: key = K_ALT;                    break;
-
-               case XK_KP_Begin: key = '5';    break;
-
-               case XK_KP_Insert: 
-               case XK_Insert:key = K_INS; break;
-
-               case XK_KP_Multiply: key = '*'; break;
-               case XK_KP_Add:  key = '+'; break;
-               case XK_KP_Subtract: key = '-'; break;
-               case XK_KP_Divide: key = '/'; break;
-
-#if 0
-               case 0x021: key = '1';break;/* [!] */
-               case 0x040: key = '2';break;/* [@] */
-               case 0x023: key = '3';break;/* [#] */
-               case 0x024: key = '4';break;/* [$] */
-               case 0x025: key = '5';break;/* [%] */
-               case 0x05e: key = '6';break;/* [^] */
-               case 0x026: key = '7';break;/* [&] */
-               case 0x02a: key = '8';break;/* [*] */
-               case 0x028: key = '9';;break;/* [(] */
-               case 0x029: key = '0';break;/* [)] */
-               case 0x05f: key = '-';break;/* [_] */
-               case 0x02b: key = '=';break;/* [+] */
-               case 0x07c: key = '\'';break;/* [|] */
-               case 0x07d: key = '[';break;/* [}] */
-               case 0x07b: key = ']';break;/* [{] */
-               case 0x022: key = '\'';break;/* ["] */
-               case 0x03a: key = ';';break;/* [:] */
-               case 0x03f: key = '/';break;/* [?] */
-               case 0x03e: key = '.';break;/* [>] */
-               case 0x03c: key = ',';break;/* [<] */
-#endif
+               /* For Sun keyboards */
+               case XK_F27:            key = K_HOME; break;
+               case XK_F29:            key = K_PGUP; break;
+               case XK_F33:            key = K_END; break;
+               case XK_F35:            key = K_PGDN; break;
 
                default:
-                       key = *(unsigned char*)buf;
-                       if (key >= 'A' && key <= 'Z')
-                               key = key - 'A' + 'a';
+                       if (keysym < 128) {
+                               /* ASCII keys */
+                               key = keysym;
+                               if (/*!modified && */((key >= 'A') && (key <= 'Z'))) {
+                                       key = key + ('a' - 'A');
+                               }
+                       }
                        break;
-       } 
+       }
 
        return key;
 }
@@ -273,19 +236,20 @@ static Cursor CreateNullCursor(Display *display, Window root)
 
 static void install_grabs(void)
 {
+        XWindowAttributes attribs_1;
+        XSetWindowAttributes attribs_2;
+
+        XGetWindowAttributes(dpy, win, &attribs_1);
+        attribs_2.event_mask = attribs_1.your_event_mask | KEY_MASK | MOUSE_MASK;
+        XChangeWindowAttributes(dpy, win, CWEventMask, &attribs_2);
 
 // inviso cursor
        XDefineCursor(dpy, win, CreateNullCursor(dpy, win));
 
-       XGrabPointer(dpy, win,
-                                True,
-                                0,
-                                GrabModeAsync, GrabModeAsync,
-                                win,
-                                None,
-                                CurrentTime);
+       XGrabPointer(dpy, win,  True, 0, GrabModeAsync, GrabModeAsync,
+                    win, None, CurrentTime);
 
-       if (in_dgamouse.value) {
+/*     if (in_dgamouse.value) {
                int MajorVersion, MinorVersion;
 
                if (!XF86DGAQueryVersion(dpy, &MajorVersion, &MinorVersion)) { 
@@ -297,18 +261,16 @@ static void install_grabs(void)
                        XF86DGADirectVideo(dpy, DefaultScreen(dpy), XF86DGADirectMouse);
                        XWarpPointer(dpy, None, win, 0, 0, 0, 0, 0, 0);
                }
-       } else {
+       } else {*/
                XWarpPointer(dpy, None, win,
                                         0, 0, 0, 0,
                                         vid.width / 2, vid.height / 2);
-       }
+/*     }*/
 
-       XGrabKeyboard(dpy, win,
-                                 False,
-                                 GrabModeAsync, GrabModeAsync,
-                                 CurrentTime);
+       XGrabKeyboard(dpy, win, False, GrabModeAsync, GrabModeAsync, CurrentTime);
 
        mouse_active = true;
+       mouse_x = mouse_y = 0;
 
 //     XSync(dpy, True);
 }
@@ -318,10 +280,10 @@ static void uninstall_grabs(void)
        if (!dpy || !win)
                return;
 
-       if (dgamouse) {
+/*     if (dgamouse) {
                dgamouse = false;
                XF86DGADirectVideo(dpy, DefaultScreen(dpy), 0);
-       }
+       }*/
 
        XUngrabPointer(dpy, CurrentTime);
        XUngrabKeyboard(dpy, CurrentTime);
@@ -338,8 +300,6 @@ static void HandleEvents(void)
 //     KeySym ks;
        int b;
        qboolean dowarp = false;
-       int mwx = vid.width/2;
-       int mwy = vid.height/2;
 
        if (!dpy)
                return;
@@ -354,24 +314,47 @@ static void HandleEvents(void)
                        break;
 
                case MotionNotify:
-                       if (mouse_active) {
+                       if (dgamouse) {
+                               mouse_x += event.xmotion.x_root/* * in_dga_mouseaccel.value*/;
+                               mouse_y += event.xmotion.y_root/* * in_dga_mouseaccel.value*/;
+                       } else {
+                               if (!p_mouse_x && !p_mouse_y) {
+                                       Con_Printf("event->xmotion.x: %d\n", event.xmotion.x); 
+                                       Con_Printf("event->xmotion.y: %d\n", event.xmotion.y); 
+                               }
+/*                             if (vid_fullscreen.value || _windowed_mouse.value) {*/
+                                       if (!event.xmotion.send_event) {
+                                               mouse_x += (event.xmotion.x - p_mouse_x);
+                                               mouse_y += (event.xmotion.y - p_mouse_y);
+                                               if (abs(vid.width/2 - event.xmotion.x) > vid.width / 4
+                                                   || abs(vid.height/2 - event.xmotion.y) > vid.height / 4) {
+                                                       dowarp = true;
+                                               }
+                                       }
+/*                             } else {
+                                       mouse_x += (event.xmotion.x - p_mouse_x);
+                                       mouse_y += (event.xmotion.y - p_mouse_y);
+                               }*/
+                               p_mouse_x = event.xmotion.x;
+                               p_mouse_y = event.xmotion.y;
+                       }
+        
+/*                     if (mouse_active) {
                                if (dgamouse) {
-                                       mx += (event.xmotion.x + win_x) * 2;
-                                       my += (event.xmotion.y + win_y) * 2;
+                                       mouse_x += (event.xmotion.x + win_x) * 2;
+                                       mouse_y += (event.xmotion.y + win_y) * 2;
                                } 
-                               else 
+                               else
                                {
-                                       mx += ((int)event.xmotion.x - mwx) * 2;
-                                       my += ((int)event.xmotion.y - mwy) * 2;
+                                       mouse_x += ((int)event.xmotion.x - mwx) * 2;
+                                       mouse_y += ((int)event.xmotion.y - mwy) * 2;
                                        mwx = event.xmotion.x;
                                        mwy = event.xmotion.y;
 
-                                       if (mx || my)
+                                       if (mouse_x || mouse_y)
                                                dowarp = true;
                                }
-                       }
-                       break;
-
+                       }*/
                        break;
 
                case ButtonPress:
@@ -412,7 +395,9 @@ static void HandleEvents(void)
 
        if (dowarp) {
                /* move the mouse to the window center again */
-               XWarpPointer(dpy, None, win, 0, 0, 0, 0, vid.width / 2, vid.height / 2);
+               p_mouse_x = vid.width / 2;
+               p_mouse_y = vid.height / 2;
+               XWarpPointer(dpy, None, win, 0, 0, 0, 0, p_mouse_x, p_mouse_y);
        }
 
 }
@@ -434,7 +419,7 @@ static void IN_ActivateMouse( void )
                return;
 
        if (!mouse_active) {
-               mx = my = 0; // don't spazz
+               mouse_x = mouse_y = 0; // don't spazz
                install_grabs();
                mouse_active = true;
        }
@@ -445,8 +430,10 @@ void VID_Shutdown(void)
 {
        if (!ctx || !dpy)
                return;
-       IN_DeactivateMouse();
+
        if (dpy) {
+               uninstall_grabs();
+
                if (ctx)
                        glXDestroyContext(dpy, ctx);
                if (win)
@@ -482,7 +469,6 @@ void InitSig(void)
        signal(SIGTERM, signal_handler);
 }
 
-/*
 void (*qglVertexPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
 void (*qglColorPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
 void (*qglTexCoordPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
@@ -490,9 +476,8 @@ void (*qglArrayElement)(GLint i);
 void (*qglDrawElements)(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
 void (*qglMTexCoord2f)(GLenum, GLfloat, GLfloat);
 void (*qglSelectTexture)(GLenum);
-void (*glColorTableEXT)(int, int, int, int, int, const void*);
 
-void CheckVertexArrays (void)
+void VID_CheckVertexArrays (void)
 {
        void *prjobj;
        if (COM_CheckParm("-novertex"))
@@ -524,9 +509,8 @@ void CheckVertexArrays (void)
        Con_Printf("...vertex array support disabled (not detected - get a better driver)\n");
        dlclose(prjobj);
 }
-*/
 
-void CheckMultiTexture(void) 
+void VID_CheckMultiTexture(void) 
 {
        void *prjobj;
        qglMTexCoord2f = NULL;
@@ -564,36 +548,6 @@ void CheckMultiTexture(void)
        dlclose(prjobj);
 }
 
-/*
-===============
-GL_Init
-===============
-*/
-extern char *QSG_EXTENSIONS;
-void GL_Init (void)
-{
-       gl_vendor = glGetString (GL_VENDOR);
-       Con_Printf ("GL_VENDOR: %s\n", gl_vendor);
-       gl_renderer = glGetString (GL_RENDERER);
-       Con_Printf ("GL_RENDERER: %s\n", gl_renderer);
-
-       gl_version = glGetString (GL_VERSION);
-       Con_Printf ("GL_VERSION: %s\n", gl_version);
-       gl_extensions = glGetString (GL_EXTENSIONS);
-       Con_Printf ("GL_EXTENSIONS: %s\n", gl_extensions);
-
-//     Con_Printf ("%s %s\n", gl_renderer, gl_version);
-
-       CheckMultiTexture();
-//     CheckVertexArrays();
-
-       // LordHavoc: report supported extensions
-       Con_Printf ("\nQSG extensions: %s\n", QSG_EXTENSIONS);
-
-       glCullFace(GL_FRONT);
-       glAlphaFunc(GL_GREATER, 0.5);
-}
-
 /*
 =================
 GL_BeginRendering
@@ -606,9 +560,6 @@ void GL_BeginRendering (int *x, int *y, int *width, int *height)
        *width = scr_width;
        *height = scr_height;
 
-//    if (!wglMakeCurrent( maindc, baseRC ))
-//             Sys_Error ("wglMakeCurrent failed");
-
 //     glViewport (*x, *y, *width, *height);
 }
 
@@ -621,72 +572,7 @@ void GL_EndRendering (void)
        glXSwapBuffers(dpy, win);
 }
 
-qboolean VID_Is8bit(void)
-{
-       return is8bit;
-}
-
-void VID_Init8bitPalette(void) 
-{
-       // Check for 8bit Extensions and initialize them.
-       int i;
-       void *prjobj;
-
-       if (!COM_CheckParm("-8bit"))
-               return;
-       if ((prjobj = dlopen(NULL, RTLD_LAZY)) == NULL)
-       {
-               Con_Printf("Unable to open symbol list for main program.\n");
-               return;
-       }
-
-       if (strstr(gl_extensions, "3DFX_set_global_palette") && (qgl3DfxSetPaletteEXT = dlsym(prjobj, "gl3DfxSetPaletteEXT")) != NULL)
-       {
-               GLubyte table[256][4];
-               char *oldpal;
-
-               Con_SafePrintf("8-bit GL extensions enabled.\n");
-               glEnable( GL_SHARED_TEXTURE_PALETTE_EXT );
-               oldpal = (char *) d_8to24table; //d_8to24table3dfx;
-               for (i=0;i<256;i++)
-               {
-                       table[i][2] = *oldpal++;
-                       table[i][1] = *oldpal++;
-                       table[i][0] = *oldpal++;
-                       table[i][3] = 255;
-                       oldpal++;
-               }
-               qgl3DfxSetPaletteEXT((GLuint *)table);
-               is8bit = true;
-
-       }
-       else if (strstr(gl_extensions, "GL_EXT_shared_texture_palette") && (qglColorTableEXT = dlsym(prjobj, "glColorTableEXT")) != NULL)
-       {
-               char thePalette[256*3];
-               char *oldPalette, *newPalette;
-
-               Con_SafePrintf("8-bit GL extensions enabled.\n");
-               glEnable( GL_SHARED_TEXTURE_PALETTE_EXT );
-               oldPalette = (char *) d_8to24table; //d_8to24table3dfx;
-               newPalette = thePalette;
-               for (i=0;i<256;i++)
-               {
-                       *newPalette++ = *oldPalette++;
-                       *newPalette++ = *oldPalette++;
-                       *newPalette++ = *oldPalette++;
-                       oldPalette++;
-               }
-               qglColorTableEXT(GL_SHARED_TEXTURE_PALETTE_EXT, GL_RGB, 256, GL_RGB, GL_UNSIGNED_BYTE, (void *) thePalette);
-               is8bit = true;
-       }
-       
-       dlclose(prjobj);
-}
-
-extern void Check_Gamma (unsigned char *pal);
-void VID_Setup15to8Palette ();
-
-void VID_Init(unsigned char *palette)
+void VID_Init()
 {
        int i;
        int attrib[] = {
@@ -855,21 +741,11 @@ void VID_Init(unsigned char *palette)
 
        GL_Init();
 
-//     sprintf (gldir, "%s/glquake", com_gamedir);
-//     Sys_mkdir (gldir);
-
-       VID_SetPalette(palette);
-
-       Check_Gamma(palette);
-
-       VID_Init8bitPalette();
-
-       if (is8bit) // LordHavoc: avoid calculating 15to8 table if it won't be used
-               VID_Setup15to8Palette ();
-
        Con_SafePrintf ("Video mode %dx%d initialized.\n", width, height);
 
        vid.recalc_refdef = 1;                          // force a surface cache flush
+
+       install_grabs();
 }
 
 void Sys_SendKeyEvents(void)
@@ -915,43 +791,39 @@ void IN_MouseMove (usercmd_t *cmd)
 {
        if (!mouse_avail)
                return;
-   
-       if (m_filter.value)
-       {
-               mx = (mx + old_mouse_x) * 0.5;
-               my = (my + old_mouse_y) * 0.5;
-       }
-       old_mouse_x = mx;
-       old_mouse_y = my;
-
-       mx *= sensitivity.value;
-       my *= sensitivity.value;
 
-// add mouse X/Y movement to cmd
-       if ( (in_strafe.state & 1) || (lookstrafe.value && (in_mlook.state & 1) ))
-               cmd->sidemove += m_side.value * mx;
-       else
-               cl.viewangles[YAW] -= m_yaw.value * mx;
-       
-       if (in_mlook.state & 1)
-               V_StopPitchDrift ();
-               
-       if ( (in_mlook.state & 1) && !(in_strafe.state & 1))
-       {
-               cl.viewangles[PITCH] += m_pitch.value * my;
-               if (cl.viewangles[PITCH] > 80)
-                       cl.viewangles[PITCH] = 80;
-               if (cl.viewangles[PITCH] < -70)
-                       cl.viewangles[PITCH] = -70;
-       }
-       else
-       {
-               if ((in_strafe.state & 1) && noclip_anglehack)
-                       cmd->upmove -= m_forward.value * my;
-               else
-                       cmd->forwardmove -= m_forward.value * my;
-       }
-       mx = my = 0;
+        if (!mouse_avail)
+                return;
+
+        if (m_filter.value) {
+                mouse_x = (mouse_x + old_mouse_x) * 0.5;
+                mouse_y = (mouse_y + old_mouse_y) * 0.5;
+
+                old_mouse_x = mouse_x;
+                old_mouse_y = mouse_y;
+        }
+
+        mouse_x *= sensitivity.value;
+        mouse_y *= sensitivity.value;
+        
+        if (in_strafe.state & 1)
+                cmd->sidemove += m_side.value * mouse_x;
+        else
+                cl.viewangles[YAW] -= m_yaw.value * mouse_x;
+                
+/*        if (freelook)*/
+                V_StopPitchDrift ();
+
+        if (/*freelook && */!(in_strafe.state & 1)) {
+                cl.viewangles[PITCH] += m_pitch.value * mouse_y;
+                cl.viewangles[PITCH] = bound (-70, cl.viewangles[PITCH], 80);
+        } else {
+                if ((in_strafe.state & 1) && noclip_anglehack)
+                        cmd->upmove -= m_forward.value * mouse_y;
+                else
+                        cmd->forwardmove -= m_forward.value * mouse_y;
+        }
+        mouse_x = mouse_y = 0.0;
 }
 
 void IN_Move (usercmd_t *cmd)
index 719e0203f7e84a1177718bed6f7adcc255328e72..589c59dc4365d4751f98461be2e6bd1b0c889f95 100644 (file)
@@ -1,104 +1,3 @@
 
 #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 ()
-{
-       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;
-       }
-}
-
-// 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)
-{
-       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++)
-                       qgamma[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;
-                       qgamma[i] = inf;
-               }
-       }
-
-       // gamma correct the palette
-       //for (i=0 ; i<768 ; i++)
-       //      pal[i] = qgamma[pal[i]];
-       // note: 32bit uploads are corrected by the upload functions
-}
index 28d1b4d37a7b29f7b695b2264c0273446b676d73..e8e7ca597b271922f18b5dfdf0689f6a46de3a97 100644 (file)
--- a/vid_wgl.c
+++ b/vid_wgl.c
@@ -26,12 +26,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #define MAX_MODE_LIST  30
 #define VID_ROW_SIZE   3
-#define WARP_WIDTH             320
-#define WARP_HEIGHT            200
 #define MAXWIDTH               10000
 #define MAXHEIGHT              10000
-#define BASEWIDTH              320
-#define BASEHEIGHT             200
 
 #define MODE_WINDOWED                  0
 #define NO_MODE                                        (MODE_WINDOWED - 1)
@@ -87,7 +83,7 @@ int                   DIBWidth, DIBHeight;
 RECT           WindowRect;
 DWORD          WindowStyle, ExWindowStyle;
 
-HWND   mainwindow, dibwindow;
+HWND   mainwindow;
 
 int                    vid_modenum = NO_MODE;
 int                    vid_realmode;
@@ -116,14 +112,10 @@ void AppActivate(BOOL fActive, BOOL minimize);
 char *VID_GetModeDescription (int mode);
 void ClearAllStates (void);
 void VID_UpdateWindowStatus (void);
-void GL_Init (void);
 
 // LordHavoc: ARB multitexture support
 int gl_mtex_enum = 0;
 
-qboolean is8bit = false;
-qboolean isPermedia = false;
-qboolean isATI = false; // LordHavoc: special differences for ATI's broken drivers
 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.
 qboolean gl_mtexable = false;
@@ -178,8 +170,7 @@ qboolean VID_SetWindowedMode (int modenum)
        DIBWidth = modelist[modenum].width;
        DIBHeight = modelist[modenum].height;
 
-       WindowStyle = WS_OVERLAPPED | WS_BORDER | WS_CAPTION | WS_SYSMENU |
-                                 WS_MINIMIZEBOX;
+       WindowStyle = WS_OVERLAPPED | WS_BORDER | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;
        ExWindowStyle = 0;
 
        rect = WindowRect;
@@ -189,47 +180,19 @@ qboolean VID_SetWindowedMode (int modenum)
        height = rect.bottom - rect.top;
 
        // Create the DIB window
-       dibwindow = CreateWindowEx (
-                ExWindowStyle,
-#ifdef NEHAHRA
-                "DPNehahraQuake",
-                "DPNehahraGLQuake",
-#else
-                "DarkPlacesQuake",
-                "DarkPlacesGLQuake",
-#endif
-                WindowStyle,
-                rect.left, rect.top,
-                width,
-                height,
-                NULL,
-                NULL,
-                global_hInstance,
-                NULL);
-
-       if (!dibwindow)
+       mainwindow = CreateWindowEx (ExWindowStyle, "DarkPlaces", "DarkPlacesGL", WindowStyle, rect.left, rect.top, width, height, NULL, NULL, global_hInstance, NULL);
+
+       if (!mainwindow)
                Sys_Error ("Couldn't create DIB window");
 
        // Center and show the DIB window
-       CenterWindow(dibwindow, WindowRect.right - WindowRect.left,
-                                WindowRect.bottom - WindowRect.top, false);
+       CenterWindow(mainwindow, WindowRect.right - WindowRect.left, WindowRect.bottom - WindowRect.top, false);
 
-       ShowWindow (dibwindow, SW_SHOWDEFAULT);
-       UpdateWindow (dibwindow);
+       ShowWindow (mainwindow, SW_SHOWDEFAULT);
+       UpdateWindow (mainwindow);
 
        modestate = MS_WINDOWED;
 
-       // LordHavoc: using GDI functions on an OpenGL window?  bad idea
-       /*
-// because we have set the background brush for the window to NULL
-// (to avoid flickering when re-sizing the window on the desktop),
-// we clear the window to black when created, otherwise it will be
-// empty while Quake starts up.
-       hdc = GetDC(dibwindow);
-       PatBlt(hdc,0,0,WindowRect.right,WindowRect.bottom,BLACKNESS);
-       ReleaseDC(dibwindow, hdc);
-       */
-
        if (vid.conheight > modelist[modenum].height)
                vid.conheight = modelist[modenum].height;
        if (vid.conwidth > modelist[modenum].width)
@@ -237,8 +200,6 @@ qboolean VID_SetWindowedMode (int modenum)
        vid.width = vid.conwidth;
        vid.height = vid.conheight;
 
-       mainwindow = dibwindow;
-
        SendMessage (mainwindow, WM_SETICON, (WPARAM)TRUE, (LPARAM)hIcon);
        SendMessage (mainwindow, WM_SETICON, (WPARAM)FALSE, (LPARAM)hIcon);
 
@@ -285,40 +246,13 @@ qboolean VID_SetFullDIBMode (int modenum)
        height = rect.bottom - rect.top;
 
        // Create the DIB window
-       dibwindow = CreateWindowEx (
-                ExWindowStyle,
-#ifdef NEHAHRA
-                "DPNehahraQuake",
-                "DPNehahraGLQuake",
-#else
-                "DarkPlacesQuake",
-                "DarkPlacesGLQuake",
-#endif
-                WindowStyle,
-                rect.left, rect.top,
-                width,
-                height,
-                NULL,
-                NULL,
-                global_hInstance,
-                NULL);
-
-       if (!dibwindow)
-               Sys_Error ("Couldn't create DIB window");
+       mainwindow = CreateWindowEx (ExWindowStyle, "DarkPlaces", "DarkPlacesGL", WindowStyle, rect.left, rect.top, width, height, NULL, NULL, global_hInstance, NULL);
 
-       ShowWindow (dibwindow, SW_SHOWDEFAULT);
-       UpdateWindow (dibwindow);
+       if (!mainwindow)
+               Sys_Error ("Couldn't create DIB window");
 
-       // LordHavoc: using GDI functions on an OpenGL window?  bad idea
-       /*
-       // Because we have set the background brush for the window to NULL
-       // (to avoid flickering when re-sizing the window on the desktop), we
-       // clear the window to black when created, otherwise it will be
-       // empty while Quake starts up.
-       hdc = GetDC(dibwindow);
-       PatBlt(hdc,0,0,WindowRect.right,WindowRect.bottom,BLACKNESS);
-       ReleaseDC(dibwindow, hdc);
-       */
+       ShowWindow (mainwindow, SW_SHOWDEFAULT);
+       UpdateWindow (mainwindow);
 
        if (vid.conheight > modelist[modenum].height)
                vid.conheight = modelist[modenum].height;
@@ -331,8 +265,6 @@ qboolean VID_SetFullDIBMode (int modenum)
        window_x = 0;
        window_y = 0;
 
-       mainwindow = dibwindow;
-
        SendMessage (mainwindow, WM_SETICON, (WPARAM)TRUE, (LPARAM)hIcon);
        SendMessage (mainwindow, WM_SETICON, (WPARAM)FALSE, (LPARAM)hIcon);
 
@@ -340,18 +272,14 @@ qboolean VID_SetFullDIBMode (int modenum)
 }
 
 
-int VID_SetMode (int modenum, unsigned char *palette)
+int VID_SetMode (int modenum)
 {
        int                             original_mode, temp;
        qboolean                stat;
     MSG                                msg;
 
-       if ((windowed && (modenum != 0)) ||
-               (!windowed && (modenum < 1)) ||
-               (!windowed && (modenum >= nummodes)))
-       {
+       if ((windowed && (modenum != 0)) || (!windowed && (modenum < 1)) || (!windowed && (modenum >= nummodes)))
                Sys_Error ("Bad video mode\n");
-       }
 
 // so Con_Printfs don't mess us up by forcing vid and snd updates
        temp = scr_disabled_for_loading;
@@ -387,9 +315,7 @@ int VID_SetMode (int modenum, unsigned char *palette)
                IN_HideMouse ();
        }
        else
-       {
                Sys_Error ("VID_SetMode: Bad mode type in modelist");
-       }
 
        window_width = DIBWidth;
        window_height = DIBHeight;
@@ -399,9 +325,7 @@ int VID_SetMode (int modenum, unsigned char *palette)
        scr_disabled_for_loading = temp;
 
        if (!stat)
-       {
                Sys_Error ("Couldn't set video mode");
-       }
 
 // now we try to make sure we get the focus on the mode switch, because
 // sometimes in some systems we don't.  We grab the foreground, then
@@ -410,7 +334,6 @@ int VID_SetMode (int modenum, unsigned char *palette)
 // ourselves at the top of the z order, then grab the foreground again,
 // Who knows if it helps, but it probably doesn't hurt
        SetForegroundWindow (mainwindow);
-       VID_SetPalette (palette);
        vid_modenum = modenum;
        Cvar_SetValue ("vid_mode", (float)vid_modenum);
 
@@ -422,9 +345,7 @@ int VID_SetMode (int modenum, unsigned char *palette)
 
        Sleep (100);
 
-       SetWindowPos (mainwindow, HWND_TOP, 0, 0, 0, 0,
-                                 SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW |
-                                 SWP_NOCOPYBITS);
+       SetWindowPos (mainwindow, HWND_TOP, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW | SWP_NOCOPYBITS);
 
        SetForegroundWindow (mainwindow);
 
@@ -434,8 +355,6 @@ int VID_SetMode (int modenum, unsigned char *palette)
        if (!msg_suppress_1)
                Con_SafePrintf ("Video mode %s initialized.\n", VID_GetModeDescription (vid_modenum));
 
-       VID_SetPalette (palette);
-
        vid.recalc_refdef = 1;
 
        return true;
@@ -463,16 +382,15 @@ void VID_UpdateWindowStatus (void)
 
 //====================================
 
-void (APIENTRY *qglVertexPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
-void (APIENTRY *qglColorPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
-void (APIENTRY *qglTexCoordPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
-void (APIENTRY *qglArrayElement)(GLint i);
-void (APIENTRY *qglDrawElements)(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
-void (APIENTRY *qglMTexCoord2f)(GLenum, GLfloat, GLfloat);
-void (APIENTRY *qglSelectTexture)(GLenum);
-void (APIENTRY *glColorTableEXT)(int, int, int, int, int, const void*);
+void (GLAPIENTRY *qglVertexPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
+void (GLAPIENTRY *qglColorPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
+void (GLAPIENTRY *qglTexCoordPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
+void (GLAPIENTRY *qglArrayElement)(GLint i);
+void (GLAPIENTRY *qglDrawElements)(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
+void (GLAPIENTRY *qglMTexCoord2f)(GLenum, GLfloat, GLfloat);
+void (GLAPIENTRY *qglSelectTexture)(GLenum);
 
-void CheckVertexArrays (void)
+void VID_CheckVertexArrays (void)
 {
        if (COM_CheckParm("-novertex"))
        {
@@ -498,7 +416,7 @@ void CheckVertexArrays (void)
 
 int            texture_extension_number = 1;
 
-void CheckMultiTexture(void) 
+void VID_CheckMultiTexture(void) 
 {
        qglMTexCoord2f = NULL;
        qglSelectTexture = NULL;
@@ -529,49 +447,6 @@ void CheckMultiTexture(void)
                Con_Printf("...multitexture disabled (not detected)\n");
 }
 
-/*
-===============
-GL_Init
-===============
-*/
-extern char *QSG_EXTENSIONS;
-void GL_Init (void)
-{
-       gl_vendor = glGetString (GL_VENDOR);
-       Con_Printf ("GL_VENDOR: %s\n", gl_vendor);
-       gl_renderer = glGetString (GL_RENDERER);
-       Con_Printf ("GL_RENDERER: %s\n", gl_renderer);
-
-       gl_version = glGetString (GL_VERSION);
-       Con_Printf ("GL_VERSION: %s\n", gl_version);
-       gl_extensions = glGetString (GL_EXTENSIONS);
-       Con_Printf ("GL_EXTENSIONS: %s\n", gl_extensions);
-
-//     Con_Printf ("%s %s\n", gl_renderer, gl_version);
-
-       if (strncasecmp(gl_renderer,"Permedia",8)==0)
-               isPermedia = true;
-
-       // LordHavoc: special differences for ATI (broken 8bit color when also using 32bit? weird!)
-       if (strncasecmp(gl_vendor,"ATI",3)==0)
-       {
-               isATI = true;
-               if (strncasecmp(gl_renderer,"Rage Pro",8)==0)
-                       isRagePro = true;
-       }
-       if (strncasecmp(gl_renderer,"Matrox G200 Direct3D",20)==0) // a D3D driver for GL? sigh...
-               isG200 = true;
-
-       CheckMultiTexture ();
-       CheckVertexArrays ();
-
-       // LordHavoc: report supported extensions
-       Con_Printf ("\nQSG extensions: %s\n", QSG_EXTENSIONS);
-       // LordHavoc: set up state
-       glAlphaFunc(GL_GREATER, 0.5);
-       glCullFace(GL_FRONT);
-}
-
 /*
 =================
 GL_BeginRendering
@@ -580,8 +455,6 @@ GL_BeginRendering
 */
 void GL_BeginRendering (int *x, int *y, int *width, int *height)
 {
-//     extern cvar_t gl_clear;
-
        *x = *y = 0;
        *width = WindowRect.right - WindowRect.left;
        *height = WindowRect.bottom - WindowRect.top;
@@ -649,20 +522,20 @@ void      VID_Shutdown (void)
        wglMakeCurrent(NULL, NULL);
 
                // LordHavoc: free textures before closing (may help NVIDIA)
-               for (i = 0;i < 8192;i++) temp[i] = i;
+               for (i = 0;i < 8192;i++) temp[i] = i+1;
                glDeleteTextures(8192, temp);
 
        if (hRC)
            wglDeleteContext(hRC);
 
-               if (hDC && dibwindow)
-                       ReleaseDC(dibwindow, hDC);
+               if (hDC && mainwindow)
+                       ReleaseDC(mainwindow, hDC);
 
                if (modestate == MS_FULLDIB)
                        ChangeDisplaySettings (NULL, 0);
 
-               if (maindc && dibwindow)
-                       ReleaseDC (dibwindow, maindc);
+               if (maindc && mainwindow)
+                       ReleaseDC (mainwindow, maindc);
 
                AppActivate(false, false);
        }
@@ -713,50 +586,33 @@ BOOL bSetupPixelFormat(HDC hDC)
 
 
 
-byte        scantokey[128] = 
-                                       { 
-//  0           1       2       3       4       5       6       7 
-//  8           9       A       B       C       D       E       F 
-       0  ,    27,     '1',    '2',    '3',    '4',    '5',    '6', 
-       '7',    '8',    '9',    '0',    '-',    '=',    K_BACKSPACE, 9, // 0 
-       'q',    'w',    'e',    'r',    't',    'y',    'u',    'i', 
-       'o',    'p',    '[',    ']',    13 ,    K_CTRL,'a',  's',      // 1 
-       'd',    'f',    'g',    'h',    'j',    'k',    'l',    ';', 
-       '\'' ,    '`',    K_SHIFT,'\\',  'z',    'x',    'c',    'v',      // 2 
-       'b',    'n',    'm',    ',',    '.',    '/',    K_SHIFT,'*', 
-       K_ALT,' ',   0  ,    K_F1, K_F2, K_F3, K_F4, K_F5,   // 3 
-       K_F6, K_F7, K_F8, K_F9, K_F10, K_PAUSE  ,    0  , K_HOME, 
-       K_UPARROW,K_PGUP,'-',K_LEFTARROW,'5',K_RIGHTARROW,'+',K_END, //4 
-       K_DOWNARROW,K_PGDN,K_INS,K_DEL,0,0,             0,              K_F11, 
-       K_F12,0  ,    0  ,    0  ,    0  ,    0  ,    0  ,    0,        // 5 
-       0  ,    0  ,    0  ,    0  ,    0  ,    0  ,    0  ,    0, 
-       0  ,    0  ,    0  ,    0  ,    0  ,    0  ,    0  ,    0,        // 6 
-       0  ,    0  ,    0  ,    0  ,    0  ,    0  ,    0  ,    0, 
-       0  ,    0  ,    0  ,    0  ,    0  ,    0  ,    0  ,    0         // 7 
-                                       }; 
-
-byte        shiftscantokey[128] = 
-                                       { 
-//  0           1       2       3       4       5       6       7 
-//  8           9       A       B       C       D       E       F 
-       0  ,    27,     '!',    '@',    '#',    '$',    '%',    '^', 
-       '&',    '*',    '(',    ')',    '_',    '+',    K_BACKSPACE, 9, // 0 
-       'Q',    'W',    'E',    'R',    'T',    'Y',    'U',    'I', 
-       'O',    'P',    '{',    '}',    13 ,    K_CTRL,'A',  'S',      // 1 
-       'D',    'F',    'G',    'H',    'J',    'K',    'L',    ':', 
-       '"' ,    '~',    K_SHIFT,'|',  'Z',    'X',    'C',    'V',      // 2 
-       'B',    'N',    'M',    '<',    '>',    '?',    K_SHIFT,'*', 
-       K_ALT,' ',   0  ,    K_F1, K_F2, K_F3, K_F4, K_F5,   // 3 
-       K_F6, K_F7, K_F8, K_F9, K_F10, K_PAUSE  ,    0  , K_HOME, 
-       K_UPARROW,K_PGUP,'_',K_LEFTARROW,'%',K_RIGHTARROW,'+',K_END, //4 
-       K_DOWNARROW,K_PGDN,K_INS,K_DEL,0,0,             0,              K_F11, 
-       K_F12,0  ,    0  ,    0  ,    0  ,    0  ,    0  ,    0,        // 5 
-       0  ,    0  ,    0  ,    0  ,    0  ,    0  ,    0  ,    0, 
-       0  ,    0  ,    0  ,    0  ,    0  ,    0  ,    0  ,    0,        // 6 
-       0  ,    0  ,    0  ,    0  ,    0  ,    0  ,    0  ,    0, 
-       0  ,    0  ,    0  ,    0  ,    0  ,    0  ,    0  ,    0         // 7 
-                                       }; 
+byte scantokey[128] =
+{
+//     0           1      2     3     4     5       6       7      8         9      A       B           C     D            E           F
+       0          ,27    ,'1'  ,'2'  ,'3'  ,'4'    ,'5'    ,'6'   ,'7'      ,'8'   ,'9'    ,'0'        ,'-'  ,'='         ,K_BACKSPACE,9     , // 0
+       'q'        ,'w'   ,'e'  ,'r'  ,'t'  ,'y'    ,'u'    ,'i'   ,'o'      ,'p'   ,'['    ,']'        ,13   ,K_CTRL      ,'a'        ,'s'   , // 1
+       'd'        ,'f'   ,'g'  ,'h'  ,'j'  ,'k'    ,'l'    ,';'   ,'\''     ,'`'   ,K_SHIFT,'\\'       ,'z'  ,'x'         ,'c'        ,'v'   , // 2
+       'b'        ,'n'   ,'m'  ,','  ,'.'  ,'/'    ,K_SHIFT,'*'   ,K_ALT    ,' '   ,0      ,K_F1       ,K_F2 ,K_F3        ,K_F4       ,K_F5  , // 3
+       K_F6       ,K_F7  ,K_F8 ,K_F9 ,K_F10,K_PAUSE,0      ,K_HOME,K_UPARROW,K_PGUP,'-'    ,K_LEFTARROW,'5'  ,K_RIGHTARROW,'+'        ,K_END , // 4
+       K_DOWNARROW,K_PGDN,K_INS,K_DEL,0    ,0      ,0      ,K_F11 ,K_F12    ,0     ,0      ,0          ,0    ,0           ,0          ,0     , // 5
+       0          ,0     ,0    ,0    ,0    ,0      ,0      ,0     ,0        ,0     ,0      ,0          ,0    ,0           ,0          ,0     , // 6
+       0          ,0     ,0    ,0    ,0    ,0      ,0      ,0     ,0        ,0     ,0      ,0          ,0    ,0           ,0          ,0       // 7
+};
 
+/*
+byte shiftscantokey[128] =
+{ 
+//     0           1      2     3     4     5       6       7      8         9      A       B           C    D            E           F 
+       0          ,27    ,'!'  ,'@'  ,'#'  ,'$'    ,'%'    ,'^'   ,'&'      ,'*'   ,'('    ,')'        ,'_' ,'+'         ,K_BACKSPACE,9    , // 0
+       'Q'        ,'W'   ,'E'  ,'R'  ,'T'  ,'Y'    ,'U'    ,'I'   ,'O'      ,'P'   ,'{'    ,'}'        ,13  ,K_CTRL      ,'A'        ,'S'  , // 1
+       'D'        ,'F'   ,'G'  ,'H'  ,'J'  ,'K'    ,'L'    ,':'   ,'"'      ,'~'   ,K_SHIFT,'|'        ,'Z' ,'X'         ,'C'        ,'V'  , // 2
+       'B'        ,'N'   ,'M'  ,'<'  ,'>'  ,'?'    ,K_SHIFT,'*'   ,K_ALT    ,' '   ,0      ,K_F1       ,K_F2,K_F3        ,K_F4       ,K_F5 , // 3
+       K_F6       ,K_F7  ,K_F8 ,K_F9 ,K_F10,K_PAUSE,0      ,K_HOME,K_UPARROW,K_PGUP,'_'    ,K_LEFTARROW,'%' ,K_RIGHTARROW,'+'        ,K_END, // 4
+       K_DOWNARROW,K_PGDN,K_INS,K_DEL,0    ,0      ,0      ,K_F11 ,K_F12    ,0     ,0      ,0          ,0   ,0           ,0          ,0    , // 5
+       0          ,0     ,0    ,0    ,0    ,0      ,0      ,0     ,0        ,0     ,0      ,0          ,0   ,0           ,0          ,0    , // 6
+       0          ,0     ,0    ,0    ,0    ,0      ,0      ,0     ,0        ,0     ,0      ,0          ,0   ,0           ,0          ,0      // 7 
+}; 
+*/
 
 /*
 =======
@@ -765,13 +621,15 @@ MapKey
 Map from windows to quake keynums
 =======
 */
-int MapKey (int key)
+int MapKey (int key, int virtualkey)
 {
        key = (key>>16)&255;
        if (key > 127)
                return 0;
        if (scantokey[key] == 0)
                Con_DPrintf("key 0x%02x has no translation\n", key);
+//     if (scantokey[key] >= 0x20 && scantokey[key] < 0x7F)
+//             return realchar;
        return scantokey[key];
 }
 
@@ -903,12 +761,12 @@ LONG WINAPI MainWndProc (
 
                case WM_KEYDOWN:
                case WM_SYSKEYDOWN:
-                       Key_Event (MapKey(lParam), true);
+                       Key_Event (MapKey(lParam, wParam), true);
                        break;
                        
                case WM_KEYUP:
                case WM_SYSKEYUP:
-                       Key_Event (MapKey(lParam), false);
+                       Key_Event (MapKey(lParam, wParam), false);
                        break;
 
                case WM_SYSCHAR:
@@ -956,11 +814,8 @@ LONG WINAPI MainWndProc (
             break;
 
            case WM_CLOSE:
-                       if (MessageBox (mainwindow, "Are you sure you want to quit?", "Confirm Exit",
-                                               MB_YESNO | MB_SETFOREGROUND | MB_ICONQUESTION) == IDYES)
-                       {
+                       if (MessageBox (mainwindow, "Are you sure you want to quit?", "Confirm Exit", MB_YESNO | MB_SETFOREGROUND | MB_ICONQUESTION) == IDYES)
                                Sys_Quit ();
-                       }
 
                break;
 
@@ -976,8 +831,8 @@ LONG WINAPI MainWndProc (
 
            case WM_DESTROY:
         {
-                       if (dibwindow)
-                               DestroyWindow (dibwindow);
+                       if (mainwindow)
+                               DestroyWindow (mainwindow);
 
             PostQuitMessage (0);
         }
@@ -1045,9 +900,7 @@ char *VID_GetModeDescription (int mode)
        }
        else
        {
-               sprintf (temp, "Desktop resolution (%dx%d)",
-                                modelist[MODE_FULLSCREEN_DEFAULT].width,
-                                modelist[MODE_FULLSCREEN_DEFAULT].height);
+               sprintf (temp, "Desktop resolution (%dx%d)", modelist[MODE_FULLSCREEN_DEFAULT].width, modelist[MODE_FULLSCREEN_DEFAULT].height);
                pinfo = temp;
        }
 
@@ -1069,15 +922,9 @@ char *VID_GetExtModeDescription (int mode)
        if (modelist[mode].type == MS_FULLDIB)
        {
                if (!leavecurrentmode)
-               {
                        sprintf(pinfo,"%s fullscreen", pv->modedesc);
-               }
                else
-               {
-                       sprintf (pinfo, "Desktop resolution (%dx%d)",
-                                        modelist[MODE_FULLSCREEN_DEFAULT].width,
-                                        modelist[MODE_FULLSCREEN_DEFAULT].height);
-               }
+                       sprintf (pinfo, "Desktop resolution (%dx%d)", modelist[MODE_FULLSCREEN_DEFAULT].width, modelist[MODE_FULLSCREEN_DEFAULT].height);
        }
        else
        {
@@ -1163,12 +1010,37 @@ void VID_DescribeModes_f (void)
        leavecurrentmode = t;
 }
 
+void VID_AddMode(int type, int width, int height, int modenum, int halfscreen, int dib, int fullscreen, int bpp)
+{
+       int i;
+       if (nummodes >= MAX_MODE_LIST)
+               return;
+       modelist[nummodes].type = type;
+       modelist[nummodes].width = width;
+       modelist[nummodes].height = height;
+       modelist[nummodes].modenum = modenum;
+       modelist[nummodes].halfscreen = halfscreen;
+       modelist[nummodes].dib = dib;
+       modelist[nummodes].fullscreen = fullscreen;
+       modelist[nummodes].bpp = bpp;
+       if (bpp == 0)
+               sprintf (modelist[nummodes].modedesc, "%dx%d", width, height);
+       else
+               sprintf (modelist[nummodes].modedesc, "%dx%dx%d", width, height, bpp);
+       for (i = 0;i < nummodes;i++)
+       {
+               if (!memcmp(&modelist[i], &modelist[nummodes], sizeof(vmode_t)))
+                       return;
+       }
+       nummodes++;
+}
 
 void VID_InitDIB (HINSTANCE hInstance)
 {
+       int w, h;
        WNDCLASS                wc;
 
-       /* Register the frame class */
+       // Register the frame class
     wc.style         = 0;
     wc.lpfnWndProc   = (WNDPROC)MainWndProc;
     wc.cbClsExtra    = 0;
@@ -1178,15 +1050,12 @@ void VID_InitDIB (HINSTANCE hInstance)
     wc.hCursor       = LoadCursor (NULL,IDC_ARROW);
        wc.hbrBackground = NULL;
     wc.lpszMenuName  = 0;
-#ifdef NEHAHRA
-    wc.lpszClassName = "DPNehahraQuake";
-#else
-    wc.lpszClassName = "DarkPlacesQuake";
-#endif
+    wc.lpszClassName = "DarkPlaces";
 
     if (!RegisterClass (&wc) )
                Sys_Error ("Couldn't register window class");
 
+       /*
        modelist[0].type = MS_WINDOWED;
 
        if (COM_CheckParm("-width"))
@@ -1205,8 +1074,7 @@ void VID_InitDIB (HINSTANCE hInstance)
        if (modelist[0].height < 240)
                modelist[0].height = 240;
 
-       sprintf (modelist[0].modedesc, "%dx%d",
-                        modelist[0].width, modelist[0].height);
+       sprintf (modelist[0].modedesc, "%dx%d", modelist[0].width, modelist[0].height);
 
        modelist[0].modenum = MODE_WINDOWED;
        modelist[0].dib = 1;
@@ -1215,6 +1083,24 @@ void VID_InitDIB (HINSTANCE hInstance)
        modelist[0].bpp = 0;
 
        nummodes = 1;
+       */
+       if (COM_CheckParm("-width"))
+               w = atoi(com_argv[COM_CheckParm("-width")+1]);
+       else
+               w = 640;
+
+       if (w < 320)
+               w = 320;
+
+       if (COM_CheckParm("-height"))
+               h = atoi(com_argv[COM_CheckParm("-height")+1]);
+       else
+               h = w * 240/320;
+
+       if (h < 240)
+               h = 240;
+
+       VID_AddMode(MS_WINDOWED, w, h, 0, 0, 1, 0, 0);
 }
 
 
@@ -1226,8 +1112,14 @@ VID_InitFullDIB
 void VID_InitFullDIB (HINSTANCE hInstance)
 {
        DEVMODE devmode;
-       int             i, modenum, originalnummodes, existingmode, numlowresmodes;
-       int             j, bpp, done;
+//     int             i;
+       int             modenum;
+       int             originalnummodes;
+//     int             existingmode;
+       int             numlowresmodes;
+       int             j;
+       int             bpp;
+       int             done;
        BOOL    stat;
 
 // enumerate >8 bpp modes
@@ -1238,18 +1130,19 @@ void VID_InitFullDIB (HINSTANCE hInstance)
        {
                stat = EnumDisplaySettings (NULL, modenum, &devmode);
 
-               if ((devmode.dmBitsPerPel >= 15) &&
-                       (devmode.dmPelsWidth <= MAXWIDTH) &&
-                       (devmode.dmPelsHeight <= MAXHEIGHT) &&
-                       (nummodes < MAX_MODE_LIST))
+               if ((devmode.dmBitsPerPel >= 15) && (devmode.dmPelsWidth <= MAXWIDTH) && (devmode.dmPelsHeight <= MAXHEIGHT) && (nummodes < MAX_MODE_LIST))
                {
-                       devmode.dmFields = DM_BITSPERPEL |
-                                                          DM_PELSWIDTH |
-                                                          DM_PELSHEIGHT;
+                       devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
 
-                       if (ChangeDisplaySettings (&devmode, CDS_TEST | CDS_FULLSCREEN) ==
-                                       DISP_CHANGE_SUCCESSFUL)
+                       if (ChangeDisplaySettings (&devmode, CDS_TEST | CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL)
                        {
+                       // if the width is more than twice the height, reduce it by half because this
+                       // is probably a dual-screen monitor
+                               if ((!COM_CheckParm("-noadjustaspect")) && (devmode.dmPelsWidth > (devmode.dmPelsHeight << 1)))
+                                       VID_AddMode(MS_FULLDIB, devmode.dmPelsWidth >> 1, devmode.dmPelsHeight, 0, 1, 1, 1, devmode.dmBitsPerPel);
+                               else
+                                       VID_AddMode(MS_FULLDIB, devmode.dmPelsWidth, devmode.dmPelsHeight, 0, 0, 1, 1, devmode.dmBitsPerPel);
+                               /*
                                modelist[nummodes].type = MS_FULLDIB;
                                modelist[nummodes].width = devmode.dmPelsWidth;
                                modelist[nummodes].height = devmode.dmPelsHeight;
@@ -1258,9 +1151,7 @@ void VID_InitFullDIB (HINSTANCE hInstance)
                                modelist[nummodes].dib = 1;
                                modelist[nummodes].fullscreen = 1;
                                modelist[nummodes].bpp = devmode.dmBitsPerPel;
-                               sprintf (modelist[nummodes].modedesc, "%dx%dx%d",
-                                                devmode.dmPelsWidth, devmode.dmPelsHeight,
-                                                devmode.dmBitsPerPel);
+                               sprintf (modelist[nummodes].modedesc, "%dx%dx%d", devmode.dmPelsWidth, devmode.dmPelsHeight, devmode.dmBitsPerPel);
 
                        // if the width is more than twice the height, reduce it by half because this
                        // is probably a dual-screen monitor
@@ -1270,18 +1161,13 @@ void VID_InitFullDIB (HINSTANCE hInstance)
                                        {
                                                modelist[nummodes].width >>= 1;
                                                modelist[nummodes].halfscreen = 1;
-                                               sprintf (modelist[nummodes].modedesc, "%dx%dx%d",
-                                                                modelist[nummodes].width,
-                                                                modelist[nummodes].height,
-                                                                modelist[nummodes].bpp);
+                                               sprintf (modelist[nummodes].modedesc, "%dx%dx%d", modelist[nummodes].width, modelist[nummodes].height, modelist[nummodes].bpp);
                                        }
                                }
 
                                for (i=originalnummodes, existingmode = 0 ; i<nummodes ; i++)
                                {
-                                       if ((modelist[nummodes].width == modelist[i].width)   &&
-                                               (modelist[nummodes].height == modelist[i].height) &&
-                                               (modelist[nummodes].bpp == modelist[i].bpp))
+                                       if ((modelist[nummodes].width == modelist[i].width) && (modelist[nummodes].height == modelist[i].height) && (modelist[nummodes].bpp == modelist[i].bpp))
                                        {
                                                existingmode = 1;
                                                break;
@@ -1289,14 +1175,14 @@ void VID_InitFullDIB (HINSTANCE hInstance)
                                }
 
                                if (!existingmode)
-                               {
                                        nummodes++;
-                               }
+                               */
                        }
                }
 
                modenum++;
-       } while (stat);
+       }
+       while (stat);
 
 // see if there are any low-res modes that aren't being reported
        numlowresmodes = sizeof(lowresmodes) / sizeof(lowresmodes[0]);
@@ -1312,8 +1198,9 @@ void VID_InitFullDIB (HINSTANCE hInstance)
                        devmode.dmPelsHeight = lowresmodes[j].height;
                        devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
 
-                       if (ChangeDisplaySettings (&devmode, CDS_TEST | CDS_FULLSCREEN) ==
-                                       DISP_CHANGE_SUCCESSFUL)
+                       if (ChangeDisplaySettings (&devmode, CDS_TEST | CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL)
+                               VID_AddMode(MS_FULLDIB, devmode.dmPelsWidth, devmode.dmPelsHeight, 0, 0, 1, 1, devmode.dmBitsPerPel);
+                       /*
                        {
                                modelist[nummodes].type = MS_FULLDIB;
                                modelist[nummodes].width = devmode.dmPelsWidth;
@@ -1323,15 +1210,11 @@ void VID_InitFullDIB (HINSTANCE hInstance)
                                modelist[nummodes].dib = 1;
                                modelist[nummodes].fullscreen = 1;
                                modelist[nummodes].bpp = devmode.dmBitsPerPel;
-                               sprintf (modelist[nummodes].modedesc, "%dx%dx%d",
-                                                devmode.dmPelsWidth, devmode.dmPelsHeight,
-                                                devmode.dmBitsPerPel);
+                               sprintf (modelist[nummodes].modedesc, "%dx%dx%d", devmode.dmPelsWidth, devmode.dmPelsHeight, devmode.dmBitsPerPel);
 
                                for (i=originalnummodes, existingmode = 0 ; i<nummodes ; i++)
                                {
-                                       if ((modelist[nummodes].width == modelist[i].width)   &&
-                                               (modelist[nummodes].height == modelist[i].height) &&
-                                               (modelist[nummodes].bpp == modelist[i].bpp))
+                                       if ((modelist[nummodes].width == modelist[i].width) && (modelist[nummodes].height == modelist[i].height) && (modelist[nummodes].bpp == modelist[i].bpp))
                                        {
                                                existingmode = 1;
                                                break;
@@ -1339,10 +1222,9 @@ void VID_InitFullDIB (HINSTANCE hInstance)
                                }
 
                                if (!existingmode)
-                               {
                                        nummodes++;
-                               }
                        }
+                       */
                }
                switch (bpp)
                {
@@ -1358,61 +1240,23 @@ void VID_InitFullDIB (HINSTANCE hInstance)
                                done = 1;
                                break;
                }
-       } while (!done);
+       }
+       while (!done);
 
        if (nummodes == originalnummodes)
                Con_SafePrintf ("No fullscreen DIB modes found\n");
 }
 
-qboolean VID_Is8bit()
-{
-       return is8bit;
-}
-
-#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB
-
-void VID_Init8bitPalette() 
-{
-       // Check for 8bit Extensions and initialize them.
-       int i;
-       char thePalette[256*3];
-       char *oldPalette, *newPalette;
-       // LordHavoc: 8bit texture support broke many things...  it now must be specifically stated on the commandline (-no8bit became -8bit)
-       if (!COM_CheckParm("-8bit"))
-               return;
-       if (strstr(gl_extensions, "GL_EXT_shared_texture_palette"))
-               return;
-       if (!(glColorTableEXT = (void *)wglGetProcAddress("glColorTableEXT")))
-               return;
-
-       Con_SafePrintf("8-bit GL extensions enabled.\n");
-       glEnable( GL_SHARED_TEXTURE_PALETTE_EXT );
-       oldPalette = (char *) d_8to24table;
-       newPalette = thePalette;
-       for (i=0;i<256;i++)
-       {
-               *newPalette++ = *oldPalette++;
-               *newPalette++ = *oldPalette++;
-               *newPalette++ = *oldPalette++;
-               oldPalette++;
-       }
-       glColorTableEXT(GL_SHARED_TEXTURE_PALETTE_EXT, GL_RGB, 256, GL_RGB, GL_UNSIGNED_BYTE, (void *) thePalette);
-       is8bit = TRUE;
-}
-
-extern void Check_Gamma (unsigned char *pal);
-void VID_Setup15to8Palette ();
-
 /*
 ===================
 VID_Init
 ===================
 */
-void   VID_Init (unsigned char *palette)
+void   VID_Init ()
 {
-       int             i, existingmode;
+       int             i;
+//     int             existingmode;
        int             basenummodes, width, height, bpp, findbpp, done;
-//     char    gldir[MAX_OSPATH];
        HDC             hdc;
        DEVMODE devmode;
 
@@ -1448,9 +1292,7 @@ void      VID_Init (unsigned char *palette)
                hdc = GetDC (NULL);
 
                if (GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE)
-               {
                        Sys_Error ("Can't run in non-RGB mode");
-               }
 
                ReleaseDC (NULL, hdc);
 
@@ -1466,30 +1308,22 @@ void    VID_Init (unsigned char *palette)
                windowed = false;
 
                if (COM_CheckParm("-mode"))
-               {
                        vid_default = atoi(com_argv[COM_CheckParm("-mode")+1]);
-               }
                else
                {
                        if (COM_CheckParm("-current"))
                        {
-                               modelist[MODE_FULLSCREEN_DEFAULT].width =
-                                               GetSystemMetrics (SM_CXSCREEN);
-                               modelist[MODE_FULLSCREEN_DEFAULT].height =
-                                               GetSystemMetrics (SM_CYSCREEN);
+                               modelist[MODE_FULLSCREEN_DEFAULT].width = GetSystemMetrics (SM_CXSCREEN);
+                               modelist[MODE_FULLSCREEN_DEFAULT].height = GetSystemMetrics (SM_CYSCREEN);
                                vid_default = MODE_FULLSCREEN_DEFAULT;
                                leavecurrentmode = 1;
                        }
                        else
                        {
                                if (COM_CheckParm("-width"))
-                               {
                                        width = atoi(com_argv[COM_CheckParm("-width")+1]);
-                               }
                                else
-                               {
                                        width = 640;
-                               }
 
                                if (COM_CheckParm("-bpp"))
                                {
@@ -1507,6 +1341,8 @@ void      VID_Init (unsigned char *palette)
 
                        // if they want to force it, add the specified mode to the list
                                if (COM_CheckParm("-force") && (nummodes < MAX_MODE_LIST))
+                                       VID_AddMode(MS_FULLDIB, width, height, 0, 0, 1, 1, bpp);
+                               /*
                                {
                                        modelist[nummodes].type = MS_FULLDIB;
                                        modelist[nummodes].width = width;
@@ -1516,15 +1352,11 @@ void    VID_Init (unsigned char *palette)
                                        modelist[nummodes].dib = 1;
                                        modelist[nummodes].fullscreen = 1;
                                        modelist[nummodes].bpp = bpp;
-                                       sprintf (modelist[nummodes].modedesc, "%dx%dx%d",
-                                                        devmode.dmPelsWidth, devmode.dmPelsHeight,
-                                                        devmode.dmBitsPerPel);
+                                       sprintf (modelist[nummodes].modedesc, "%dx%dx%d", devmode.dmPelsWidth, devmode.dmPelsHeight, devmode.dmBitsPerPel);
 
                                        for (i=nummodes, existingmode = 0 ; i<nummodes ; i++)
                                        {
-                                               if ((modelist[nummodes].width == modelist[i].width)   &&
-                                                       (modelist[nummodes].height == modelist[i].height) &&
-                                                       (modelist[nummodes].bpp == modelist[i].bpp))
+                                               if ((modelist[nummodes].width == modelist[i].width) && (modelist[nummodes].height == modelist[i].height) && (modelist[nummodes].bpp == modelist[i].bpp))
                                                {
                                                        existingmode = 1;
                                                        break;
@@ -1532,10 +1364,9 @@ void     VID_Init (unsigned char *palette)
                                        }
 
                                        if (!existingmode)
-                                       {
                                                nummodes++;
-                                       }
                                }
+                               */
 
                                done = 0;
 
@@ -1547,9 +1378,7 @@ void      VID_Init (unsigned char *palette)
 
                                                for (i=1, vid_default=0 ; i<nummodes ; i++)
                                                {
-                                                       if ((modelist[i].width == width) &&
-                                                               (modelist[i].height == height) &&
-                                                               (modelist[i].bpp == bpp))
+                                                       if ((modelist[i].width == width) && (modelist[i].height == height) && (modelist[i].bpp == bpp))
                                                        {
                                                                vid_default = i;
                                                                done = 1;
@@ -1576,32 +1405,20 @@ void    VID_Init (unsigned char *palette)
                                                {
                                                        switch (bpp)
                                                        {
-                                                       case 15:
-                                                               bpp = 16;
-                                                               break;
-                                                       case 16:
-                                                               bpp = 32;
-                                                               break;
-                                                       case 32:
-                                                               bpp = 24;
-                                                               break;
-                                                       case 24:
-                                                               done = 1;
-                                                               break;
+                                                       case 15: bpp = 16;break;
+                                                       case 16: bpp = 32;break;
+                                                       case 32: bpp = 24;break;
+                                                       case 24: done = 1;break;
                                                        }
                                                }
                                                else
-                                               {
                                                        done = 1;
-                                               }
                                        }
                                }
                                while (!done);
 
                                if (!vid_default)
-                               {
                                        Sys_Error ("Specified video mode not available");
-                               }
                        }
                }
        }
@@ -1626,13 +1443,7 @@ void     VID_Init (unsigned char *palette)
        if (vid.conheight < 200)
                vid.conheight = 200;
 
-       DestroyWindow (hwnd_dialog);
-
-       VID_SetPalette (palette);
-
-       Check_Gamma(palette);
-
-       VID_SetMode (vid_default, palette);
+       VID_SetMode (vid_default);
 
        maindc = GetDC(mainwindow);
        bSetupPixelFormat(maindc);
@@ -1645,16 +1456,20 @@ void    VID_Init (unsigned char *palette)
 
        GL_Init ();
 
+       // LordHavoc: special differences for ATI (broken 8bit color when also using 32bit? weird!)
+       if (strncasecmp(gl_vendor,"ATI",3)==0)
+       {
+               if (strncasecmp(gl_renderer,"Rage Pro",8)==0)
+                       isRagePro = true;
+       }
+       if (strncasecmp(gl_renderer,"Matrox G200 Direct3D",20)==0) // a D3D driver for GL? sigh...
+               isG200 = true;
+
 //     sprintf (gldir, "%s/glquake", com_gamedir);
 //     Sys_mkdir (gldir);
 
        vid_realmode = vid_modenum;
 
-       VID_Init8bitPalette();
-
-       if (is8bit) // LordHavoc: avoid calculating 15to8 table if it won't be used
-               VID_Setup15to8Palette ();
-
        vid_menudrawfn = VID_MenuDraw;
        vid_menukeyfn = VID_MenuKey;
 
diff --git a/view.c b/view.c
index 5b37040fa4e658741e37c83bb2f48b15e523c665..22ddf75d48e2ffa049be64c347cc8febb0142dcf 100644 (file)
--- a/view.c
+++ b/view.c
@@ -238,7 +238,7 @@ void V_DriftPitch (void)
 /*
 ============================================================================== 
  
-                                               PALETTE FLASHES 
+                                               SCREEN FLASHES 
  
 ============================================================================== 
 */ 
@@ -501,10 +501,10 @@ void V_CalcBlend (void)
 
 /*
 =============
-V_UpdatePalette
+V_UpdateBlends
 =============
 */
-void V_UpdatePalette (void)
+void V_UpdateBlends (void)
 {
        int             i, j;
        qboolean        new;
diff --git a/view.h b/view.h
index 985bc5f65f53a810ad72081a2a68d91808d58ba1..f44353eb8037009eace793c56975225c51e10feb 100644 (file)
--- a/view.h
+++ b/view.h
@@ -27,5 +27,5 @@ extern cvar_t brightness;
 void V_Init (void);
 void V_RenderView (void);
 float V_CalcRoll (vec3_t angles, vec3_t velocity);
-void V_UpdatePalette (void);
+void V_UpdateBlends (void);
 
index a22bef5bdc1373ec2ffaa4c35179a53714d4ddd2..9b35f8028027f10233528ca62601b0783f6afbc4 100644 (file)
@@ -76,7 +76,6 @@ extern int            window_center_x, window_center_y;
 extern RECT            window_rect;
 
 extern qboolean        mouseinitialized;
-extern HWND            hwnd_dialog;
 
 extern HANDLE  hinput, houtput;
 
diff --git a/world.c b/world.c
index 5a8d033a468998570d536377a7415ee361a44bce..6be76178b65d810988b4ea2d73050343edc57874 100644 (file)
--- a/world.c
+++ b/world.c
@@ -435,21 +435,28 @@ void SV_LinkEdict (edict_t *ent, qboolean touch_triggers)
 // set the abs box
 
 // LordHavoc: enabling rotating bmodels
-       if (ent->v.solid == SOLID_BSP && (ent->v.angles[0] || ent->v.angles[1] || ent->v.angles[2]) )
+       if (ent->v.solid == SOLID_BSP && (ent->v.angles[0] || ent->v.angles[1] || ent->v.angles[2]))
        {       // expand for rotation
                float           max, v;
                int                     i;
 
+               max = DotProduct(ent->v.mins, ent->v.mins);
+               v = DotProduct(ent->v.maxs, ent->v.maxs);
+               if (max < v)
+                       max = v;
+               max = sqrt(max);
+               /*
                max = 0;
                for (i=0 ; i<3 ; i++)
                {
-                       v =fabs( ent->v.mins[i]);
-                       if (v > max)
+                       v = fabs(ent->v.mins[i]);
+                       if (max < v)
                                max = v;
-                       v =fabs( ent->v.maxs[i]);
-                       if (v > max)
+                       v = fabs(ent->v.maxs[i]);
+                       if (max < v)
                                max = v;
                }
+               */
                for (i=0 ; i<3 ; i++)
                {
                        ent->v.absmin[i] = ent->v.origin[i] - max;
@@ -483,7 +490,7 @@ void SV_LinkEdict (edict_t *ent, qboolean touch_triggers)
                ent->v.absmax[1] += 1;
                ent->v.absmax[2] += 1;
        }
-       
+
 // link to PVS leafs
        ent->num_leafs = 0;
        if (ent->v.modelindex)
@@ -505,7 +512,7 @@ void SV_LinkEdict (edict_t *ent, qboolean touch_triggers)
                else
                        break;          // crosses the node
        }
-       
+
 // link it in  
 
        if (ent->v.solid == SOLID_TRIGGER)
@@ -933,8 +940,7 @@ trace_t SV_ClipMoveToEntity (edict_t *ent, vec3_t start, vec3_t mins, vec3_t max
 
 // LordHavoc: enabling rotating bmodels
        // rotate start and end into the models frame of reference
-       if (ent->v.solid == SOLID_BSP && 
-       (ent->v.angles[0] || ent->v.angles[1] || ent->v.angles[2]) )
+       if (ent->v.solid == SOLID_BSP && (ent->v.angles[0] || ent->v.angles[1] || ent->v.angles[2]))
        {
                vec3_t  forward, right, up;
                vec3_t  temp;
@@ -957,8 +963,7 @@ trace_t SV_ClipMoveToEntity (edict_t *ent, vec3_t start, vec3_t mins, vec3_t max
 
 // LordHavoc: enabling rotating bmodels
        // rotate endpos back to world frame of reference
-       if (ent->v.solid == SOLID_BSP && 
-       (ent->v.angles[0] || ent->v.angles[1] || ent->v.angles[2]) )
+       if (ent->v.solid == SOLID_BSP && (ent->v.angles[0] || ent->v.angles[1] || ent->v.angles[2]))
        {
                vec3_t  a;
                vec3_t  forward, right, up;
diff --git a/world.h b/world.h
index bf9507ccbf1fcb3ac56adff44e8bccd1dbd04d34..7d829946aecd199f7ebc49953085e11f923e3f56 100644 (file)
--- a/world.h
+++ b/world.h
@@ -81,3 +81,5 @@ trace_t SV_Move (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int type, e
 // shouldn't be considered solid objects
 
 // passedict is explicitly excluded from clipping checks (normally NULL)
+
+extern qboolean SV_RecursiveHullCheck (hull_t *hull, int num, float p1f, float p2f, vec3_t p1, vec3_t p2, trace_t *trace);
\ No newline at end of file