From ee02c7385b47fe0f5a5c312902855c05e3f1c7ed Mon Sep 17 00:00:00 2001 From: Joseph Carter Date: Thu, 15 Jun 2000 12:05:41 +0000 Subject: [PATCH] Those GL drivers with non-accellerated blending should have their authors tarred, feathered, stabbed, shot, drawn, quartered, and then really hurt. Such hardware requiring it should be incinerated as worthless garbage. Yes, this means that we now change blending states often again. This may recover much of the lost FPS people were having with certain cards and drivers. Sorry guys, I didn't consider that card makers could be such complete idiots. On the plus side, all major bugs outstanding in the GL renderer should be resolved excepting the banding on 3dfx cards. As soon as Mercury gets me the documentation on the gamma ramp extension, I'll be using it (hint..) This is your cue to merge my changes into the main tree taniwha. No depth polys yet. Waterripple added. Version display while downloading removed. gl_finish sortof removed (cvar needs to be pulled still), gl_ztrick is next. I understand the GL renderer and what I plan to do w/ it better now, so I can start pounding away at that after I wake up. --- include/glquake.h | 1 + source/draw.c | 6 ++- source/gl_part.c | 3 ++ source/gl_rmain.c | 11 ++++- source/gl_rmisc.c | 1 + source/gl_rsurf.c | 102 +++++++++++++++++++++++----------------------- source/gl_warp.c | 81 +++++------------------------------- 7 files changed, 80 insertions(+), 125 deletions(-) diff --git a/include/glquake.h b/include/glquake.h index 3ccec47..a7430c7 100644 --- a/include/glquake.h +++ b/include/glquake.h @@ -192,6 +192,7 @@ extern cvar_t *r_lightmap; extern cvar_t *r_shadows; extern cvar_t *r_mirroralpha; extern cvar_t *r_wateralpha; +extern cvar_t *r_waterripple; extern cvar_t *r_dynamic; extern cvar_t *r_novis; extern cvar_t *r_netgraph; diff --git a/source/draw.c b/source/draw.c index 165050c..6fa5838 100644 --- a/source/draw.c +++ b/source/draw.c @@ -36,6 +36,7 @@ #include "console.h" #include "quakefs.h" #include "sound.h" +#include "client.h" #include @@ -703,8 +704,9 @@ void Draw_ConsoleBackground (int lines) } } - Draw_AltString8 (vid.conwidth - strlen(cl_verstring->string)*8 - 11, - lines-14, cl_verstring->string); + if (!cls.download) + Draw_AltString8 (vid.conwidth - strlen(cl_verstring->string) + * 8 - 11, lines-14, cl_verstring->string); } diff --git a/source/gl_part.c b/source/gl_part.c index 1fe8407..3d0d43c 100644 --- a/source/gl_part.c +++ b/source/gl_part.c @@ -495,6 +495,9 @@ void R_DrawParticles (void) qboolean alphaTestEnabled; glBindTexture (GL_TEXTURE_2D, particletexture); + glEnable (GL_BLEND); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + alphaTestEnabled = glIsEnabled(GL_ALPHA_TEST); if (alphaTestEnabled) diff --git a/source/gl_rmain.c b/source/gl_rmain.c index 56c1ff0..4847ab4 100644 --- a/source/gl_rmain.c +++ b/source/gl_rmain.c @@ -100,6 +100,7 @@ cvar_t *r_lightmap; cvar_t *r_shadows; cvar_t *r_mirroralpha; cvar_t *r_wateralpha; +cvar_t *r_waterripple; cvar_t *r_dynamic; cvar_t *r_novis; cvar_t *r_netgraph; @@ -362,7 +363,12 @@ void GL_DrawAliasFrame (aliashdr_t *paliashdr, int posenum) int *order; int count; -lastposenum = posenum; + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glShadeModel(GL_SMOOTH); + glEnable(GL_BLEND); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + + lastposenum = posenum; verts = (trivertx_t *)((byte *)paliashdr + paliashdr->posedata); verts += posenum * paliashdr->poseverts; @@ -590,7 +596,7 @@ void R_DrawAliasModel (entity_t *e) GL_DisableMultitexture(); - glPushMatrix (); + glPushMatrix (); R_RotateForEntity (e); if (!strcmp (clmodel->name, "progs/eyes.mdl") ) { @@ -781,6 +787,7 @@ void R_PolyBlend (void) GL_DisableMultitexture(); + glEnable (GL_BLEND); glDisable (GL_DEPTH_TEST); glDisable (GL_TEXTURE_2D); diff --git a/source/gl_rmisc.c b/source/gl_rmisc.c index 35bd893..db69d59 100644 --- a/source/gl_rmisc.c +++ b/source/gl_rmisc.c @@ -238,6 +238,7 @@ void R_Init (void) r_shadows = Cvar_Get("r_shadows", "0", CVAR_NONE, "None"); r_mirroralpha = Cvar_Get("r_mirroralpha", "1", CVAR_NONE, "None"); r_wateralpha = Cvar_Get("r_wateralpha", "1", CVAR_NONE, "None"); + r_waterripple = Cvar_Get ("r_waterripple", "0", CVAR_NONE, "None"); r_dynamic = Cvar_Get("r_dynamic", "1", CVAR_NONE, "None"); r_novis = Cvar_Get("r_novis", "0", CVAR_NONE, "None"); r_speeds = Cvar_Get("r_speeds", "0", CVAR_NONE, "None"); diff --git a/source/gl_rsurf.c b/source/gl_rsurf.c index bc7f498..cbcf4f7 100644 --- a/source/gl_rsurf.c +++ b/source/gl_rsurf.c @@ -381,7 +381,7 @@ void R_DrawSequentialPoly (msurface_t *s) // normal lightmaped poly // - if (! (s->flags & (SURF_DRAWSKY|SURF_DRAWTURB/*|SURF_UNDERWATER*/) ) ) + if (!(s->flags & (SURF_DRAWSKY|SURF_DRAWTURB))) { R_RenderDynamicLightmaps (s); if (gl_mtexable) @@ -392,7 +392,7 @@ void R_DrawSequentialPoly (msurface_t *s) // Binds world to texture env 0 GL_SelectTexture(0); glBindTexture (GL_TEXTURE_2D, t->gl_texturenum); -// glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); // Binds lightmap to texenv 1 GL_EnableMultitexture(); // Same as SelectTexture (TEXTURE1) glBindTexture (GL_TEXTURE_2D, lightmap_textures + s->lightmaptexturenum); @@ -410,6 +410,7 @@ void R_DrawSequentialPoly (msurface_t *s) theRect->w = 0; } glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glBegin(GL_POLYGON); v = p->verts[0]; for (i=0 ; inumverts ; i++, v+= VERTEXSIZE) @@ -443,6 +444,8 @@ void R_DrawSequentialPoly (msurface_t *s) glVertex3fv (v); } glEnd (); + + glDisable (GL_BLEND); } return; } @@ -498,6 +501,10 @@ void R_BlendLightmaps (void) glDepthMask (0); // don't bother writing Z glBlendFunc (GL_ZERO, GL_SRC_COLOR); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + + if (r_lightmap->value) + glEnable (GL_BLEND); for (i=0 ; il = 0; -// theRect->t = 0; -// theRect->w = BLOCK_WIDTH; -// theRect->h = BLOCK_HEIGHT; -// glTexImage2D (GL_TEXTURE_2D, 0, lightmap_bytes -// , BLOCK_WIDTH, BLOCK_HEIGHT, 0, -// gl_lightmap_format, GL_UNSIGNED_BYTE, lightmaps+i*BLOCK_WIDTH*BLOCK_HEIGHT*lightmap_bytes); -// glTexImage2D (GL_TEXTURE_2D, 0, lightmap_bytes -// , BLOCK_WIDTH, theRect->h, 0, -// gl_lightmap_format, GL_UNSIGNED_BYTE, lightmaps+(i*BLOCK_HEIGHT+theRect->t)*BLOCK_WIDTH*lightmap_bytes); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, theRect->t, BLOCK_WIDTH, theRect->h, gl_lightmap_format, GL_UNSIGNED_BYTE, lightmaps+(i* BLOCK_HEIGHT + theRect->t) *BLOCK_WIDTH*lightmap_bytes); @@ -541,6 +538,7 @@ void R_BlendLightmaps (void) } // Return to normal blending --KB + glDisable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDepthMask (1); // back to normal Z buffering @@ -710,13 +708,15 @@ void R_DrawWaterSurfaces (void) // go back to the world matrix // - glLoadMatrixf (r_world_matrix); + glLoadMatrixf (r_world_matrix); if (r_wateralpha->value < 1.0) { glColor4f (0.5, 0.5, 0.5, r_wateralpha->value); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - } else + } else { glColor3f (0.5, 0.5, 0.5); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + } if (!gl_texsort->value) { if (!waterchain) @@ -797,8 +797,8 @@ void DrawTextureChains (void) } else { - if ((s->flags & SURF_DRAWTURB) && r_wateralpha->value != 1.0) - continue; // draw translucent water later +// if ((s->flags & SURF_DRAWTURB) && r_wateralpha->value != 1.0) +// continue; // draw translucent water later for ( ; s ; s=s->texturechain) R_RenderBrushPoly (s); } @@ -846,7 +846,11 @@ void R_DrawBrushModel (entity_t *e) if (R_CullBox (mins, maxs)) return; + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + glDisable (GL_ALPHA_TEST); + glDisable (GL_BLEND); glColor3f (1.0, 1.0, 1.0); + memset (lightmap_polys, 0, sizeof(lightmap_polys)); VectorSubtract (r_refdef.vieworg, e->origin, modelorg); @@ -908,6 +912,10 @@ void R_DrawBrushModel (entity_t *e) R_BlendLightmaps (); glPopMatrix (); + glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glDisable (GL_ALPHA_TEST); + glEnable (GL_BLEND); } /* @@ -984,10 +992,7 @@ void R_RecursiveWorldNode (mnode_t *node) break; } - if (dot >= 0) - side = 0; - else - side = 1; + side = dot < 0; // recurse down the children, front side first R_RecursiveWorldNode (node->children[side]); @@ -1003,41 +1008,33 @@ void R_RecursiveWorldNode (mnode_t *node) side = SURF_PLANEBACK; else if (dot > BACKFACE_EPSILON) side = 0; + for ( ; c ; c--, surf++) { - for ( ; c ; c--, surf++) + if (surf->visframe != r_framecount) + continue; + + // don't backface underwater surfaces, because they warp + if ((dot < 0) ^ !!(surf->flags & SURF_PLANEBACK)) + continue; // wrong side + + // if sorting by texture, just store it out + if (gl_texsort->value) { - if (surf->visframe != r_framecount) - continue; - - // don't backface underwater surfaces, because they warp -// if ( !(surf->flags & SURF_UNDERWATER) && ( (dot < 0) ^ !!(surf->flags & SURF_PLANEBACK)) ) -// continue; // wrong side - if ( !(((r_viewleaf->contents==CONTENTS_EMPTY && (surf->flags & SURF_UNDERWATER)) || - (r_viewleaf->contents!=CONTENTS_EMPTY && !(surf->flags & SURF_UNDERWATER))) - && !(surf->flags & SURF_DONTWARP)) && ( (dot < 0) ^ !!(surf->flags & SURF_PLANEBACK)) ) - continue; // wrong side - - // if sorting by texture, just store it out - if (gl_texsort->value) + if (!mirror + || surf->texinfo->texture != cl.worldmodel->textures[mirrortexturenum]) { - if (!mirror - || surf->texinfo->texture != cl.worldmodel->textures[mirrortexturenum]) - { - surf->texturechain = surf->texinfo->texture->texturechain; - surf->texinfo->texture->texturechain = surf; - } - } else if (surf->flags & SURF_DRAWSKY) { - surf->texturechain = skychain; - skychain = surf; - } else if (surf->flags & SURF_DRAWTURB) { - surf->texturechain = waterchain; - waterchain = surf; - } else - R_DrawSequentialPoly (surf); - + surf->texturechain = surf->texinfo->texture->texturechain; + surf->texinfo->texture->texturechain = surf; + } + } else if (surf->flags & SURF_DRAWSKY) { + surf->texturechain = skychain; + skychain = surf; + } else if (surf->flags & SURF_DRAWTURB) { + surf->texturechain = waterchain; + waterchain = surf; + } else + R_DrawSequentialPoly (surf); } - } - } // recurse down the back side @@ -1067,11 +1064,14 @@ void R_DrawWorld (void) // Be sure to clear the skybox --KB R_DrawSky (); + glDisable (GL_BLEND); R_RecursiveWorldNode (cl.worldmodel->nodes); DrawTextureChains (); R_BlendLightmaps (); + + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); } diff --git a/source/gl_warp.c b/source/gl_warp.c index 650ca8b..746d637 100644 --- a/source/gl_warp.c +++ b/source/gl_warp.c @@ -223,7 +223,7 @@ void EmitWaterPolys (msurface_t *fa) float *v; int i; float s, t, os, ot; - + vec3_t nv; for (p=fa->polys ; p ; p=p->next) { @@ -240,78 +240,19 @@ void EmitWaterPolys (msurface_t *fa) t *= (1.0/64); glTexCoord2f (s, t); - glVertex3fv (v); + + VectorCopy (v, nv); + nv[2] += r_waterripple->value + * turbsin[(int)((v[3]*0.125+realtime) * TURBSCALE) & 255] + * turbsin[(int)((v[4]*0.125+realtime) * TURBSCALE) & 255] + * (1.0 / 64.0); + + glVertex3fv (nv); } glEnd (); } } -#if 0 -/* -============= -EmitSkyPolys -============= -*/ -void EmitSkyPolys (msurface_t *fa) -{ - glpoly_t *p; - float *v; - int i; - float s, t; - vec3_t dir; - float length; - - for (p=fa->polys ; p ; p=p->next) - { - glBegin (GL_POLYGON); - for (i=0,v=p->verts[0] ; inumverts ; i++, v+=VERTEXSIZE) - { - VectorSubtract (v, r_origin, dir); - dir[2] *= 3; // flatten the sphere - - length = dir[0]*dir[0] + dir[1]*dir[1] + dir[2]*dir[2]; - length = sqrt (length); - length = 6*63/length; - - dir[0] *= length; - dir[1] *= length; - - s = (speedscale + dir[0]) * (1.0/128); - t = (speedscale + dir[1]) * (1.0/128); - - glTexCoord2f (s, t); - glVertex3fv (v); - } - glEnd (); - } -} - -/* -=============== -EmitBothSkyLayers - -Does a sky warp on the pre-fragmented glpoly_t chain -This will be called for brushmodels, the world -will have them chained together. -=============== -*/ -void EmitBothSkyLayers (msurface_t *fa) -{ - GL_DisableMultitexture(); - - glBindTexture (GL_TEXTURE_2D, solidskytexture); - speedscale = realtime*8; - speedscale -= (int)speedscale & ~127 ; - - EmitSkyPolys (fa); - - glBindTexture (GL_TEXTURE_2D, alphaskytexture); - speedscale = realtime*16; - speedscale -= (int)speedscale & ~127 ; - - EmitSkyPolys (fa); -} -#endif /* ================================================================= @@ -781,8 +722,8 @@ R_DrawSkyDome (void) GL_DisableMultitexture (); glEnable (GL_DEPTH_TEST); glDepthFunc (GL_ALWAYS); -// glDisable (GL_BLEND); -// glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + 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); glColor3f (0.5, 0.5, 0.5);