mirror of
https://git.code.sf.net/p/quake/newtree
synced 2025-05-30 08:40:39 +00:00
Cleanup of extensions, they are no longer defined in glquake.h. In
addition, removed support (for now) for SGIS and EXT multitexture. It allowed me to enhance support for ARB multitexture, which is better anyway (especially for Radeon, but that won't get special support yet until we need a third texture pass). Updated the Unix 8-bit GL code to be more like the Windows version, which may work better. It still defaults off, because many drivers have bugs in their handling of the shared texture palette extension.
This commit is contained in:
parent
cc8d6c5827
commit
fc005fc215
7 changed files with 294 additions and 228 deletions
|
@ -381,8 +381,8 @@ extern int solidskytexture;
|
|||
extern int alphaskytexture;
|
||||
extern float speedscale; // for top sky and bottom sky
|
||||
|
||||
lpMTexFUNC qglMTexCoord2f = NULL;
|
||||
lpSelTexFUNC qglSelectTexture = NULL;
|
||||
QF_glActiveTextureARB qglActiveTexture = NULL;
|
||||
QF_glMultiTexCoord2fARB qglMultiTexCoord2f = NULL;
|
||||
|
||||
void
|
||||
GL_UploadLightmap (int i, int x, int y, int w, int h)
|
||||
|
@ -414,12 +414,12 @@ R_DrawMultitexturePoly (msurface_t *s)
|
|||
|
||||
glColor3f (1, 1, 1);
|
||||
// Binds world to texture env 0
|
||||
qglSelectTexture (gl_mtex_enum + 0);
|
||||
qglActiveTexture (gl_mtex_enum + 0);
|
||||
glBindTexture (GL_TEXTURE_2D, texture->gl_texturenum);
|
||||
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||
glEnable (GL_TEXTURE_2D);
|
||||
// Binds lightmap to texenv 1
|
||||
qglSelectTexture (gl_mtex_enum + 1);
|
||||
qglActiveTexture (gl_mtex_enum + 1);
|
||||
glBindTexture (GL_TEXTURE_2D, lightmap_textures + i);
|
||||
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glEnable (GL_TEXTURE_2D);
|
||||
|
@ -448,13 +448,13 @@ R_DrawMultitexturePoly (msurface_t *s)
|
|||
glBegin (GL_POLYGON);
|
||||
v = s->polys->verts[0];
|
||||
for (i = 0; i < s->polys->numverts; i++, v += VERTEXSIZE) {
|
||||
qglMTexCoord2f (gl_mtex_enum + 0, v[3], v[4]);
|
||||
qglMTexCoord2f (gl_mtex_enum + 1, v[5], v[6]);
|
||||
qglMultiTexCoord2f (gl_mtex_enum + 0, v[3], v[4]);
|
||||
qglMultiTexCoord2f (gl_mtex_enum + 1, v[5], v[6]);
|
||||
glVertex3fv (v);
|
||||
}
|
||||
glEnd ();
|
||||
glDisable (GL_TEXTURE_2D);
|
||||
qglSelectTexture (gl_mtex_enum + 0);
|
||||
qglActiveTexture (gl_mtex_enum + 0);
|
||||
glEnable (GL_TEXTURE_2D);
|
||||
|
||||
if (texture->gl_fb_texturenum > 0) {
|
||||
|
@ -785,7 +785,7 @@ R_DrawBrushModel (entity_t *e)
|
|||
e->angles[0] = -e->angles[0]; // stupid quake bug
|
||||
|
||||
// LordHavoc: anyone without multitexture won't want texsort 0 anyway...
|
||||
if (!gl_mtexable)
|
||||
if (!gl_mtex_capable)
|
||||
Cvar_SetValue (gl_texsort, 1);
|
||||
|
||||
//
|
||||
|
@ -966,7 +966,7 @@ R_DrawWorld (void)
|
|||
currententity = &ent;
|
||||
|
||||
// LordHavoc: anyone without multitexture won't want texsort 0 anyway...
|
||||
if (!gl_mtexable)
|
||||
if (!gl_mtex_capable)
|
||||
Cvar_SetValue (gl_texsort, 1);
|
||||
|
||||
memset (lightmap_polys, 0, sizeof (lightmap_polys));
|
||||
|
@ -1266,8 +1266,8 @@ GL_BuildLightmaps (void)
|
|||
}
|
||||
}
|
||||
|
||||
if (gl_mtexable && !gl_texsort->int_val)
|
||||
qglSelectTexture (gl_mtex_enum + 1);
|
||||
if (gl_mtex_capable && !gl_texsort->int_val)
|
||||
qglActiveTexture (gl_mtex_enum + 1);
|
||||
|
||||
//
|
||||
// upload all lightmaps that were filled
|
||||
|
@ -1288,6 +1288,6 @@ GL_BuildLightmaps (void)
|
|||
GL_UNSIGNED_BYTE, lightmaps[i]);
|
||||
}
|
||||
|
||||
if (gl_mtexable && !gl_texsort->int_val)
|
||||
qglSelectTexture (gl_mtex_enum + 0);
|
||||
if (gl_mtex_capable && !gl_texsort->int_val)
|
||||
qglActiveTexture (gl_mtex_enum + 0);
|
||||
}
|
||||
|
|
|
@ -651,7 +651,7 @@ SCR_ScreenShot_f (void)
|
|||
return;
|
||||
}
|
||||
buffer = malloc (glwidth * glheight * 3);
|
||||
glReadPixels (glx, gly, glwidth, glheight, GL_BGR, GL_UNSIGNED_BYTE,
|
||||
glReadPixels (glx, gly, glwidth, glheight, GL_BGR_EXT, GL_UNSIGNED_BYTE,
|
||||
buffer);
|
||||
WriteTGAfile (pcxname, buffer, glwidth, glheight);
|
||||
free (buffer);
|
||||
|
|
|
@ -72,53 +72,45 @@ const char *gl_version;
|
|||
const char *gl_extensions;
|
||||
|
||||
// ARB Multitexture
|
||||
int gl_mtex_enum = TEXTURE0_SGIS;
|
||||
qboolean gl_arb_mtex = false;
|
||||
qboolean gl_mtexable = false;
|
||||
qboolean gl_mtex_capable = false;
|
||||
GLenum gl_mtex_enum = GL_TEXTURE0_ARB;
|
||||
|
||||
static qboolean is8bit = false;
|
||||
cvar_t *vid_use8bit;
|
||||
QF_glColorTableEXT qglColorTableEXT = NULL;
|
||||
qboolean is8bit = false;
|
||||
cvar_t *vid_use8bit;
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
CheckMultiTextureExtensions
|
||||
|
||||
Check for ARB, SGIS, or EXT multitexture support
|
||||
Check for ARB multitexture support
|
||||
*/
|
||||
|
||||
void
|
||||
CheckMultiTextureExtensions (void)
|
||||
{
|
||||
Con_Printf ("Checking for multitexture: ");
|
||||
if (COM_CheckParm ("-nomtex")) {
|
||||
Con_Printf ("disabled\n");
|
||||
Con_Printf ("disabled.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (QFGL_ExtensionPresent ("GL_ARB_multitexture")) {
|
||||
Con_Printf ("GL_ARB_multitexture\n");
|
||||
qglMTexCoord2f = QFGL_ExtensionAddress ("glMultiTexCoord2fARB");
|
||||
qglSelectTexture = QFGL_ExtensionAddress ("glActiveTextureARB");
|
||||
gl_mtex_enum = GL_TEXTURE0_ARB;
|
||||
gl_mtexable = true;
|
||||
gl_arb_mtex = true;
|
||||
} else if (QFGL_ExtensionPresent ("GL_SGIS_multitexture")) {
|
||||
Con_Printf ("GL_SGIS_multitexture\n");
|
||||
qglMTexCoord2f = QFGL_ExtensionAddress ("glMTexCoord2fSGIS");
|
||||
qglSelectTexture = QFGL_ExtensionAddress ("glSelectTextureSGIS");
|
||||
gl_mtex_enum = TEXTURE0_SGIS;
|
||||
gl_mtexable = true;
|
||||
gl_arb_mtex = false;
|
||||
} else if (QFGL_ExtensionPresent ("GL_EXT_multitexture")) {
|
||||
Con_Printf ("GL_EXT_multitexture\n");
|
||||
qglMTexCoord2f = QFGL_ExtensionAddress ("glMTexCoord2fEXT");
|
||||
qglSelectTexture = QFGL_ExtensionAddress ("glSelectTextureEXT");
|
||||
gl_mtex_enum = TEXTURE0_SGIS;
|
||||
gl_mtexable = true;
|
||||
gl_arb_mtex = false;
|
||||
|
||||
int max_texture_units = 0;
|
||||
|
||||
glGetIntegerv (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");
|
||||
qglActiveTexture = QFGL_ExtensionAddress ("glActiveTextureARB");
|
||||
gl_mtex_enum = GL_TEXTURE0_ARB;
|
||||
gl_mtex_capable = true;
|
||||
} else {
|
||||
Con_Printf ("disabled, not enough TMUs.\n");
|
||||
}
|
||||
} else {
|
||||
Con_Printf ("none\n");
|
||||
Con_Printf ("not found.\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -312,15 +304,12 @@ Tdfx_Init8bitPalette (void)
|
|||
* the GL_EXT_shared_texture_palette spec might be a very good idea in
|
||||
* general.
|
||||
*/
|
||||
#if 0
|
||||
void
|
||||
Shared_Init8bitPalette (void)
|
||||
{
|
||||
int i;
|
||||
GLubyte thePalette[256][3];
|
||||
GLubyte *oldPalette;
|
||||
|
||||
QF_glColorTableEXT qglColorTableEXT = NULL;
|
||||
int i;
|
||||
GLubyte thePalette[256 * 3];
|
||||
GLubyte *oldPalette, *newPalette;
|
||||
|
||||
if (is8bit) {
|
||||
return;
|
||||
|
@ -333,20 +322,21 @@ Shared_Init8bitPalette (void)
|
|||
|
||||
Con_Printf ("GL_EXT_shared_texture_palette\n");
|
||||
|
||||
oldPalette = (GLubyte *) d_8to24table; // d_8to24table3dfx;
|
||||
for (i = 0; i < 256; i++) {
|
||||
thePalette[i][0] = *oldPalette++;
|
||||
thePalette[i][1] = *oldPalette++;
|
||||
thePalette[i][2] = *oldPalette++;
|
||||
}
|
||||
glEnable (GL_SHARED_TEXTURE_PALETTE_EXT);
|
||||
oldPalette = (GLubyte *) d_8to24table; // d_8to24table3dfx;
|
||||
newPalette = thePalette;
|
||||
for (i = 0; i < 256; i++) {
|
||||
*newPalette++ = *oldPalette++;
|
||||
*newPalette++ = *oldPalette++;
|
||||
*newPalette++ = *oldPalette++;
|
||||
oldPalette++;
|
||||
}
|
||||
qglColorTableEXT (GL_SHARED_TEXTURE_PALETTE_EXT, GL_RGB, 256, GL_RGB,
|
||||
GL_UNSIGNED_BYTE, (GLvoid *) thePalette);
|
||||
GL_UNSIGNED_BYTE, (GLvoid *) thePalette);
|
||||
is8bit = true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void
|
||||
VID_Init8bitPalette (void)
|
||||
|
@ -358,10 +348,10 @@ VID_Init8bitPalette (void)
|
|||
if (vid_use8bit->int_val) {
|
||||
#ifdef GL_SHARED_TEXTURE_PALETTE_EXT
|
||||
Tdfx_Init8bitPalette ();
|
||||
//Shared_Init8bitPalette ();
|
||||
Shared_Init8bitPalette ();
|
||||
#endif
|
||||
if (!is8bit) {
|
||||
Con_Printf ("none\n");
|
||||
Con_Printf ("not found.\n");
|
||||
}
|
||||
} else {
|
||||
Con_Printf ("disabled.\n");
|
||||
|
|
115
source/vid_wgl.c
115
source/vid_wgl.c
|
@ -93,6 +93,15 @@ const char *gl_renderer;
|
|||
const char *gl_version;
|
||||
const char *gl_extensions;
|
||||
|
||||
// ARB Multitexture
|
||||
qboolean gl_mtex_capable = false;
|
||||
GLenum gl_mtex_enum = GL_TEXTURE0_ARB;
|
||||
|
||||
// 8-bit and permedia support
|
||||
QF_glColorTableEXT qglColorTableEXT = NULL;
|
||||
qboolean is8bit = false;
|
||||
qboolean isPermedia = false;
|
||||
|
||||
// fixme: Only used by MGL ..
|
||||
qboolean DDActive;
|
||||
|
||||
|
@ -154,14 +163,6 @@ void ClearAllStates (void);
|
|||
void VID_UpdateWindowStatus (void);
|
||||
void GL_Init (void);
|
||||
|
||||
typedef void (APIENTRY * lp3DFXFUNC) (int, int, int, int, int, const void *);
|
||||
lp3DFXFUNC glColorTableEXT;
|
||||
qboolean is8bit = false;
|
||||
qboolean isPermedia = false;
|
||||
int gl_mtex_enum = TEXTURE0_SGIS;
|
||||
qboolean gl_arb_mtex = false;
|
||||
qboolean gl_mtexable = false;
|
||||
|
||||
//====================================
|
||||
|
||||
cvar_t *_windowed_mouse;
|
||||
|
@ -490,47 +491,33 @@ VID_UpdateWindowStatus (void)
|
|||
|
||||
int texture_extension_number = 1;
|
||||
|
||||
#ifdef _WIN32
|
||||
void
|
||||
CheckMultiTextureExtensions (void)
|
||||
{
|
||||
Con_Printf ("Checking for multitexture... ");
|
||||
if (COM_CheckParm ("-nomtex")) {
|
||||
Con_Printf ("disabled\n");
|
||||
Con_Printf ("disabled.\n");
|
||||
return;
|
||||
}
|
||||
if (strstr (gl_extensions, "GL_ARB_multitexture ")) {
|
||||
Con_Printf ("GL_ARB_multitexture\n");
|
||||
qglMTexCoord2f = (void *) wglGetProcAddress ("glMultiTexCoord2fARB");
|
||||
qglSelectTexture = (void *) wglGetProcAddress ("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 *) 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;
|
||||
|
||||
if (QFGL_ExtensionPresent ("GL_ARB_multitexture")) {
|
||||
|
||||
int max_texture_units = 0;
|
||||
|
||||
glGetIntegerv (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");
|
||||
qglActiveTexture = QFGL_ExtensionAddress ("glActiveTextureARB");
|
||||
gl_mtex_enum = GL_TEXTURE0_ARB;
|
||||
gl_mtex_capable = true;
|
||||
} else {
|
||||
Con_Printf ("disabled, not enough TMUs.\n");
|
||||
}
|
||||
} else {
|
||||
Con_Printf ("none found\n");
|
||||
Con_Printf ("not found.\n");
|
||||
}
|
||||
}
|
||||
#else
|
||||
void
|
||||
CheckMultiTextureExtensions (void)
|
||||
{
|
||||
gl_mtexable = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
===============
|
||||
|
@ -1428,35 +1415,37 @@ VID_Is8bit ()
|
|||
return is8bit;
|
||||
}
|
||||
|
||||
#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB
|
||||
|
||||
void
|
||||
VID_Init8bitPalette ()
|
||||
VID_Init8bitPalette (void)
|
||||
{
|
||||
// Check for 8bit Extensions and initialize them.
|
||||
int i;
|
||||
char thePalette[256 * 3];
|
||||
char *oldPalette, *newPalette;
|
||||
int i;
|
||||
GLubyte thePalette[256 * 3];
|
||||
GLubyte *oldPalette, *newPalette;
|
||||
|
||||
glColorTableEXT = (void *) wglGetProcAddress ("glColorTableEXT");
|
||||
if (!glColorTableEXT
|
||||
|| strstr (gl_extensions, "GL_EXT_shared_texture_palette")
|
||||
|| COM_CheckParm ("-no8bit"))
|
||||
if (COM_CheckParm ("-no8bit") || is8bit) {
|
||||
return;
|
||||
|
||||
Con_Printf ("8-bit GL extensions enabled.\n");
|
||||
glEnable (GL_SHARED_TEXTURE_PALETTE_EXT);
|
||||
oldPalette = (char *) d_8to24table; // d_8to24table3dfx;
|
||||
newPalette = thePalette;
|
||||
for (i = 0; i < 256; i++) {
|
||||
*newPalette++ = *oldPalette++;
|
||||
*newPalette++ = *oldPalette++;
|
||||
*newPalette++ = *oldPalette++;
|
||||
oldPalette++;
|
||||
}
|
||||
glColorTableEXT (GL_SHARED_TEXTURE_PALETTE_EXT, GL_RGB, 256, GL_RGB,
|
||||
GL_UNSIGNED_BYTE, (void *) thePalette);
|
||||
is8bit = TRUE;
|
||||
|
||||
if (QFGL_ExtensionPresent ("GL_EXT_shared_texture_palette")) {
|
||||
if (!(qglColorTableEXT = QFGL_ExtensionAddress ("glColorTableEXT"))) {
|
||||
return;
|
||||
}
|
||||
|
||||
Con_Printf ("8-bit GL extension enabled.\n");
|
||||
|
||||
glEnable (GL_SHARED_TEXTURE_PALETTE_EXT);
|
||||
oldPalette = (GLubyte *) d_8to24table; // d_8to24table3dfx;
|
||||
newPalette = thePalette;
|
||||
for (i = 0; i < 256; i++) {
|
||||
*newPalette++ = *oldPalette++;
|
||||
*newPalette++ = *oldPalette++;
|
||||
*newPalette++ = *oldPalette++;
|
||||
oldPalette++;
|
||||
}
|
||||
qglColorTableEXT (GL_SHARED_TEXTURE_PALETTE_EXT, GL_RGB, 256, GL_RGB,
|
||||
GL_UNSIGNED_BYTE, (GLvoid *) thePalette);
|
||||
is8bit = true;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue