mirror of
https://git.code.sf.net/p/quake/newtree
synced 2025-03-14 04:01:06 +00:00
GL cleanup. (cleanup after Endy mainly)
This commit is contained in:
parent
fa7a67e9fb
commit
0b826825ec
4 changed files with 89 additions and 132 deletions
|
@ -371,13 +371,8 @@ void GL_DrawAliasFrame (aliashdr_t *paliashdr, int posenum)
|
||||||
verts += posenum * paliashdr->poseverts;
|
verts += posenum * paliashdr->poseverts;
|
||||||
order = (int *)((byte *)paliashdr + paliashdr->commands);
|
order = (int *)((byte *)paliashdr + paliashdr->commands);
|
||||||
|
|
||||||
if (modelalpha != 1.0)
|
if (modelalpha != 1.0)
|
||||||
{
|
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glDepthMask(0);
|
|
||||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
@ -401,14 +396,9 @@ void GL_DrawAliasFrame (aliashdr_t *paliashdr, int posenum)
|
||||||
|
|
||||||
// normals and vertexes come from the frame list
|
// normals and vertexes come from the frame list
|
||||||
l = shadedots[verts->lightnormalindex] * shadelight;
|
l = shadedots[verts->lightnormalindex] * shadelight;
|
||||||
|
|
||||||
// Ender: Test (Colormod) [QSG Begin]
|
// LordHavoc: cleanup after Endy
|
||||||
if (modelalpha) {
|
glColor4f(shadecolor[0] * l, shadecolor[1] * l, shadecolor[2] * l, modelalpha);
|
||||||
glColor4f(shadecolor[0] * l, shadecolor[1] * l, shadecolor[2] * l, modelalpha);
|
|
||||||
} else {
|
|
||||||
glColor3f(shadecolor[0] * l, shadecolor[1] * l, shadecolor[2] * l);
|
|
||||||
}
|
|
||||||
// Ender: Test (Colormod) [QSG End]
|
|
||||||
|
|
||||||
glVertex3f (verts->v[0], verts->v[1], verts->v[2]);
|
glVertex3f (verts->v[0], verts->v[1], verts->v[2]);
|
||||||
verts++;
|
verts++;
|
||||||
|
@ -417,12 +407,8 @@ void GL_DrawAliasFrame (aliashdr_t *paliashdr, int posenum)
|
||||||
glEnd ();
|
glEnd ();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (modelalpha != 1.0) {
|
if (modelalpha != 1.0)
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // normal alpha blend
|
glDepthMask(1);
|
||||||
glDisable(GL_BLEND);
|
|
||||||
glDepthMask(1);
|
|
||||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -546,6 +532,10 @@ void R_DrawAliasModel (entity_t *e)
|
||||||
if (R_CullBox (mins, maxs))
|
if (R_CullBox (mins, maxs))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// FIXME: shadecolor is supposed to be the lighting for the model, not just colormod
|
||||||
|
shadecolor[0] = currententity->colormod[0];
|
||||||
|
shadecolor[1] = currententity->colormod[1];
|
||||||
|
shadecolor[2] = currententity->colormod[2];
|
||||||
|
|
||||||
VectorCopy (currententity->origin, r_entorigin);
|
VectorCopy (currententity->origin, r_entorigin);
|
||||||
VectorSubtract (r_origin, r_entorigin, modelorg);
|
VectorSubtract (r_origin, r_entorigin, modelorg);
|
||||||
|
@ -569,7 +559,8 @@ void R_DrawAliasModel (entity_t *e)
|
||||||
dist);
|
dist);
|
||||||
add = (cl_dlights[lnum].radius * cl_dlights[lnum].radius * 8) / (Length(dist) * Length(dist)); // FIXME Deek
|
add = (cl_dlights[lnum].radius * cl_dlights[lnum].radius * 8) / (Length(dist) * Length(dist)); // FIXME Deek
|
||||||
|
|
||||||
if (add > 0) {
|
if (add > 0)
|
||||||
|
{
|
||||||
ambientlight += add;
|
ambientlight += add;
|
||||||
//ZOID models should be affected by dlights as well
|
//ZOID models should be affected by dlights as well
|
||||||
shadelight += add;
|
shadelight += add;
|
||||||
|
@ -584,11 +575,12 @@ void R_DrawAliasModel (entity_t *e)
|
||||||
shadelight = 192 - ambientlight;
|
shadelight = 192 - ambientlight;
|
||||||
|
|
||||||
// ZOID: never allow players to go totally black
|
// ZOID: never allow players to go totally black
|
||||||
if (!strcmp(clmodel->name, "progs/player.mdl")) {
|
if (!strcmp(clmodel->name, "progs/player.mdl"))
|
||||||
|
{
|
||||||
if (ambientlight < 8)
|
if (ambientlight < 8)
|
||||||
ambientlight = shadelight = 8;
|
ambientlight = shadelight = 8;
|
||||||
|
}
|
||||||
} else if (!strcmp (clmodel->name, "progs/flame2.mdl")
|
else if (!strcmp (clmodel->name, "progs/flame2.mdl")
|
||||||
|| !strcmp (clmodel->name, "progs/flame.mdl") )
|
|| !strcmp (clmodel->name, "progs/flame.mdl") )
|
||||||
// HACK HACK HACK -- no fullbright colors, so make torches full light
|
// HACK HACK HACK -- no fullbright colors, so make torches full light
|
||||||
ambientlight = shadelight = 256;
|
ambientlight = shadelight = 256;
|
||||||
|
@ -618,11 +610,14 @@ void R_DrawAliasModel (entity_t *e)
|
||||||
glPushMatrix ();
|
glPushMatrix ();
|
||||||
R_RotateForEntity (e);
|
R_RotateForEntity (e);
|
||||||
|
|
||||||
if (!strcmp (clmodel->name, "progs/eyes.mdl") ) {
|
if (!strcmp (clmodel->name, "progs/eyes.mdl") )
|
||||||
|
{
|
||||||
glTranslatef (paliashdr->scale_origin[0], paliashdr->scale_origin[1], paliashdr->scale_origin[2] - (22 + 8));
|
glTranslatef (paliashdr->scale_origin[0], paliashdr->scale_origin[1], paliashdr->scale_origin[2] - (22 + 8));
|
||||||
// double size of eyes, since they are really hard to see in gl
|
// double size of eyes, since they are really hard to see in gl
|
||||||
glScalef (paliashdr->scale[0]*2, paliashdr->scale[1]*2, paliashdr->scale[2]*2);
|
glScalef (paliashdr->scale[0]*2, paliashdr->scale[1]*2, paliashdr->scale[2]*2);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
glTranslatef (paliashdr->scale_origin[0], paliashdr->scale_origin[1], paliashdr->scale_origin[2]);
|
glTranslatef (paliashdr->scale_origin[0], paliashdr->scale_origin[1], paliashdr->scale_origin[2]);
|
||||||
glScalef (paliashdr->scale[0], paliashdr->scale[1], paliashdr->scale[2]);
|
glScalef (paliashdr->scale[0], paliashdr->scale[1], paliashdr->scale[2]);
|
||||||
}
|
}
|
||||||
|
@ -635,7 +630,8 @@ void R_DrawAliasModel (entity_t *e)
|
||||||
if (currententity->scoreboard && !gl_nocolors->value)
|
if (currententity->scoreboard && !gl_nocolors->value)
|
||||||
{
|
{
|
||||||
i = currententity->scoreboard - cl.players;
|
i = currententity->scoreboard - cl.players;
|
||||||
if (!currententity->scoreboard->skin) {
|
if (!currententity->scoreboard->skin)
|
||||||
|
{
|
||||||
Skin_Find(currententity->scoreboard);
|
Skin_Find(currententity->scoreboard);
|
||||||
R_TranslatePlayerSkin(i);
|
R_TranslatePlayerSkin(i);
|
||||||
}
|
}
|
||||||
|
@ -684,45 +680,35 @@ void R_DrawEntitiesOnList (void)
|
||||||
|
|
||||||
if (!r_drawentities->value)
|
if (!r_drawentities->value)
|
||||||
return;
|
return;
|
||||||
// Ender (Extend)
|
|
||||||
modelalpha = currententity->alpha;
|
|
||||||
shadecolor[0] = currententity->colormod[0];
|
|
||||||
shadecolor[1] = currententity->colormod[1];
|
|
||||||
shadecolor[2] = currententity->colormod[2];
|
|
||||||
|
|
||||||
// draw sprites seperately, because of alpha blending
|
// LordHavoc: split into 3 loops to simplify state changes
|
||||||
for (i=0 ; i<cl_numvisedicts ; i++)
|
for (i=0 ; i<cl_numvisedicts ; i++)
|
||||||
{
|
{
|
||||||
|
if (cl_visedicts[i].model->type != mod_brush)
|
||||||
|
continue;
|
||||||
currententity = &cl_visedicts[i];
|
currententity = &cl_visedicts[i];
|
||||||
|
modelalpha = currententity->alpha;
|
||||||
|
|
||||||
switch (currententity->model->type)
|
R_DrawBrushModel (currententity);
|
||||||
{
|
|
||||||
case mod_alias:
|
|
||||||
R_DrawAliasModel (currententity);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case mod_brush:
|
|
||||||
R_DrawBrushModel (currententity);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0 ; i<cl_numvisedicts ; i++)
|
for (i=0 ; i<cl_numvisedicts ; i++)
|
||||||
{
|
{
|
||||||
|
if (cl_visedicts[i].model->type != mod_brush)
|
||||||
|
continue;
|
||||||
|
currententity = &cl_visedicts[i];
|
||||||
|
modelalpha = currententity->alpha;
|
||||||
|
|
||||||
|
R_DrawAliasModel (currententity);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i=0 ; i<cl_numvisedicts ; i++)
|
||||||
|
{
|
||||||
|
if (cl_visedicts[i].model->type != mod_sprite)
|
||||||
|
continue;
|
||||||
currententity = &cl_visedicts[i];
|
currententity = &cl_visedicts[i];
|
||||||
|
|
||||||
switch (currententity->model->type)
|
R_DrawSpriteModel (currententity);
|
||||||
{
|
|
||||||
case mod_sprite:
|
|
||||||
R_DrawSpriteModel (currententity);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default :
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -733,63 +719,18 @@ R_DrawViewModel
|
||||||
*/
|
*/
|
||||||
void R_DrawViewModel (void)
|
void R_DrawViewModel (void)
|
||||||
{
|
{
|
||||||
float ambient[4], diffuse[4];
|
if (!r_drawviewmodel->value
|
||||||
int j;
|
|| !Cam_DrawViewModel()
|
||||||
int lnum;
|
|| envmap
|
||||||
vec3_t dist;
|
|| !r_drawentities->value
|
||||||
float add;
|
|| (cl.stats[STAT_ITEMS] & IT_INVISIBILITY)
|
||||||
dlight_t *dl;
|
|| cl.stats[STAT_HEALTH] <= 0)
|
||||||
int ambientlight, shadelight;
|
|
||||||
|
|
||||||
if (!r_drawviewmodel->value || !Cam_DrawViewModel())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (envmap)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!r_drawentities->value)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (cl.stats[STAT_ITEMS] & IT_INVISIBILITY)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (cl.stats[STAT_HEALTH] <= 0)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
currententity = &cl.viewent;
|
currententity = &cl.viewent;
|
||||||
if (!currententity->model)
|
if (!currententity->model)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
j = R_LightPoint (currententity->origin);
|
|
||||||
|
|
||||||
if (j < 24)
|
|
||||||
j = 24; // allways give some light on gun
|
|
||||||
ambientlight = j;
|
|
||||||
shadelight = j;
|
|
||||||
|
|
||||||
shadecolor[0] = shadecolor[1] = shadecolor[2] = 0;
|
|
||||||
|
|
||||||
// add dynamic lights
|
|
||||||
for (lnum=0 ; lnum<MAX_DLIGHTS ; lnum++)
|
|
||||||
{
|
|
||||||
dl = &cl_dlights[lnum];
|
|
||||||
if (!dl->radius)
|
|
||||||
continue;
|
|
||||||
if (!dl->radius)
|
|
||||||
continue;
|
|
||||||
if (dl->die < cl.time)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
VectorSubtract (currententity->origin, dl->origin, dist);
|
|
||||||
add = (dl->radius * dl->radius * 8) / (Length(dist) * Length(dist)); // FIXME Deek
|
|
||||||
// add = dl->radius - Length(dist);
|
|
||||||
if (add > 0)
|
|
||||||
ambientlight += add;
|
|
||||||
}
|
|
||||||
|
|
||||||
ambient[0] = ambient[1] = ambient[2] = ambient[3] = (float)ambientlight / 128;
|
|
||||||
diffuse[0] = diffuse[1] = diffuse[2] = diffuse[3] = (float)shadelight / 128;
|
|
||||||
|
|
||||||
// hack the depth range to prevent view model from poking into walls
|
// hack the depth range to prevent view model from poking into walls
|
||||||
glDepthRange (gldepthmin, gldepthmin + 0.3*(gldepthmax-gldepthmin));
|
glDepthRange (gldepthmin, gldepthmin + 0.3*(gldepthmax-gldepthmin));
|
||||||
R_DrawAliasModel (currententity);
|
R_DrawAliasModel (currententity);
|
||||||
|
|
|
@ -512,28 +512,34 @@ R_TimeRefresh_f
|
||||||
For program optimization
|
For program optimization
|
||||||
====================
|
====================
|
||||||
*/
|
*/
|
||||||
|
// LordHavoc: improved appearance and accuracy of timerefresh
|
||||||
void R_TimeRefresh_f (void)
|
void R_TimeRefresh_f (void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
float start, stop, time;
|
double start, stop, time;
|
||||||
|
|
||||||
glDrawBuffer (GL_FRONT);
|
// glDrawBuffer (GL_FRONT);
|
||||||
glFinish ();
|
glFinish ();
|
||||||
|
GL_EndRendering ();
|
||||||
|
|
||||||
start = Sys_DoubleTime ();
|
start = Sys_DoubleTime ();
|
||||||
for (i=0 ; i<128 ; i++)
|
for (i=0 ; i<128 ; i++)
|
||||||
{
|
{
|
||||||
|
GL_BeginRendering();
|
||||||
r_refdef.viewangles[1] = i/128.0*360.0;
|
r_refdef.viewangles[1] = i/128.0*360.0;
|
||||||
R_RenderView ();
|
R_RenderView ();
|
||||||
|
glFinish ();
|
||||||
|
GL_EndRendering ();
|
||||||
}
|
}
|
||||||
|
|
||||||
glFinish ();
|
// glFinish ();
|
||||||
stop = Sys_DoubleTime ();
|
stop = Sys_DoubleTime ();
|
||||||
time = stop-start;
|
time = stop-start;
|
||||||
Con_Printf ("%f seconds (%f fps)\n", time, 128/time);
|
Con_Printf ("%f seconds (%f fps)\n", time, 128/time);
|
||||||
|
|
||||||
glDrawBuffer (GL_BACK);
|
// glDrawBuffer (GL_BACK);
|
||||||
GL_EndRendering ();
|
// GL_EndRendering ();
|
||||||
|
GL_BeginRendering();
|
||||||
}
|
}
|
||||||
|
|
||||||
void D_FlushCaches (void)
|
void D_FlushCaches (void)
|
||||||
|
|
|
@ -257,7 +257,9 @@ store:
|
||||||
t = (int) *bl++ >> 8;
|
t = (int) *bl++ >> 8;
|
||||||
*dest++ = bound(0, t, 255);
|
*dest++ = bound(0, t, 255);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
stride -= smax;
|
stride -= smax;
|
||||||
bl = blocklights;
|
bl = blocklights;
|
||||||
for (i = 0; i < tmax; i++, dest += stride)
|
for (i = 0; i < tmax; i++, dest += stride)
|
||||||
|
@ -334,7 +336,8 @@ void GL_SelectTexture (GLenum target);
|
||||||
|
|
||||||
void GL_DisableMultitexture(void)
|
void GL_DisableMultitexture(void)
|
||||||
{
|
{
|
||||||
if (mtexenabled) {
|
if (mtexenabled)
|
||||||
|
{
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
GL_SelectTexture(0);
|
GL_SelectTexture(0);
|
||||||
mtexenabled = false;
|
mtexenabled = false;
|
||||||
|
@ -343,7 +346,8 @@ void GL_DisableMultitexture(void)
|
||||||
|
|
||||||
void GL_EnableMultitexture(void)
|
void GL_EnableMultitexture(void)
|
||||||
{
|
{
|
||||||
if (gl_mtexable) {
|
if (gl_mtexable)
|
||||||
|
{
|
||||||
GL_SelectTexture(1);
|
GL_SelectTexture(1);
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
mtexenabled = true;
|
mtexenabled = true;
|
||||||
|
@ -410,7 +414,9 @@ void R_DrawSequentialPoly (msurface_t *s)
|
||||||
}
|
}
|
||||||
glEnd ();
|
glEnd ();
|
||||||
return;
|
return;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
p = s->polys;
|
p = s->polys;
|
||||||
|
|
||||||
t = R_TextureAnimation (s->texinfo->texture);
|
t = R_TextureAnimation (s->texinfo->texture);
|
||||||
|
@ -692,23 +698,29 @@ void R_DrawWaterSurfaces (void)
|
||||||
|
|
||||||
glLoadMatrixf (r_world_matrix);
|
glLoadMatrixf (r_world_matrix);
|
||||||
|
|
||||||
if (r_wateralpha->value < 1.0) {
|
if (r_wateralpha->value < 1.0)
|
||||||
|
{
|
||||||
glColor4f (0.5, 0.5, 0.5, r_wateralpha->value);
|
glColor4f (0.5, 0.5, 0.5, r_wateralpha->value);
|
||||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||||
} else
|
}
|
||||||
glColor3f (0.5, 0.5, 0.5);
|
else
|
||||||
|
glColor3f (0.5, 0.5, 0.5);
|
||||||
|
|
||||||
if (!gl_texsort->value) {
|
if (!gl_texsort->value)
|
||||||
|
{
|
||||||
if (!waterchain)
|
if (!waterchain)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for ( s = waterchain ; s ; s=s->texturechain) {
|
for ( s = waterchain ; s ; s=s->texturechain)
|
||||||
|
{
|
||||||
glBindTexture (GL_TEXTURE_2D, s->texinfo->texture->gl_texturenum);
|
glBindTexture (GL_TEXTURE_2D, s->texinfo->texture->gl_texturenum);
|
||||||
EmitWaterPolys (s);
|
EmitWaterPolys (s);
|
||||||
}
|
}
|
||||||
|
|
||||||
waterchain = NULL;
|
waterchain = NULL;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
for (i=0 ; i<cl.worldmodel->numtextures ; i++)
|
for (i=0 ; i<cl.worldmodel->numtextures ; i++)
|
||||||
{
|
{
|
||||||
|
@ -826,13 +838,7 @@ void R_DrawBrushModel (entity_t *e)
|
||||||
if (R_CullBox (mins, maxs))
|
if (R_CullBox (mins, maxs))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Ender: Extend (Alpha) [QSG - Begin]
|
glColor3f (1, 1, 1);
|
||||||
// glEnable(GL_BLEND);
|
|
||||||
// glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
|
||||||
|
|
||||||
// Note: glColor4f and gl_texsort->value = 1 for alpha! :)
|
|
||||||
glColor3f (1, 1, 1);
|
|
||||||
// Ender: Extend (Alpha) [QSG - End]
|
|
||||||
|
|
||||||
memset (lightmap_polys, 0, sizeof(lightmap_polys));
|
memset (lightmap_polys, 0, sizeof(lightmap_polys));
|
||||||
|
|
||||||
|
@ -1316,13 +1322,15 @@ void GL_BuildLightmaps (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
gl_colorlights = Cvar_Get ("gl_colorlights", "1", CVAR_ROM,
|
gl_colorlights = Cvar_Get ("gl_colorlights", "1", CVAR_ROM,
|
||||||
"Whether to use RGBA lightmaps or not");
|
"Whether to use RGB lightmaps or not");
|
||||||
|
|
||||||
if (gl_colorlights->value)
|
if (gl_colorlights->value)
|
||||||
{
|
{
|
||||||
gl_lightmap_format = GL_RGB;
|
gl_lightmap_format = GL_RGB;
|
||||||
lightmap_bytes = 3;
|
lightmap_bytes = 3;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
gl_lightmap_format = GL_LUMINANCE;
|
gl_lightmap_format = GL_LUMINANCE;
|
||||||
lightmap_bytes = 1;
|
lightmap_bytes = 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,13 +101,15 @@ V_CalcBlend (void)
|
||||||
a = 1.0 - a3;
|
a = 1.0 - a3;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a > 1.0)
|
// LordHavoc: saturate color
|
||||||
|
if (a)
|
||||||
{
|
{
|
||||||
a2 = 1.0 / a;
|
a2 = 1.0 / a;
|
||||||
r *= a2;
|
r *= a2;
|
||||||
g *= a2;
|
g *= a2;
|
||||||
b *= a2;
|
b *= a2;
|
||||||
a = 1.0;
|
if (a > 1) // clamp alpha blend too
|
||||||
|
a = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
v_blend[0] = min(r, 255.0)/255.0;
|
v_blend[0] = min(r, 255.0)/255.0;
|
||||||
|
|
Loading…
Reference in a new issue