From 68a4e60eafdfe10d610747d26cd3e407e48feebe Mon Sep 17 00:00:00 2001 From: "Zephaniah E. Hull" Date: Tue, 26 Sep 2000 09:03:21 +0000 Subject: [PATCH] Behold, the great state audit, and a few other things. First off, a cleanup in alias model rendering. Then we have R_CullBox, which is now a inline function. Then the big one, the state change cleanup, right now GL_BLEND. --- include/glquake.h | 13 ++++++++++++- include/win32/version.h | 2 +- source/gl_model_alias.c | 2 +- source/gl_part.c | 10 +++------- source/gl_rmain.c | 30 ++++++++++-------------------- source/gl_rsurf.c | 28 ++++++++++++---------------- source/gl_screen.c | 2 -- source/gl_warp.c | 5 ----- source/joystick.c | 2 ++ source/model.c | 1 + source/model_alias.c | 2 +- 11 files changed, 43 insertions(+), 54 deletions(-) diff --git a/include/glquake.h b/include/glquake.h index 677560c..cf25f01 100644 --- a/include/glquake.h +++ b/include/glquake.h @@ -297,9 +297,20 @@ void GL_Set2D (void); // gl_rmain.c // void GL_CheckGamma (unsigned char *pal); -qboolean R_CullBox (vec3_t mins, vec3_t maxs); +//qboolean R_CullBox (vec3_t mins, vec3_t maxs); void R_RotateForEntity (entity_t *e); +extern inline qboolean R_CullBox (vec3_t mins, vec3_t maxs) +{ + int i; + + for (i=0 ; i<4 ; i++) + if (BoxOnPlaneSide (mins, maxs, &frustum[i]) == 2) + return true; + return false; +} + + // // gl_rlight.c // diff --git a/include/win32/version.h b/include/win32/version.h index fd13f2b..6376cb4 100644 --- a/include/win32/version.h +++ b/include/win32/version.h @@ -30,7 +30,7 @@ /* Version strings */ #define PACKAGE "quakeforge" #define PROGRAM "QuakeForge" -#define VERSION "0.2.99beta1" +#define VERSION "0.1.99pre2" #define QW_VERSION "2.40" #define QSG_VERSION "2.0" diff --git a/source/gl_model_alias.c b/source/gl_model_alias.c index 4c51ad0..5d036d5 100644 --- a/source/gl_model_alias.c +++ b/source/gl_model_alias.c @@ -57,7 +57,7 @@ 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; +extern int posenum; byte player_8bit_texels[320*200]; diff --git a/source/gl_part.c b/source/gl_part.c index 5be390d..c183a4f 100644 --- a/source/gl_part.c +++ b/source/gl_part.c @@ -566,8 +566,9 @@ void R_DrawParticles (void) } // hack a scale up to keep particles from disapearing - scale = (p->org[0] - r_origin[0])*vpn[0] + (p->org[1] - r_origin[1])*vpn[1] - + (p->org[2] - r_origin[2])*vpn[2]; + scale = (p->org[0] - r_origin[0])*vpn[0] + + (p->org[1] - r_origin[1])*vpn[1] + + (p->org[2] - r_origin[2])*vpn[2]; if (scale < 20) scale = 1; else @@ -575,17 +576,12 @@ void R_DrawParticles (void) at = (byte *)&d_8to24table[(int)p->color]; if (p->type==pt_fire) theAlpha = 255*(6-p->ramp)/6; -// theAlpha = 192; -// else if (p->type==pt_explode || p->type==pt_explode2) -// theAlpha = 255*(8-p->ramp)/8; else theAlpha = 255; if (lighthalf) glColor4ub((byte) ((int) at[0] >> 1), (byte) ((int) at[1] >> 1), (byte) ((int) at[2] >> 1), theAlpha); else glColor4ub(at[0], at[1], at[2], theAlpha); -// glColor3ubv (at); -// glColor3ubv ((byte *)&d_8to24table[(int)p->color]); glTexCoord2f (0,0); glVertex3fv (p->org); glTexCoord2f (1,0); diff --git a/source/gl_rmain.c b/source/gl_rmain.c index e54d12e..e8b1450 100644 --- a/source/gl_rmain.c +++ b/source/gl_rmain.c @@ -186,6 +186,7 @@ R_CullBox Returns true if the box is completely outside the frustom ================= */ +/* qboolean R_CullBox (vec3_t mins, vec3_t maxs) { int i; @@ -195,6 +196,7 @@ qboolean R_CullBox (vec3_t mins, vec3_t maxs) return true; return false; } +*/ void R_RotateForEntity (entity_t *e) @@ -308,9 +310,6 @@ static void R_DrawSpriteModel (entity_t *e) glEnable (GL_ALPHA_TEST); glBegin (GL_QUADS); - glEnable (GL_ALPHA_TEST); - glBegin (GL_QUADS); - glTexCoord2f (0, 1); VectorMA (e->origin, frame->down, up, point); VectorMA (point, frame->left, right, point); @@ -352,7 +351,7 @@ float r_avertexnormals[NUMVERTEXNORMALS][3] = { }; vec3_t shadevector; -float shadelight, ambientlight; +float shadelight; // precalculated dot products for quantized angles #define SHADEDOT_QUANT 16 @@ -565,11 +564,11 @@ static void R_DrawAliasModel (entity_t *e) // get lighting information // - ambientlight = shadelight = R_LightPoint (currententity->origin); + shadelight = R_LightPoint (currententity->origin); // allways give the gun some light - if (e == &cl.viewent && ambientlight < 24) - ambientlight = shadelight = 24; + if (e == &cl.viewent) + shadelight = min(shadelight, 24); for (lnum=0 ; lnum 0) { - ambientlight += add; - //ZOID models should be affected by dlights as well shadelight += add; } } } // clamp lighting so it doesn't overbright as much - if (ambientlight > 128) - ambientlight = 128; - if (ambientlight + shadelight > 192) - shadelight = 192 - ambientlight; + shadelight = min(shadelight, 100); // ZOID: never allow players to go totally black if (!strcmp(clmodel->name, "progs/player.mdl")) { - if (ambientlight < 8) - ambientlight = shadelight = 8; + shadelight = max(shadelight, 8); } else if (!gl_fb_models->value && ( !strcmp (clmodel->name, "progs/flame.mdl") || !strcmp (clmodel->name, "progs/flame2.mdl"))) { // HACK HACK HACK -- no fullbright colors, so make torches full light - ambientlight = shadelight = 256; + shadelight = 256; } shadedots = r_avertexnormal_dots[((int)(e->angles[1] * (SHADEDOT_QUANT / 360.0))) & (SHADEDOT_QUANT - 1)]; - shadelight = shadelight / 200.0; + shadelight /= 200.0; an = e->angles[1]/180*M_PI; shadevector[0] = cos(-an); @@ -671,14 +664,11 @@ static void R_DrawAliasModel (entity_t *e) if (clmodel->hasfullbrights && gl_fb_models->value && paliashdr->gl_fb_texturenum[currententity->skinnum][anim]) { /* - glEnable (GL_BLEND); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); */ glBindTexture (GL_TEXTURE_2D, paliashdr->gl_fb_texturenum[currententity->skinnum][anim]); R_SetupAliasFrame (currententity->frame, paliashdr, true); - - //glDisable (GL_BLEND); } glShadeModel (GL_FLAT); diff --git a/source/gl_rsurf.c b/source/gl_rsurf.c index 8b3115e..8d2b63b 100644 --- a/source/gl_rsurf.c +++ b/source/gl_rsurf.c @@ -486,9 +486,7 @@ void R_BlendLightmaps (void) glDepthMask (0); // don't bother writing Z - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glBlendFunc (GL_ZERO, GL_SRC_COLOR); - glEnable(GL_BLEND); for (i=0 ; inumtextures ; i++) { if (!cl.worldmodel->textures[i]) @@ -712,6 +712,10 @@ void DrawTextureChains (void) cl.worldmodel->textures[i]->texturechain = NULL; } + + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); } /* @@ -827,16 +831,15 @@ void R_DrawBrushModel (entity_t *e) } } + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + if (gl_texsort->value) R_BlendLightmaps (); if (gl_fb_bmodels->value) R_RenderFullbrights (); - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - glPopMatrix (); } @@ -990,9 +993,6 @@ void R_DrawWorld (void) // Be sure to clear the skybox --KB R_DrawSky (); - glDisable(GL_BLEND); - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - R_RecursiveWorldNode (cl.worldmodel->nodes); DrawTextureChains (); @@ -1002,10 +1002,6 @@ void R_DrawWorld (void) if (gl_fb_bmodels->value) R_RenderFullbrights (); - - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); } diff --git a/source/gl_screen.c b/source/gl_screen.c index 9ec69c4..9be0916 100644 --- a/source/gl_screen.c +++ b/source/gl_screen.c @@ -1233,7 +1233,6 @@ void SCR_UpdateScreen (void) // LordHavoc: adjustable brightness and contrast, // also makes polyblend apply to whole screen glDisable(GL_TEXTURE_2D); - glEnable(GL_BLEND); Cvar_SetValue (brightness, bound (1, brightness->value, 5)); if (lighthalf) // LordHavoc: render was done at half brightness f = brightness->value * 2; @@ -1280,7 +1279,6 @@ void SCR_UpdateScreen (void) glEnd (); } - glDisable(GL_BLEND); glEnable(GL_TEXTURE_2D); V_UpdatePalette (); diff --git a/source/gl_warp.c b/source/gl_warp.c index ed69504..6d519bb 100644 --- a/source/gl_warp.c +++ b/source/gl_warp.c @@ -652,8 +652,6 @@ R_DrawSkyBox (void) glEnable (GL_DEPTH_TEST); glDepthFunc (GL_ALWAYS); -// glDisable (GL_BLEND); -// glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glDepthRange (gldepthmax, gldepthmax); if (lighthalf) glColor3f(0.5,0.5,0.5); @@ -733,8 +731,6 @@ R_DrawSkyDome (void) { glEnable (GL_DEPTH_TEST); glDepthFunc (GL_ALWAYS); -// glDisable (GL_BLEND); -// glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDepthRange (gldepthmax, gldepthmax); glDisable (GL_BLEND); @@ -764,7 +760,6 @@ R_DrawSkyDome (void) R_DrawSkyLayer (speedscale); } -// glDisable (GL_BLEND); glColor3f (1,1,1); glDepthFunc (GL_LEQUAL); glEnable (GL_DEPTH_TEST); diff --git a/source/joystick.c b/source/joystick.c index 572de30..772e727 100644 --- a/source/joystick.c +++ b/source/joystick.c @@ -24,6 +24,8 @@ #include "config.h" #endif +#include "protocol.h" + #ifdef HAVE_LINUX_JOYSTICK_H #include diff --git a/source/model.c b/source/model.c index bacc516..225d426 100644 --- a/source/model.c +++ b/source/model.c @@ -197,6 +197,7 @@ model_t *Mod_ForName (char *name, qboolean crash) mod = Mod_FindName (name); + Con_DPrintf("Mod_ForName: %s, %p\n", name, mod); return Mod_LoadModel (mod, crash); } diff --git a/source/model_alias.c b/source/model_alias.c index addcfb7..85355c6 100644 --- a/source/model_alias.c +++ b/source/model_alias.c @@ -65,7 +65,7 @@ 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; +int posenum = 0; void *Mod_LoadAliasFrame (void * pin, maliasframedesc_t *frame); void *Mod_LoadAliasGroup (void * pin, maliasframedesc_t *frame);