ARB multitexture for glx, wgl, and 3dfx targets

This commit is contained in:
Joseph Carter 2000-06-09 21:34:21 +00:00
parent 53b2cafae8
commit 3287c0e38b
6 changed files with 142 additions and 82 deletions

View file

@ -243,15 +243,16 @@ void GL_Bind (int texnum);
typedef void (GLAPIENTRY *lpMTexFUNC) (GLenum, GLfloat, GLfloat);
typedef void (GLAPIENTRY *lpSelTexFUNC) (GLenum);
extern lpMTexFUNC qglMTexCoord2fSGIS;
extern lpSelTexFUNC qglSelectTextureSGIS;
extern lpMTexFUNC qglMTexCoord2f;
extern lpSelTexFUNC qglSelectTexture;
extern qboolean gl_mtexable;
extern qboolean gl_arb_mtex;
extern int gl_mtex_enum;
void GL_DisableMultitexture(void);
void GL_EnableMultitexture(void);
void GL_DisableMultitexture (void);
void GL_EnableMultitexture (void);
void GL_SelectTexture (GLenum target);
//
// gl_warp.c

View file

@ -1388,18 +1388,17 @@ int GL_LoadPicTexture (qpic_t *pic)
/****************************************/
static GLenum oldtarget = TEXTURE0_SGIS;
static GLenum oldtarget = 0; // TEXTURE0_SGIS;
void GL_SelectTexture (GLenum target)
{
if (!gl_mtexable)
return;
#ifdef _WIN32 // FIXME - only multi-texture under Win32
qglSelectTextureSGIS(target);
#endif
qglSelectTexture (target + gl_mtex_enum);
if (target == oldtarget)
return;
cnttextures[oldtarget-TEXTURE0_SGIS] = currenttexture;
currenttexture = cnttextures[target-TEXTURE0_SGIS];
cnttextures[oldtarget] = currenttexture;
currenttexture = cnttextures[target];
oldtarget = target;
}

View file

@ -339,8 +339,8 @@ extern float speedscale; // for top sky and bottom sky
void DrawGLWaterPoly (glpoly_t *p);
void DrawGLWaterPolyLightmap (glpoly_t *p);
lpMTexFUNC qglMTexCoord2fSGIS = NULL;
lpSelTexFUNC qglSelectTextureSGIS = NULL;
lpMTexFUNC qglMTexCoord2f = NULL;
lpSelTexFUNC qglSelectTexture = NULL;
qboolean mtexenabled = false;
@ -350,7 +350,7 @@ void GL_DisableMultitexture(void)
{
if (mtexenabled) {
glDisable(GL_TEXTURE_2D);
GL_SelectTexture(TEXTURE0_SGIS);
GL_SelectTexture(0);
mtexenabled = false;
}
}
@ -358,7 +358,7 @@ void GL_DisableMultitexture(void)
void GL_EnableMultitexture(void)
{
if (gl_mtexable) {
GL_SelectTexture(TEXTURE1_SGIS);
GL_SelectTexture(1);
glEnable(GL_TEXTURE_2D);
mtexenabled = true;
}
@ -394,7 +394,7 @@ void R_DrawSequentialPoly (msurface_t *s)
t = R_TextureAnimation (s->texinfo->texture);
// Binds world to texture env 0
GL_SelectTexture(TEXTURE0_SGIS);
GL_SelectTexture(0);
GL_Bind (t->gl_texturenum);
// glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
// Binds lightmap to texenv 1
@ -418,8 +418,8 @@ void R_DrawSequentialPoly (msurface_t *s)
v = p->verts[0];
for (i=0 ; i<p->numverts ; i++, v+= VERTEXSIZE)
{
qglMTexCoord2fSGIS (TEXTURE0_SGIS, v[3], v[4]);
qglMTexCoord2fSGIS (TEXTURE1_SGIS, v[5], v[6]);
qglMTexCoord2f (gl_mtex_enum + 0, v[3], v[4]);
qglMTexCoord2f (gl_mtex_enum + 1, v[5], v[6]);
glVertex3fv (v);
}
glEnd ();
@ -492,7 +492,7 @@ void R_DrawSequentialPoly (msurface_t *s)
p = s->polys;
t = R_TextureAnimation (s->texinfo->texture);
GL_SelectTexture(TEXTURE0_SGIS);
GL_SelectTexture(0);
GL_Bind (t->gl_texturenum);
GL_EnableMultitexture();
GL_Bind (lightmap_textures + s->lightmaptexturenum);
@ -514,8 +514,8 @@ void R_DrawSequentialPoly (msurface_t *s)
v = p->verts[0];
for (i=0 ; i<p->numverts ; i++, v+= VERTEXSIZE)
{
qglMTexCoord2fSGIS (TEXTURE0_SGIS, v[3], v[4]);
qglMTexCoord2fSGIS (TEXTURE1_SGIS, v[5], v[6]);
qglMTexCoord2f (gl_mtex_enum + 0, v[3], v[4]);
qglMTexCoord2f (gl_mtex_enum + 1, v[5], v[6]);
nv[0] = v[0] + 8*sin(v[1]*0.05+realtime)*sin(v[2]*0.05+realtime);
nv[1] = v[1] + 8*sin(v[0]*0.05+realtime)*sin(v[2]*0.05+realtime);
@ -860,7 +860,8 @@ 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
glColor3f (0.5, 0.5, 0.5);
if (!gl_texsort->value) {
if (!waterchain)
@ -1528,7 +1529,7 @@ void GL_BuildLightmaps (void)
}
if (!gl_texsort->value)
GL_SelectTexture(TEXTURE1_SGIS);
GL_SelectTexture(1);
//
// upload all lightmaps that were filled
@ -1552,7 +1553,7 @@ void GL_BuildLightmaps (void)
}
if (!gl_texsort->value)
GL_SelectTexture(TEXTURE0_SGIS);
GL_SelectTexture(0);
}

View file

@ -160,7 +160,6 @@ void VID_SetPalette (unsigned char *palette)
int k;
unsigned short i;
unsigned *table;
//#ifdef QUAKEWORLD
FILE *f;
char s[255];
//#endif
@ -187,7 +186,6 @@ void VID_SetPalette (unsigned char *palette)
d_8to24table[255] = 0; // 255 is transparent
// JACK: 3D distance calcs - k is last closest, l is the distance.
//#ifdef QUAKEWORLD
{
static qboolean palflag = false;
@ -202,7 +200,6 @@ void VID_SetPalette (unsigned char *palette)
fread(d_15to8table, 1<<15, 1, f);
fclose(f);
} else
//#endif // QUAKEWORLD
{
for (i=0; i < (1<<15); i++) {
/* Maps
@ -227,7 +224,6 @@ void VID_SetPalette (unsigned char *palette)
}
d_15to8table[i]=k;
}
//#ifdef QUAKEWORLD
snprintf(s, sizeof(s), "%s/glquake", com_gamedir);
Sys_mkdir (s);
snprintf(s, sizeof(s), "%s/glquake/15to8.pal", com_gamedir);
@ -235,51 +231,66 @@ void VID_SetPalette (unsigned char *palette)
fwrite(d_15to8table, 1<<15, 1, f);
fclose(f);
}
//#endif // QUAKEWORLD
}
}
/*
CheckMultiTextureExtensions
Check for ARB, SGIS, or EXT multitexture support
*/
void
CheckMultiTextureExtensions ( void )
{
Con_Printf ("Checking for multitexture... ");
if (COM_CheckParm ("-nomtex"))
{
Con_Printf ("Not using multitexture.");
Con_Printf ("disabled\n");
return;
}
#ifdef HAVE_DLOPEN
dlhand = dlopen (NULL, RTLD_LAZY);
if (dlhand != NULL)
if (dlhand == NULL)
{
Con_Printf("Multitexture enabled ");
if (strstr(gl_extensions, "GL_SGIS_multitexture "))
{
Con_Printf ("(SGIS)\n");
qglMTexCoord2fSGIS =
(void *)dlsym(dlhand, "glMTexCoord2fSGIS");
qglSelectTextureSGIS =
(void *)dlsym(dlhand, "glSelectTextureSGIS");
gl_mtexable = true;
} else if (strstr(gl_extensions, "GL_EXT_multitexture "))
{
Con_Printf ("(EXT)\n");
qglMTexCoord2fSGIS =
(void *)dlsym(dlhand, "glMTexCoord2fEXT");
qglSelectTextureSGIS =
(void *)dlsym(dlhand, "glSelectTextureEXT");
gl_mtexable = true;
} else {
Con_Printf ("(but not found)\n");
}
dlclose(dlhand);
dlhand = NULL;
} else {
Con_Printf ("unable to check\n");
return;
}
if (strstr(gl_extensions, "GL_ARB_multitexture "))
{
Con_Printf ("GL_ARB_multitexture\n");
qglMTexCoord2f = (void *)dlsym(dlhand, "glMultiTexCoord2fARB");
qglSelectTexture = (void *)dlsym(dlhand, "glActiveTextureARB");
gl_mtex_enum = GL_TEXTURE0_ARB;
gl_mtexable = true;
gl_arb_mtex = true;
} else if (strstr(gl_extensions, "GL_SGIS_multitexture "))
{
Con_Printf ("GL_SGIS_multitexture\n");
qglMTexCoord2f = (void *)dlsym(dlhand, "glMTexCoord2fSGIS");
qglSelectTexture = (void *)dlsym(dlhand, "glSelectTextureSGIS");
gl_mtex_enum = TEXTURE0_SGIS;
gl_mtexable = true;
gl_arb_mtex = false;
} else if (strstr(gl_extensions, "GL_EXT_multitexture "))
{
Con_Printf ("GL_EXT_multitexture\n");
qglMTexCoord2f = (void *)dlsym(dlhand, "glMTexCoord2fEXT");
qglSelectTexture = (void *)dlsym(dlhand, "glSelectTextureEXT");
gl_mtex_enum = TEXTURE0_SGIS;
gl_mtexable = true;
gl_arb_mtex = false;
} else {
Con_Printf ("none found\n");
}
dlclose(dlhand);
dlhand = NULL;
#else
gl_mtexable = false;
#endif
}
/*
===============
GL_Init

View file

@ -293,42 +293,57 @@ void VID_SetPalette (unsigned char *palette)
}
}
/*
CheckMultiTextureExtensions
Check for ARB, SGIS, or EXT multitexture support
*/
void
CheckMultiTextureExtensions ( void )
{
Con_Printf ("Checking for multitexture... ");
if (COM_CheckParm ("-nomtex"))
{
Con_Printf ("Not using multitexture.");
Con_Printf ("disabled\n");
return;
}
#ifdef HAVE_DLOPEN
dlhand = dlopen (NULL, RTLD_LAZY);
if (dlhand != NULL)
if (dlhand == NULL)
{
Con_Printf("Multitexture enabled ");
if (strstr(gl_extensions, "GL_SGIS_multitexture "))
{
Con_Printf ("(SGIS)\n");
qglMTexCoord2fSGIS =
(void *)dlsym(dlhand, "glMTexCoord2fSGIS");
qglSelectTextureSGIS =
(void *)dlsym(dlhand, "glSelectTextureSGIS");
gl_mtexable = true;
} else if (strstr(gl_extensions, "GL_EXT_multitexture "))
{
Con_Printf ("(EXT)\n");
qglMTexCoord2fSGIS =
(void *)dlsym(dlhand, "glMTexCoord2fEXT");
qglSelectTextureSGIS =
(void *)dlsym(dlhand, "glSelectTextureEXT");
gl_mtexable = true;
} else {
Con_Printf ("(but not found)\n");
}
dlclose(dlhand);
dlhand = NULL;
} else {
Con_Printf ("unable to check\n");
return;
}
if (strstr(gl_extensions, "GL_ARB_multitexture "))
{
Con_Printf ("GL_ARB_multitexture\n");
qglMTexCoord2f = (void *)dlsym(dlhand, "glMultiTexCoord2fARB");
qglSelectTexture = (void *)dlsym(dlhand, "glActiveTextureARB");
gl_mtex_enum = GL_TEXTURE0_ARB;
gl_mtexable = true;
gl_arb_mtex = true;
} else if (strstr(gl_extensions, "GL_SGIS_multitexture "))
{
Con_Printf ("GL_SGIS_multitexture\n");
qglMTexCoord2f = (void *)dlsym(dlhand, "glMTexCoord2fSGIS");
qglSelectTexture = (void *)dlsym(dlhand, "glSelectTextureSGIS");
gl_mtex_enum = TEXTURE0_SGIS;
gl_mtexable = true;
gl_arb_mtex = false;
} else if (strstr(gl_extensions, "GL_EXT_multitexture "))
{
Con_Printf ("GL_EXT_multitexture\n");
qglMTexCoord2f = (void *)dlsym(dlhand, "glMTexCoord2fEXT");
qglSelectTexture = (void *)dlsym(dlhand, "glSelectTextureEXT");
gl_mtex_enum = TEXTURE0_SGIS;
gl_mtexable = true;
gl_arb_mtex = false;
} else {
Con_Printf ("none found\n");
}
dlclose(dlhand);
dlhand = NULL;
#else
gl_mtexable = false;
#endif

View file

@ -602,11 +602,44 @@ int texture_extension_number = 1;
#ifdef _WIN32
void CheckMultiTextureExtensions(void)
{
if (strstr(gl_extensions, "GL_SGIS_multitexture ") && !COM_CheckParm("-nomtex")) {
Con_Printf("Multitexture extensions found.\n");
qglMTexCoord2fSGIS = (void *) wglGetProcAddress("glMTexCoord2fSGIS");
qglSelectTextureSGIS = (void *) wglGetProcAddress("glSelectTextureSGIS");
Con_Printf("Checking for multitexture... ");
if (COM_CheckParm ("-nomtex"))
{
Con_Printf ("disabled\n");
return;
}
if (strstr(gl_extensions, "GL_ARB_multitexture "))
{
Con_Printf ("GL_ARB_multitexture\n");
qglMTexCoord2f =
(void *)wglGetProcAddress("glMTexCoord2fARB");
qglSelectTexture =
(void *)wglGetProcAddress("glSelectTextureARB");
gl_mtex_enum = GL_TEXTURE0_ARB;
gl_mtexable = true;
gl_arb_mtex = true;
} else if (strstr(gl_extensions, "GL_SGIS_multitexture "))
{
Con_Printf ("GL_SGIS_multitexture\n");
qglMTexCoord2f =
(void *)wglGetProcAddress("glMTexCoord2fSGIS");
qglSelectTexture =
(void *)wglGetProcAddress("glSelectTextureSGIS");
gl_mtex_enum = TEXTURE0_SGIS;
gl_mtexable = true;
gl_arb_mtex = false;
} else if (strstr(gl_extensions, "GL_EXT_multitexture "))
{
Con_Printf ("GL_EXT_multitexture\n");
qglMTexCoord2f =
(void *)wglGetProcAddress("glMTexCoord2fEXT");
qglSelectTexture =
(void *)wglGetProcAddress("glSelectTextureEXT");
gl_mtex_enum = TEXTURE0_SGIS;
gl_mtexable = true;
gl_arb_mtex = false;
} else {
Con_Printf ("none found\n");
}
}
#else