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 *lpMTexFUNC) (GLenum, GLfloat, GLfloat);
typedef void (GLAPIENTRY *lpSelTexFUNC) (GLenum); typedef void (GLAPIENTRY *lpSelTexFUNC) (GLenum);
extern lpMTexFUNC qglMTexCoord2fSGIS; extern lpMTexFUNC qglMTexCoord2f;
extern lpSelTexFUNC qglSelectTextureSGIS; extern lpSelTexFUNC qglSelectTexture;
extern qboolean gl_mtexable; extern qboolean gl_mtexable;
extern qboolean gl_arb_mtex; extern qboolean gl_arb_mtex;
extern int gl_mtex_enum; extern int gl_mtex_enum;
void GL_DisableMultitexture(void); void GL_DisableMultitexture (void);
void GL_EnableMultitexture(void); void GL_EnableMultitexture (void);
void GL_SelectTexture (GLenum target);
// //
// gl_warp.c // 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) void GL_SelectTexture (GLenum target)
{ {
if (!gl_mtexable) if (!gl_mtexable)
return; return;
#ifdef _WIN32 // FIXME - only multi-texture under Win32 qglSelectTexture (target + gl_mtex_enum);
qglSelectTextureSGIS(target);
#endif
if (target == oldtarget) if (target == oldtarget)
return; return;
cnttextures[oldtarget-TEXTURE0_SGIS] = currenttexture; cnttextures[oldtarget] = currenttexture;
currenttexture = cnttextures[target-TEXTURE0_SGIS]; currenttexture = cnttextures[target];
oldtarget = target; oldtarget = target;
} }

View file

@ -339,8 +339,8 @@ extern float speedscale; // for top sky and bottom sky
void DrawGLWaterPoly (glpoly_t *p); void DrawGLWaterPoly (glpoly_t *p);
void DrawGLWaterPolyLightmap (glpoly_t *p); void DrawGLWaterPolyLightmap (glpoly_t *p);
lpMTexFUNC qglMTexCoord2fSGIS = NULL; lpMTexFUNC qglMTexCoord2f = NULL;
lpSelTexFUNC qglSelectTextureSGIS = NULL; lpSelTexFUNC qglSelectTexture = NULL;
qboolean mtexenabled = false; qboolean mtexenabled = false;
@ -350,7 +350,7 @@ void GL_DisableMultitexture(void)
{ {
if (mtexenabled) { if (mtexenabled) {
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
GL_SelectTexture(TEXTURE0_SGIS); GL_SelectTexture(0);
mtexenabled = false; mtexenabled = false;
} }
} }
@ -358,7 +358,7 @@ void GL_DisableMultitexture(void)
void GL_EnableMultitexture(void) void GL_EnableMultitexture(void)
{ {
if (gl_mtexable) { if (gl_mtexable) {
GL_SelectTexture(TEXTURE1_SGIS); GL_SelectTexture(1);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
mtexenabled = true; mtexenabled = true;
} }
@ -394,7 +394,7 @@ void R_DrawSequentialPoly (msurface_t *s)
t = R_TextureAnimation (s->texinfo->texture); t = R_TextureAnimation (s->texinfo->texture);
// Binds world to texture env 0 // Binds world to texture env 0
GL_SelectTexture(TEXTURE0_SGIS); GL_SelectTexture(0);
GL_Bind (t->gl_texturenum); GL_Bind (t->gl_texturenum);
// glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); // glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
// Binds lightmap to texenv 1 // Binds lightmap to texenv 1
@ -418,8 +418,8 @@ void R_DrawSequentialPoly (msurface_t *s)
v = p->verts[0]; v = p->verts[0];
for (i=0 ; i<p->numverts ; i++, v+= VERTEXSIZE) for (i=0 ; i<p->numverts ; i++, v+= VERTEXSIZE)
{ {
qglMTexCoord2fSGIS (TEXTURE0_SGIS, v[3], v[4]); qglMTexCoord2f (gl_mtex_enum + 0, v[3], v[4]);
qglMTexCoord2fSGIS (TEXTURE1_SGIS, v[5], v[6]); qglMTexCoord2f (gl_mtex_enum + 1, v[5], v[6]);
glVertex3fv (v); glVertex3fv (v);
} }
glEnd (); glEnd ();
@ -492,7 +492,7 @@ void R_DrawSequentialPoly (msurface_t *s)
p = s->polys; p = s->polys;
t = R_TextureAnimation (s->texinfo->texture); t = R_TextureAnimation (s->texinfo->texture);
GL_SelectTexture(TEXTURE0_SGIS); GL_SelectTexture(0);
GL_Bind (t->gl_texturenum); GL_Bind (t->gl_texturenum);
GL_EnableMultitexture(); GL_EnableMultitexture();
GL_Bind (lightmap_textures + s->lightmaptexturenum); GL_Bind (lightmap_textures + s->lightmaptexturenum);
@ -514,8 +514,8 @@ void R_DrawSequentialPoly (msurface_t *s)
v = p->verts[0]; v = p->verts[0];
for (i=0 ; i<p->numverts ; i++, v+= VERTEXSIZE) for (i=0 ; i<p->numverts ; i++, v+= VERTEXSIZE)
{ {
qglMTexCoord2fSGIS (TEXTURE0_SGIS, v[3], v[4]); qglMTexCoord2f (gl_mtex_enum + 0, v[3], v[4]);
qglMTexCoord2fSGIS (TEXTURE1_SGIS, v[5], v[6]); 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[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); 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) { 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);
if (!gl_texsort->value) { if (!gl_texsort->value) {
if (!waterchain) if (!waterchain)
@ -1528,7 +1529,7 @@ void GL_BuildLightmaps (void)
} }
if (!gl_texsort->value) if (!gl_texsort->value)
GL_SelectTexture(TEXTURE1_SGIS); GL_SelectTexture(1);
// //
// upload all lightmaps that were filled // upload all lightmaps that were filled
@ -1552,7 +1553,7 @@ void GL_BuildLightmaps (void)
} }
if (!gl_texsort->value) 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; int k;
unsigned short i; unsigned short i;
unsigned *table; unsigned *table;
//#ifdef QUAKEWORLD
FILE *f; FILE *f;
char s[255]; char s[255];
//#endif //#endif
@ -187,7 +186,6 @@ void VID_SetPalette (unsigned char *palette)
d_8to24table[255] = 0; // 255 is transparent d_8to24table[255] = 0; // 255 is transparent
// JACK: 3D distance calcs - k is last closest, l is the distance. // JACK: 3D distance calcs - k is last closest, l is the distance.
//#ifdef QUAKEWORLD
{ {
static qboolean palflag = false; static qboolean palflag = false;
@ -202,7 +200,6 @@ void VID_SetPalette (unsigned char *palette)
fread(d_15to8table, 1<<15, 1, f); fread(d_15to8table, 1<<15, 1, f);
fclose(f); fclose(f);
} else } else
//#endif // QUAKEWORLD
{ {
for (i=0; i < (1<<15); i++) { for (i=0; i < (1<<15); i++) {
/* Maps /* Maps
@ -227,7 +224,6 @@ void VID_SetPalette (unsigned char *palette)
} }
d_15to8table[i]=k; d_15to8table[i]=k;
} }
//#ifdef QUAKEWORLD
snprintf(s, sizeof(s), "%s/glquake", com_gamedir); snprintf(s, sizeof(s), "%s/glquake", com_gamedir);
Sys_mkdir (s); Sys_mkdir (s);
snprintf(s, sizeof(s), "%s/glquake/15to8.pal", com_gamedir); 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); fwrite(d_15to8table, 1<<15, 1, f);
fclose(f); fclose(f);
} }
//#endif // QUAKEWORLD
} }
} }
/*
CheckMultiTextureExtensions
Check for ARB, SGIS, or EXT multitexture support
*/
void void
CheckMultiTextureExtensions ( void ) CheckMultiTextureExtensions ( void )
{ {
Con_Printf ("Checking for multitexture... ");
if (COM_CheckParm ("-nomtex")) if (COM_CheckParm ("-nomtex"))
{ {
Con_Printf ("Not using multitexture."); Con_Printf ("disabled\n");
return; return;
} }
#ifdef HAVE_DLOPEN #ifdef HAVE_DLOPEN
dlhand = dlopen (NULL, RTLD_LAZY); dlhand = dlopen (NULL, RTLD_LAZY);
if (dlhand != NULL) if (dlhand == NULL)
{ {
Con_Printf("Multitexture enabled "); Con_Printf ("unable to check\n");
if (strstr(gl_extensions, "GL_SGIS_multitexture ")) return;
{
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 {
} }
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 #else
gl_mtexable = false; gl_mtexable = false;
#endif #endif
} }
/* /*
=============== ===============
GL_Init GL_Init

View file

@ -293,42 +293,57 @@ void VID_SetPalette (unsigned char *palette)
} }
} }
/*
CheckMultiTextureExtensions
Check for ARB, SGIS, or EXT multitexture support
*/
void void
CheckMultiTextureExtensions ( void ) CheckMultiTextureExtensions ( void )
{ {
Con_Printf ("Checking for multitexture... ");
if (COM_CheckParm ("-nomtex")) if (COM_CheckParm ("-nomtex"))
{ {
Con_Printf ("Not using multitexture."); Con_Printf ("disabled\n");
return; return;
} }
#ifdef HAVE_DLOPEN #ifdef HAVE_DLOPEN
dlhand = dlopen (NULL, RTLD_LAZY); dlhand = dlopen (NULL, RTLD_LAZY);
if (dlhand != NULL) if (dlhand == NULL)
{ {
Con_Printf("Multitexture enabled "); Con_Printf ("unable to check\n");
if (strstr(gl_extensions, "GL_SGIS_multitexture ")) return;
{
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 {
} }
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 #else
gl_mtexable = false; gl_mtexable = false;
#endif #endif

View file

@ -602,11 +602,44 @@ int texture_extension_number = 1;
#ifdef _WIN32 #ifdef _WIN32
void CheckMultiTextureExtensions(void) void CheckMultiTextureExtensions(void)
{ {
if (strstr(gl_extensions, "GL_SGIS_multitexture ") && !COM_CheckParm("-nomtex")) { Con_Printf("Checking for multitexture... ");
Con_Printf("Multitexture extensions found.\n"); if (COM_CheckParm ("-nomtex"))
qglMTexCoord2fSGIS = (void *) wglGetProcAddress("glMTexCoord2fSGIS"); {
qglSelectTextureSGIS = (void *) wglGetProcAddress("glSelectTextureSGIS"); 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_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 #else