mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 22:31:05 +00:00
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:
parent
3a76cf4eac
commit
a4f3973ef1
4 changed files with 89 additions and 12 deletions
|
@ -36,6 +36,7 @@
|
|||
// Multitexturing
|
||||
extern QF_glActiveTextureARB qglActiveTexture;
|
||||
extern QF_glMultiTexCoord2fARB qglMultiTexCoord2f;
|
||||
extern QF_glMultiTexCoord2fvARB qglMultiTexCoord2fv;
|
||||
extern qboolean gl_mtex_active;
|
||||
extern qboolean gl_mtex_capable;
|
||||
extern GLenum gl_mtex_enum;
|
||||
|
|
|
@ -89,7 +89,6 @@ float shadelight;
|
|||
float *shadedots = r_avertexnormal_dots[0];
|
||||
vec3_t shadevector;
|
||||
|
||||
|
||||
static void
|
||||
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
|
||||
|
||||
|
@ -544,8 +584,6 @@ R_DrawAliasModel (entity_t *e, qboolean cull)
|
|||
fb_texture = skindesc->fb_texnum;
|
||||
}
|
||||
|
||||
qfglBindTexture (GL_TEXTURE_2D, texture);
|
||||
|
||||
if (paliashdr->mdl.ident == POLYHEADER16)
|
||||
vo = GL_GetAliasFrameVerts16 (e->frame, paliashdr, e);
|
||||
else
|
||||
|
@ -554,12 +592,31 @@ R_DrawAliasModel (entity_t *e, qboolean cull)
|
|||
if (modelalpha != 1.0)
|
||||
qfglDepthMask (GL_FALSE);
|
||||
|
||||
GL_DrawAliasFrame (vo);
|
||||
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);
|
||||
|
||||
// This block is GL fullbright support for objects...
|
||||
if (fb_texture) {
|
||||
qfglBindTexture (GL_TEXTURE_2D, fb_texture);
|
||||
GL_DrawAliasFrame_fb (vo);
|
||||
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);
|
||||
|
||||
qfglBindTexture (GL_TEXTURE_2D, fb_texture);
|
||||
GL_DrawAliasFrame_fb (vo);
|
||||
}
|
||||
}
|
||||
|
||||
if (modelalpha != 1.0)
|
||||
|
|
|
@ -262,11 +262,15 @@ R_BuildLightMap (msurface_t *surf, byte * dest, int stride)
|
|||
stride -= smax * lightmap_bytes;
|
||||
bl = blocklights;
|
||||
|
||||
#if 0
|
||||
if (gl_mtex_active) {
|
||||
shift = 7; // 0-1 lightmap range.
|
||||
} else {
|
||||
#endif
|
||||
shift = 8; // 0-2 lightmap range.
|
||||
#if 0
|
||||
}
|
||||
#endif
|
||||
|
||||
switch (lightmap_bytes) {
|
||||
case 4:
|
||||
|
@ -367,6 +371,7 @@ GL_UploadLightmap (int i, int x, int y, int w, int h)
|
|||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void
|
||||
R_DrawMultitexturePoly (msurface_t *s)
|
||||
{
|
||||
|
@ -430,6 +435,7 @@ R_DrawMultitexturePoly (msurface_t *s)
|
|||
|
||||
qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
R_BlendLightmaps (void)
|
||||
|
@ -704,8 +710,10 @@ R_DrawBrushModel (entity_t *e)
|
|||
} else if (psurf->flags & SURF_DRAWSKY) {
|
||||
CHAIN_SURF (psurf, sky_chain);
|
||||
return;
|
||||
#if 0
|
||||
} else if (gl_mtex_active) {
|
||||
R_DrawMultitexturePoly (psurf);
|
||||
#endif
|
||||
} else {
|
||||
texture_t *tex;
|
||||
if (!psurf->texinfo->texture->anim_total)
|
||||
|
@ -722,7 +730,9 @@ R_DrawBrushModel (entity_t *e)
|
|||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (!gl_mtex_active)
|
||||
#endif
|
||||
R_BlendLightmaps ();
|
||||
|
||||
if (gl_fb_bmodels->int_val)
|
||||
|
@ -794,8 +804,10 @@ R_RecursiveWorldNode (mnode_t *node)
|
|||
// CHAIN_SURF (surf, waterchain);
|
||||
} else if (surf->flags & SURF_DRAWSKY) {
|
||||
CHAIN_SURF (surf, sky_chain);
|
||||
#if 0
|
||||
} else if (gl_mtex_active) {
|
||||
R_DrawMultitexturePoly (surf);
|
||||
#endif
|
||||
} else {
|
||||
texture_t *tex;
|
||||
if (!surf->texinfo->texture->anim_total)
|
||||
|
@ -841,7 +853,9 @@ R_DrawWorld (void)
|
|||
|
||||
DrawTextureChains ();
|
||||
|
||||
#if 0
|
||||
if (!gl_mtex_active)
|
||||
#endif
|
||||
R_BlendLightmaps ();
|
||||
|
||||
if (gl_fb_bmodels->int_val)
|
||||
|
@ -1114,8 +1128,10 @@ GL_BuildLightmaps (model_t **models, int num_models)
|
|||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (gl_mtex_active)
|
||||
qglActiveTexture (gl_mtex_enum + 1);
|
||||
#endif
|
||||
|
||||
// upload all lightmaps that were filled
|
||||
for (i = 0; i < MAX_LIGHTMAPS; i++) {
|
||||
|
@ -1134,6 +1150,8 @@ GL_BuildLightmaps (model_t **models, int num_models)
|
|||
GL_UNSIGNED_BYTE, lightmaps[i]);
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (gl_mtex_active)
|
||||
qglActiveTexture (gl_mtex_enum + 0);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -61,8 +61,9 @@ static const char rcsid[] =
|
|||
unsigned char d_15to8table[65536];
|
||||
unsigned int d_8to24table[256];
|
||||
|
||||
QF_glActiveTextureARB qglActiveTexture = NULL;
|
||||
QF_glMultiTexCoord2fARB qglMultiTexCoord2f = NULL;
|
||||
QF_glActiveTextureARB qglActiveTexture = NULL;
|
||||
QF_glMultiTexCoord2fARB qglMultiTexCoord2f = NULL;
|
||||
QF_glMultiTexCoord2fvARB qglMultiTexCoord2fv = NULL;
|
||||
|
||||
const char *gl_extensions;
|
||||
const char *gl_renderer;
|
||||
|
@ -138,8 +139,8 @@ CheckMultiTextureExtensions (void)
|
|||
qfglGetIntegerv (GL_MAX_TEXTURE_UNITS_ARB, &max_texture_units);
|
||||
if (max_texture_units >= 2) {
|
||||
Con_Printf ("enabled, %d TMUs.\n", max_texture_units);
|
||||
qglMultiTexCoord2f = QFGL_ExtensionAddress
|
||||
("glMultiTexCoord2fARB");
|
||||
qglMultiTexCoord2f = QFGL_ExtensionAddress ("glMultiTexCoord2fARB");
|
||||
qglMultiTexCoord2fv = QFGL_ExtensionAddress ("glMultiTexCoord2fvARB");
|
||||
qglActiveTexture = QFGL_ExtensionAddress ("glActiveTextureARB");
|
||||
gl_mtex_enum = GL_TEXTURE0_ARB;
|
||||
if (qglMultiTexCoord2f && gl_mtex_enum)
|
||||
|
|
Loading…
Reference in a new issue