Add multitexture support for Alias models, and disable the multitexture

support for BSP models, until they can be fixed. gl_multitexture should now
actually be a speedup!

NOTE: Some OpenGL implementations have trouble with the texture function
used. 3Dfx Voodoo 1/2 are known to have this trouble. I don't know how to fix
this, or even if it can be fixed. :/
This commit is contained in:
Jeff Teunissen 2002-04-16 16:51:35 +00:00
parent 3a76cf4eac
commit a4f3973ef1
4 changed files with 89 additions and 12 deletions

View file

@ -36,6 +36,7 @@
// Multitexturing // Multitexturing
extern QF_glActiveTextureARB qglActiveTexture; extern QF_glActiveTextureARB qglActiveTexture;
extern QF_glMultiTexCoord2fARB qglMultiTexCoord2f; extern QF_glMultiTexCoord2fARB qglMultiTexCoord2f;
extern QF_glMultiTexCoord2fvARB qglMultiTexCoord2fv;
extern qboolean gl_mtex_active; extern qboolean gl_mtex_active;
extern qboolean gl_mtex_capable; extern qboolean gl_mtex_capable;
extern GLenum gl_mtex_enum; extern GLenum gl_mtex_enum;

View file

@ -89,7 +89,6 @@ float shadelight;
float *shadedots = r_avertexnormal_dots[0]; float *shadedots = r_avertexnormal_dots[0];
vec3_t shadevector; vec3_t shadevector;
static void static void
GL_DrawAliasFrame (vert_order_t *vo) GL_DrawAliasFrame (vert_order_t *vo)
{ {
@ -165,6 +164,47 @@ GL_DrawAliasFrame_fb (vert_order_t *vo)
} }
} }
static void
GL_DrawAliasFrameMulti (vert_order_t *vo)
{
float color[4];
int count;
int *order;
blended_vert_t *verts;
verts = vo->verts;
order = vo->order;
color[3] = modelalpha;
while ((count = *order++)) {
// get the vertex count and primitive type
if (count < 0) {
count = -count;
qfglBegin (GL_TRIANGLE_FAN);
} else {
qfglBegin (GL_TRIANGLE_STRIP);
}
do {
// texture coordinates come from the draw list
qglMultiTexCoord2fv (gl_mtex_enum + 0, (float *) order);
qglMultiTexCoord2fv (gl_mtex_enum + 1, (float *) order);
order += 2;
// normals and vertexes come from the frame list
VectorScale (shadecolor, verts->lightdot, color);
qfglColor4fv (color);
qfglVertex3fv (verts->vert);
verts++;
} while (--count);
qfglEnd ();
}
}
/* /*
GL_DrawAliasShadow GL_DrawAliasShadow
@ -544,8 +584,6 @@ R_DrawAliasModel (entity_t *e, qboolean cull)
fb_texture = skindesc->fb_texnum; fb_texture = skindesc->fb_texnum;
} }
qfglBindTexture (GL_TEXTURE_2D, texture);
if (paliashdr->mdl.ident == POLYHEADER16) if (paliashdr->mdl.ident == POLYHEADER16)
vo = GL_GetAliasFrameVerts16 (e->frame, paliashdr, e); vo = GL_GetAliasFrameVerts16 (e->frame, paliashdr, e);
else else
@ -554,13 +592,32 @@ R_DrawAliasModel (entity_t *e, qboolean cull)
if (modelalpha != 1.0) if (modelalpha != 1.0)
qfglDepthMask (GL_FALSE); qfglDepthMask (GL_FALSE);
if (!fb_texture) { // Model has no fullbrights, don't bother with multi
qfglBindTexture (GL_TEXTURE_2D, texture);
GL_DrawAliasFrame (vo);
} else { // try multitexture
if (gl_mtex_active) { // set up the textures
qglActiveTexture (gl_mtex_enum + 0);
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);
GL_DrawAliasFrameMulti (vo); // do the heavy lifting
// restore the settings
qfglDisable (GL_TEXTURE_2D);
qglActiveTexture (gl_mtex_enum + 0);
} else {
qfglBindTexture (GL_TEXTURE_2D, texture);
GL_DrawAliasFrame (vo); GL_DrawAliasFrame (vo);
// This block is GL fullbright support for objects...
if (fb_texture) {
qfglBindTexture (GL_TEXTURE_2D, fb_texture); qfglBindTexture (GL_TEXTURE_2D, fb_texture);
GL_DrawAliasFrame_fb (vo); GL_DrawAliasFrame_fb (vo);
} }
}
if (modelalpha != 1.0) if (modelalpha != 1.0)
qfglDepthMask (GL_TRUE); qfglDepthMask (GL_TRUE);

View file

@ -262,11 +262,15 @@ R_BuildLightMap (msurface_t *surf, byte * dest, int stride)
stride -= smax * lightmap_bytes; stride -= smax * lightmap_bytes;
bl = blocklights; bl = blocklights;
#if 0
if (gl_mtex_active) { if (gl_mtex_active) {
shift = 7; // 0-1 lightmap range. shift = 7; // 0-1 lightmap range.
} else { } else {
#endif
shift = 8; // 0-2 lightmap range. shift = 8; // 0-2 lightmap range.
#if 0
} }
#endif
switch (lightmap_bytes) { switch (lightmap_bytes) {
case 4: case 4:
@ -367,6 +371,7 @@ GL_UploadLightmap (int i, int x, int y, int w, int h)
} }
} }
#if 0
static void static void
R_DrawMultitexturePoly (msurface_t *s) R_DrawMultitexturePoly (msurface_t *s)
{ {
@ -430,6 +435,7 @@ R_DrawMultitexturePoly (msurface_t *s)
qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
} }
#endif
static void static void
R_BlendLightmaps (void) R_BlendLightmaps (void)
@ -704,8 +710,10 @@ R_DrawBrushModel (entity_t *e)
} else if (psurf->flags & SURF_DRAWSKY) { } else if (psurf->flags & SURF_DRAWSKY) {
CHAIN_SURF (psurf, sky_chain); CHAIN_SURF (psurf, sky_chain);
return; return;
#if 0
} else if (gl_mtex_active) { } else if (gl_mtex_active) {
R_DrawMultitexturePoly (psurf); R_DrawMultitexturePoly (psurf);
#endif
} else { } else {
texture_t *tex; texture_t *tex;
if (!psurf->texinfo->texture->anim_total) if (!psurf->texinfo->texture->anim_total)
@ -722,7 +730,9 @@ R_DrawBrushModel (entity_t *e)
} }
} }
#if 0
if (!gl_mtex_active) if (!gl_mtex_active)
#endif
R_BlendLightmaps (); R_BlendLightmaps ();
if (gl_fb_bmodels->int_val) if (gl_fb_bmodels->int_val)
@ -794,8 +804,10 @@ R_RecursiveWorldNode (mnode_t *node)
// CHAIN_SURF (surf, waterchain); // CHAIN_SURF (surf, waterchain);
} else if (surf->flags & SURF_DRAWSKY) { } else if (surf->flags & SURF_DRAWSKY) {
CHAIN_SURF (surf, sky_chain); CHAIN_SURF (surf, sky_chain);
#if 0
} else if (gl_mtex_active) { } else if (gl_mtex_active) {
R_DrawMultitexturePoly (surf); R_DrawMultitexturePoly (surf);
#endif
} else { } else {
texture_t *tex; texture_t *tex;
if (!surf->texinfo->texture->anim_total) if (!surf->texinfo->texture->anim_total)
@ -841,7 +853,9 @@ R_DrawWorld (void)
DrawTextureChains (); DrawTextureChains ();
#if 0
if (!gl_mtex_active) if (!gl_mtex_active)
#endif
R_BlendLightmaps (); R_BlendLightmaps ();
if (gl_fb_bmodels->int_val) if (gl_fb_bmodels->int_val)
@ -1114,8 +1128,10 @@ GL_BuildLightmaps (model_t **models, int num_models)
} }
} }
#if 0
if (gl_mtex_active) if (gl_mtex_active)
qglActiveTexture (gl_mtex_enum + 1); qglActiveTexture (gl_mtex_enum + 1);
#endif
// upload all lightmaps that were filled // upload all lightmaps that were filled
for (i = 0; i < MAX_LIGHTMAPS; i++) { for (i = 0; i < MAX_LIGHTMAPS; i++) {
@ -1134,6 +1150,8 @@ GL_BuildLightmaps (model_t **models, int num_models)
GL_UNSIGNED_BYTE, lightmaps[i]); GL_UNSIGNED_BYTE, lightmaps[i]);
} }
#if 0
if (gl_mtex_active) if (gl_mtex_active)
qglActiveTexture (gl_mtex_enum + 0); qglActiveTexture (gl_mtex_enum + 0);
#endif
} }

View file

@ -63,6 +63,7 @@ unsigned int d_8to24table[256];
QF_glActiveTextureARB qglActiveTexture = NULL; QF_glActiveTextureARB qglActiveTexture = NULL;
QF_glMultiTexCoord2fARB qglMultiTexCoord2f = NULL; QF_glMultiTexCoord2fARB qglMultiTexCoord2f = NULL;
QF_glMultiTexCoord2fvARB qglMultiTexCoord2fv = NULL;
const char *gl_extensions; const char *gl_extensions;
const char *gl_renderer; const char *gl_renderer;
@ -138,8 +139,8 @@ CheckMultiTextureExtensions (void)
qfglGetIntegerv (GL_MAX_TEXTURE_UNITS_ARB, &max_texture_units); qfglGetIntegerv (GL_MAX_TEXTURE_UNITS_ARB, &max_texture_units);
if (max_texture_units >= 2) { if (max_texture_units >= 2) {
Con_Printf ("enabled, %d TMUs.\n", max_texture_units); Con_Printf ("enabled, %d TMUs.\n", max_texture_units);
qglMultiTexCoord2f = QFGL_ExtensionAddress qglMultiTexCoord2f = QFGL_ExtensionAddress ("glMultiTexCoord2fARB");
("glMultiTexCoord2fARB"); qglMultiTexCoord2fv = QFGL_ExtensionAddress ("glMultiTexCoord2fvARB");
qglActiveTexture = QFGL_ExtensionAddress ("glActiveTextureARB"); qglActiveTexture = QFGL_ExtensionAddress ("glActiveTextureARB");
gl_mtex_enum = GL_TEXTURE0_ARB; gl_mtex_enum = GL_TEXTURE0_ARB;
if (qglMultiTexCoord2f && gl_mtex_enum) if (qglMultiTexCoord2f && gl_mtex_enum)