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.
This commit is contained in:
Joseph Carter 2000-06-15 12:05:41 +00:00
parent 1161fee40b
commit ee02c7385b
7 changed files with 80 additions and 125 deletions

View file

@ -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;

View file

@ -36,6 +36,7 @@
#include "console.h"
#include "quakefs.h"
#include "sound.h"
#include "client.h"
#include <string.h>
@ -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);
}

View file

@ -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)

View file

@ -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,6 +363,11 @@ void GL_DrawAliasFrame (aliashdr_t *paliashdr, int posenum)
int *order;
int count;
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);
@ -781,6 +787,7 @@ void R_PolyBlend (void)
GL_DisableMultitexture();
glEnable (GL_BLEND);
glDisable (GL_DEPTH_TEST);
glDisable (GL_TEXTURE_2D);

View file

@ -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");

View file

@ -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 ; i<p->numverts ; 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 ; i<MAX_LIGHTMAPS ; i++)
{
@ -509,16 +516,6 @@ void R_BlendLightmaps (void)
{
lightmap_modified[i] = false;
theRect = &lightmap_rectchange[i];
// theRect->l = 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
@ -715,8 +713,10 @@ void R_DrawWaterSurfaces (void)
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,18 +1008,13 @@ void R_RecursiveWorldNode (mnode_t *node)
side = SURF_PLANEBACK;
else if (dot > BACKFACE_EPSILON)
side = 0;
{
for ( ; c ; c--, surf++)
{
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)) )
if ((dot < 0) ^ !!(surf->flags & SURF_PLANEBACK))
continue; // wrong side
// if sorting by texture, just store it out
@ -1034,12 +1034,9 @@ void R_RecursiveWorldNode (mnode_t *node)
waterchain = surf;
} else
R_DrawSequentialPoly (surf);
}
}
}
// recurse down the back side
R_RecursiveWorldNode (node->children[!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);
}

View file

@ -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] ; i<p->numverts ; 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);