mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 23:32:09 +00:00
Fix a bunch of state leaks that made multitextured fullbrights smear the world.
Now just have one (known) issue with bmodels with fullbright textures not rendering their base texture. Floating fullbrights are nifty! Also a number of optimizations, which need wider performance testing.
This commit is contained in:
parent
6e6df349e4
commit
5157f668ad
5 changed files with 141 additions and 96 deletions
|
@ -37,7 +37,7 @@ void GL_BuildLightmaps (struct model_s **models, int num_models);
|
|||
|
||||
void R_DrawBrushModel (struct entity_s *e);
|
||||
void R_DrawWorld (void);
|
||||
void R_RenderBrushPoly (msurface_t *fa);
|
||||
inline void R_RenderBrushPoly (msurface_t *fa, texture_t *tex);
|
||||
|
||||
void EmitWaterPolys (msurface_t *fa);
|
||||
|
||||
|
|
|
@ -729,9 +729,9 @@ R_DrawAliasModel (entity_t *e)
|
|||
qfglBindTexture (GL_TEXTURE_2D, texture);
|
||||
|
||||
qglActiveTexture (gl_mtex_enum + 1);
|
||||
qfglBindTexture (GL_TEXTURE_2D, fb_texture);
|
||||
qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
|
||||
qfglEnable (GL_TEXTURE_2D);
|
||||
qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
|
||||
qfglBindTexture (GL_TEXTURE_2D, fb_texture);
|
||||
|
||||
// do the heavy lifting
|
||||
if (vo->tex_coord)
|
||||
|
@ -775,8 +775,9 @@ R_DrawAliasModel (entity_t *e)
|
|||
qfglDepthMask (GL_TRUE);
|
||||
qfglEnable (GL_TEXTURE_2D);
|
||||
qfglPopMatrix ();
|
||||
} else if (modelalpha < 1.0)
|
||||
} else if (modelalpha < 1.0) {
|
||||
qfglDepthMask (GL_TRUE);
|
||||
}
|
||||
|
||||
Cache_Release (&e->model->cache);
|
||||
}
|
||||
|
|
|
@ -271,12 +271,28 @@ R_DrawEntitiesOnList (void)
|
|||
|
||||
R_DrawAliasModel (currententity);
|
||||
}
|
||||
qfglColor3ubv (color_white);
|
||||
if (tess)
|
||||
qfglDisable (GL_PN_TRIANGLES_ATI);
|
||||
if (gl_affinemodels->int_val)
|
||||
qfglHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_DONT_CARE);
|
||||
if (gl_mtex_active) { // FIXME: Ugly, but faster than cleaning up in every
|
||||
// R_DrawAliasModel()!
|
||||
qfglColor4ubv (color_white);
|
||||
qglActiveTexture (gl_mtex_enum + 1);
|
||||
qfglEnable (GL_TEXTURE_2D);
|
||||
if (gl_combine_capable && gl_doublebright->int_val) {
|
||||
qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
|
||||
qfglTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);
|
||||
qfglTexEnvf (GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2.0);
|
||||
} else {
|
||||
qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
}
|
||||
qfglDisable (GL_TEXTURE_2D);
|
||||
|
||||
qglActiveTexture (gl_mtex_enum + 0);
|
||||
}
|
||||
|
||||
qfglColor3ubv (color_white);
|
||||
qfglEnable (GL_ALPHA_TEST);
|
||||
if (gl_va_capable)
|
||||
qfglInterleavedArrays (GL_T2F_C4UB_V3F, 0, spriteVertexArray);
|
||||
|
@ -305,11 +321,28 @@ R_DrawViewModel (void)
|
|||
qfglDepthRange (gldepthmin, gldepthmin + 0.3 * (gldepthmax - gldepthmin));
|
||||
if (gl_affinemodels->int_val)
|
||||
qfglHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
||||
|
||||
R_DrawAliasModel (currententity);
|
||||
qfglColor3ubv (color_white);
|
||||
if (gl_mtex_active) { // FIXME: Ugly, but faster than cleaning up in every
|
||||
// R_DrawAliasModel()!
|
||||
qfglColor4ubv (color_white);
|
||||
qglActiveTexture (gl_mtex_enum + 1);
|
||||
qfglEnable (GL_TEXTURE_2D);
|
||||
if (gl_combine_capable && gl_doublebright->int_val) {
|
||||
qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
|
||||
qfglTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);
|
||||
qfglTexEnvf (GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2.0);
|
||||
} else {
|
||||
qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
}
|
||||
qfglDisable (GL_TEXTURE_2D);
|
||||
|
||||
qglActiveTexture (gl_mtex_enum + 0);
|
||||
}
|
||||
if (gl_affinemodels->int_val)
|
||||
qfglHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_DONT_CARE);
|
||||
qfglDepthRange (gldepthmin, gldepthmax);
|
||||
qfglColor3ubv (color_white);
|
||||
}
|
||||
|
||||
static inline int
|
||||
|
@ -556,19 +589,22 @@ R_Mirror (void)
|
|||
s = r_worldentity.model->textures[mirrortexturenum]->texturechain;
|
||||
for (; s; s = s->texturechain) {
|
||||
texture_t *tex;
|
||||
|
||||
if (!s->texinfo->texture->anim_total)
|
||||
tex = s->texinfo->texture;
|
||||
else
|
||||
tex = R_TextureAnimation (s);
|
||||
|
||||
// FIXME: if this is needed, then include header for fullbright_polys
|
||||
// if ( tex->gl_fb_texturenum > 0) {
|
||||
// FIXME: Needs to set the texture, the tmu, and include the header, and then
|
||||
// clean up afterwards.
|
||||
// if (tex->gl_fb_texturenum && gl_mtex_fullbright
|
||||
// && gl_fb_models->int_val) {
|
||||
// s->polys->fb_chain = fullbright_polys[tex->gl_fb_texturenum];
|
||||
// fullbright_polys[tex->gl_fb_texturenum] = s->polys;
|
||||
// }
|
||||
|
||||
qfglBindTexture (GL_TEXTURE_2D, tex->gl_texturenum);
|
||||
R_RenderBrushPoly (s);
|
||||
R_RenderBrushPoly (s, tex);
|
||||
}
|
||||
r_worldentity.model->textures[mirrortexturenum]->texturechain = NULL;
|
||||
qfglColor3ubv (color_white);
|
||||
|
|
|
@ -145,7 +145,7 @@ R_RenderFullbrights (void)
|
|||
}
|
||||
|
||||
inline void
|
||||
R_RenderBrushPoly (msurface_t *fa)
|
||||
R_RenderBrushPoly (msurface_t *fa, texture_t *tex)
|
||||
{
|
||||
float *v;
|
||||
int i;
|
||||
|
@ -156,15 +156,21 @@ R_RenderBrushPoly (msurface_t *fa)
|
|||
v = fa->polys->verts[0];
|
||||
|
||||
if (gl_mtex_active) {
|
||||
if (tex->gl_fb_texturenum && gl_mtex_fullbright
|
||||
&& gl_fb_bmodels->int_val) {
|
||||
for (i = 0; i < fa->polys->numverts; i++, v += VERTEXSIZE) {
|
||||
qglMultiTexCoord2fv (gl_mtex_enum + 0, &v[3]);
|
||||
qglMultiTexCoord2fv (gl_mtex_enum + 1, &v[5]);
|
||||
|
||||
if (gl_mtex_fullbright)
|
||||
qglMultiTexCoord2fv (gl_mtex_enum + 2, &v[3]);
|
||||
|
||||
qfglVertex3fv (v);
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < fa->polys->numverts; i++, v += VERTEXSIZE) {
|
||||
qglMultiTexCoord2fv (gl_mtex_enum + 0, &v[3]);
|
||||
qglMultiTexCoord2fv (gl_mtex_enum + 1, &v[5]);
|
||||
qfglVertex3fv (v);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < fa->polys->numverts; i++, v += VERTEXSIZE) {
|
||||
qfglTexCoord2fv (&v[3]);
|
||||
|
@ -261,24 +267,11 @@ DrawTextureChains (void)
|
|||
texture_t *tex;
|
||||
|
||||
if (gl_mtex_active) {
|
||||
// Fullbrights
|
||||
if (gl_mtex_fullbright) {
|
||||
qglActiveTexture (gl_mtex_enum + 2);
|
||||
qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
|
||||
}
|
||||
|
||||
// Lightmaps
|
||||
qglActiveTexture (gl_mtex_enum +1);
|
||||
if (gl_combine_capable && gl_doublebright->int_val) {
|
||||
qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
|
||||
qfglTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);
|
||||
qfglTexEnvf (GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2.0);
|
||||
} else {
|
||||
qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
}
|
||||
qfglEnable (GL_TEXTURE_2D); // I hope this can go here...
|
||||
qglActiveTexture (gl_mtex_enum + 1);
|
||||
qfglEnable (GL_TEXTURE_2D);
|
||||
|
||||
// Base texture
|
||||
// Base Texture
|
||||
qglActiveTexture (gl_mtex_enum + 0);
|
||||
qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||
} else {
|
||||
|
@ -290,37 +283,37 @@ DrawTextureChains (void)
|
|||
if (!tex)
|
||||
continue;
|
||||
|
||||
if (gl_mtex_active)
|
||||
qglActiveTexture (gl_mtex_enum + 0);
|
||||
|
||||
if (gl_mtex_active) {
|
||||
qfglBindTexture (GL_TEXTURE_2D, tex->gl_texturenum);
|
||||
|
||||
if (gl_mtex_fullbright && gl_fb_bmodels->int_val
|
||||
&& tex->gl_fb_texturenum) {
|
||||
if (tex->gl_fb_texturenum && gl_mtex_fullbright
|
||||
&& gl_fb_bmodels->int_val) {
|
||||
qglActiveTexture (gl_mtex_enum + 2);
|
||||
qfglBindTexture (GL_TEXTURE_2D, tex->gl_fb_texturenum);
|
||||
qfglEnable (GL_TEXTURE_2D);
|
||||
qfglBindTexture (GL_TEXTURE_2D, tex->gl_fb_texturenum);
|
||||
}
|
||||
|
||||
if (gl_mtex_active) {
|
||||
qglActiveTexture (gl_mtex_enum + 1);
|
||||
|
||||
for (s = tex->texturechain; s; s = s->texturechain) {
|
||||
qfglBindTexture (GL_TEXTURE_2D, lightmap_textures +
|
||||
s->lightmaptexturenum);
|
||||
|
||||
R_RenderBrushPoly (s);
|
||||
}
|
||||
} else {
|
||||
for (s = tex->texturechain; s; s = s->texturechain)
|
||||
R_RenderBrushPoly (s);
|
||||
R_RenderBrushPoly (s, tex);
|
||||
}
|
||||
|
||||
if (gl_mtex_fullbright && gl_fb_bmodels->int_val
|
||||
&& tex->gl_fb_texturenum) {
|
||||
if (tex->gl_fb_texturenum && gl_mtex_fullbright
|
||||
&& gl_fb_bmodels->int_val) {
|
||||
qglActiveTexture (gl_mtex_enum + 2);
|
||||
qfglDisable (GL_TEXTURE_2D);
|
||||
}
|
||||
qglActiveTexture (gl_mtex_enum + 0);
|
||||
} else {
|
||||
qfglBindTexture (GL_TEXTURE_2D, tex->gl_texturenum);
|
||||
|
||||
for (s = tex->texturechain; s; s = s->texturechain)
|
||||
R_RenderBrushPoly (s, tex);
|
||||
}
|
||||
|
||||
tex->texturechain = NULL;
|
||||
tex->texturechain_tail = &tex->texturechain;
|
||||
|
@ -336,7 +329,7 @@ DrawTextureChains (void)
|
|||
qglActiveTexture (gl_mtex_enum + 1);
|
||||
qfglDisable (GL_TEXTURE_2D);
|
||||
|
||||
// Rest mode for default TMU
|
||||
// Reset mode for default TMU
|
||||
qglActiveTexture (gl_mtex_enum + 0);
|
||||
qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
}
|
||||
|
@ -429,24 +422,6 @@ R_DrawBrushModel (entity_t *e)
|
|||
R_CalcLightmaps ();
|
||||
psurf = &model->surfaces[model->firstmodelsurface];
|
||||
|
||||
// Fullbrights
|
||||
if (gl_mtex_fullbright) {
|
||||
qglActiveTexture (gl_mtex_enum + 2);
|
||||
qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
|
||||
}
|
||||
|
||||
// Lightmaps
|
||||
qglActiveTexture (gl_mtex_enum + 1);
|
||||
if (gl_doublebright->int_val && gl_combine_capable) {
|
||||
qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
|
||||
qfglTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);
|
||||
qfglTexEnvf (GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2.0);
|
||||
} else {
|
||||
qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
}
|
||||
qfglEnable (GL_TEXTURE_2D);
|
||||
|
||||
// Regular texture (DON'T GL_REPLACE!)
|
||||
qglActiveTexture (gl_mtex_enum + 0);
|
||||
} else {
|
||||
psurf = &model->surfaces[model->firstmodelsurface];
|
||||
|
@ -488,38 +463,45 @@ R_DrawBrushModel (entity_t *e)
|
|||
else
|
||||
tex = R_TextureAnimation (psurf);
|
||||
|
||||
qfglBindTexture (GL_TEXTURE_2D, tex->gl_texturenum);
|
||||
|
||||
qfglColor4fv (color);
|
||||
|
||||
if (gl_fb_bmodels->int_val && gl_mtex_fullbright
|
||||
&& tex->gl_fb_texturenum > 0) {
|
||||
if (gl_mtex_active) {
|
||||
if (tex->gl_fb_texturenum && gl_fb_bmodels->int_val
|
||||
&& gl_mtex_fullbright) {
|
||||
qglActiveTexture (gl_mtex_enum + 2);
|
||||
qfglBindTexture (GL_TEXTURE_2D, tex->gl_fb_texturenum);
|
||||
qfglEnable (GL_TEXTURE_2D);
|
||||
qfglBindTexture (GL_TEXTURE_2D, tex->gl_fb_texturenum);
|
||||
}
|
||||
|
||||
if (gl_mtex_active) {
|
||||
qglActiveTexture (gl_mtex_enum + 1);
|
||||
qfglEnable (GL_TEXTURE_2D);
|
||||
qfglBindTexture (GL_TEXTURE_2D, lightmap_textures +
|
||||
psurf->lightmaptexturenum);
|
||||
|
||||
qglActiveTexture (gl_mtex_enum + 0);
|
||||
qfglBindTexture (GL_TEXTURE_2D, tex->gl_texturenum);
|
||||
} else {
|
||||
qfglBindTexture (GL_TEXTURE_2D, tex->gl_texturenum);
|
||||
}
|
||||
|
||||
R_RenderBrushPoly (psurf);
|
||||
R_RenderBrushPoly (psurf, tex);
|
||||
|
||||
if (gl_fb_bmodels->int_val && gl_mtex_fullbright
|
||||
&& tex->gl_fb_texturenum > 0) {
|
||||
if (gl_mtex_active) {
|
||||
if (tex->gl_fb_texturenum && gl_fb_bmodels->int_val
|
||||
&& gl_mtex_fullbright) {
|
||||
qglActiveTexture (gl_mtex_enum + 2);
|
||||
qfglDisable (GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
if (gl_mtex_active) {
|
||||
qglActiveTexture (gl_mtex_enum + 1);
|
||||
qfglDisable (GL_TEXTURE_2D);
|
||||
|
||||
qglActiveTexture (gl_mtex_enum + 0);
|
||||
}
|
||||
|
||||
qfglColor3ubv (color_white);
|
||||
|
||||
if (tex->gl_fb_texturenum > 0 && gl_fb_bmodels->int_val
|
||||
if (tex->gl_fb_texturenum && gl_fb_bmodels->int_val
|
||||
&& !gl_mtex_fullbright) {
|
||||
psurf->polys->fb_chain =
|
||||
fullbright_polys[tex->gl_fb_texturenum];
|
||||
|
@ -533,7 +515,9 @@ R_DrawBrushModel (entity_t *e)
|
|||
// Go away, lightmap
|
||||
qglActiveTexture (gl_mtex_enum + 1);
|
||||
qfglDisable (GL_TEXTURE_2D);
|
||||
|
||||
qglActiveTexture (gl_mtex_enum + 0);
|
||||
qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
} else {
|
||||
R_CalcAndBlendLightmaps ();
|
||||
}
|
||||
|
@ -597,7 +581,7 @@ visit_node (mnode_t *node, int side)
|
|||
tex = surf->texinfo->texture;
|
||||
else
|
||||
tex = R_TextureAnimation (surf);
|
||||
if (tex->gl_fb_texturenum > 0) {
|
||||
if (tex->gl_fb_texturenum) {
|
||||
surf->polys->fb_chain = fullbright_polys[tex->gl_fb_texturenum];
|
||||
fullbright_polys[tex->gl_fb_texturenum] = surf->polys;
|
||||
}
|
||||
|
|
|
@ -416,7 +416,6 @@ GL_Init_Common (void)
|
|||
|
||||
qfglEnable (GL_BLEND);
|
||||
qfglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
|
||||
CheckMultiTextureExtensions ();
|
||||
|
@ -424,6 +423,31 @@ GL_Init_Common (void)
|
|||
CheckTruFormExtensions ();
|
||||
GL_Common_Init_Cvars ();
|
||||
CheckVertexArraySize ();
|
||||
|
||||
if (gl_mtex_active) {
|
||||
// Fullbrights
|
||||
if (gl_mtex_fullbright) {
|
||||
qglActiveTexture (gl_mtex_enum + 2);
|
||||
qfglEnable (GL_TEXTURE_2D);
|
||||
qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
|
||||
qfglDisable (GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
// Lightmaps
|
||||
qglActiveTexture (gl_mtex_enum + 1);
|
||||
qfglEnable (GL_TEXTURE_2D);
|
||||
if (gl_combine_capable && gl_doublebright->int_val) {
|
||||
qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
|
||||
qfglTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);
|
||||
qfglTexEnvf (GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2.0);
|
||||
} else {
|
||||
qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
}
|
||||
qfglDisable (GL_TEXTURE_2D);
|
||||
|
||||
// Base Texture
|
||||
qglActiveTexture (gl_mtex_enum + 0);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in a new issue