===============
*/
extern char *ENGINE_EXTENSIONS;
-extern void VID_CheckCombine(void);
void GL_Init (void)
{
gl_vendor = glGetString (GL_VENDOR);
// Con_Printf ("%s %s\n", gl_renderer, gl_version);
- VID_CheckMultitexture();
- VID_CheckCVA();
- VID_CheckCombine();
+// VID_CheckMultitexture();
+// VID_CheckCVA();
+// VID_CheckCombine();
+ VID_CheckExtensions();
// LordHavoc: report supported extensions
Con_Printf ("\nengine extensions: %s\n", ENGINE_EXTENSIONS);
if (nosubimage || nosubimagefragments)
{
+ // LordHavoc: switch to second TMU as an upload hint for voodoo2
+ // (don't know if it really pays attention or not, but original
+ // glquake did this...)
if(r_upload.value)
if (gl_mtexable)
- qglSelectTexture(gl_mtex_enum+1);
+ qglActiveTexture(GL_TEXTURE1_ARB);
for (i = 0;i < MAX_LIGHTMAPS;i++)
{
if (!allocated[i][0])
}
if(r_upload.value)
if (gl_mtexable)
- qglSelectTexture(gl_mtex_enum+0);
+ qglActiveTexture(GL_TEXTURE0_ARB);
}
}
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
extern qboolean isG200;
extern qboolean isRagePro;
-extern qboolean gl_mtexable;
-extern qboolean gl_supportslockarrays;
extern void GL_BeginRendering (int *x, int *y, int *width, int *height);
extern void GL_EndRendering (void);
extern const char *gl_version;
extern const char *gl_extensions;
-// Multitexture
-#define TEXTURE0_SGIS 0x835E
-#define TEXTURE1_SGIS 0x835F
-
#ifndef _WIN32
#define APIENTRY /* */
#endif
-// LordHavoc: ARB multitexure support
-extern int gl_mtex_enum;
-
// for platforms (wgl) that do not use GLAPIENTRY
#ifndef GLAPIENTRY
#define GLAPIENTRY APIENTRY
#endif
-// multitexture
-extern void (GLAPIENTRY *qglMTexCoord2f) (GLenum, GLfloat, GLfloat);
-extern void (GLAPIENTRY *qglSelectTexture) (GLenum);
-extern void (GLAPIENTRY *qglLockArraysEXT) (GLint first, GLint count);
-extern void (GLAPIENTRY *qglUnlockArraysEXT) (void);
-
-
-#ifndef GL_ACTIVE_TEXTURE_ARB
// GL_ARB_multitexture
+extern int gl_mtexable;
+extern void (GLAPIENTRY *qglMultiTexCoord2f) (GLenum, GLfloat, GLfloat);
+extern void (GLAPIENTRY *qglActiveTexture) (GLenum);
+extern void (GLAPIENTRY *qglClientActiveTexture) (GLenum);
+#ifndef GL_ACTIVE_TEXTURE_ARB
#define GL_ACTIVE_TEXTURE_ARB 0x84E0
#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1
#define GL_MAX_TEXTURES_UNITS_ARB 0x84E2
#define GL_TEXTURE31_ARB 0x84DF
#endif
-#ifndef GL_COMBINE_ARB
+// GL_EXT_compiled_vertex_array
+extern int gl_supportslockarrays;
+extern void (GLAPIENTRY *qglLockArraysEXT) (GLint first, GLint count);
+extern void (GLAPIENTRY *qglUnlockArraysEXT) (void);
+
// GL_ARB_texture_env_combine
+extern int gl_combine_extension;
+#ifndef GL_COMBINE_ARB
#define GL_COMBINE_ARB 0x8570
#define GL_COMBINE_RGB_ARB 0x8571
#define GL_COMBINE_ALPHA_ARB 0x8572
#define GL_PREVIOUS_ARB 0x8578
#endif
-extern qboolean gl_combine_extension;
extern cvar_t gl_combine;
#ifdef WIN32
void GL_Init (void);
-void VID_CheckMultitexture(void);
-void VID_CheckCVA(void);
+void VID_CheckExtensions(void);
void VID_Init (void);
// Called at startup
signal(SIGTERM, signal_handler);
}
-/*
- VID_CheckMultitexture
-
- Check for ARB, SGIS, or EXT multitexture support
-*/
-void VID_CheckMultitexture(void)
-{
- Con_Printf ("Checking for multitexture... ");
- if (COM_CheckParm ("-nomtex"))
- {
- Con_Printf ("disabled\n");
- return;
- }
- dlhand = dlopen (NULL, RTLD_LAZY);
- if (dlhand == NULL)
- {
- 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;
- }
- 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;
- }
- else
- Con_Printf ("none found\n");
- dlclose(dlhand);
- dlhand = NULL;
-}
-
-void VID_CheckCVA(void)
-{
- qglLockArraysEXT = NULL;
- qglUnlockArraysEXT = NULL;
- gl_supportslockarrays = false;
- if (COM_CheckParm("-nocva"))
- {
- Con_Printf("...compiled vertex arrays disabled\n");
- return;
- }
- dlhand = dlopen (NULL, RTLD_LAZY);
- if (dlhand == NULL)
- {
- Con_Printf("Unable to open symbol list for main program.\n");
- return;
- }
- if (strstr(gl_extensions, "GL_EXT_compiled_vertex_array"))
- {
- Con_Printf("...using compiled vertex arrays\n");
- qglLockArraysEXT = (void *) dlsym(dlhand, "glLockArraysEXT");
- qglUnlockArraysEXT = (void *) dlsym(dlhand, "glUnlockArraysEXT");
- gl_supportslockarrays = true;
- }
- dlclose(dlhand);
- dlhand = NULL;
-}
-
-
typedef void (GLAPIENTRY *gl3DfxSetDitherModeEXT_FUNC) (GrDitherMode_t mode);
void VID_SetupDithering(void)
signal(SIGTERM, signal_handler);
}
-void VID_CheckMultitexture(void)
-{
- void *prjobj;
- qglMTexCoord2f = NULL;
- qglSelectTexture = NULL;
- // Check to see if multitexture is disabled
- if (COM_CheckParm("-nomtex"))
- {
- Con_Printf("...multitexture disabled\n");
- return;
- }
- if ((prjobj = dlopen(NULL, RTLD_LAZY)) == NULL)
- {
- Con_Printf("Unable to open symbol list for main program.\n");
- return;
- }
- // Test for ARB_multitexture
- if (!COM_CheckParm("-SGISmtex") && strstr(gl_extensions, "GL_ARB_multitexture "))
- {
- Con_Printf("...using GL_ARB_multitexture\n");
- qglMTexCoord2f = (void *) dlsym(prjobj, "glMultiTexCoord2fARB");
- qglSelectTexture = (void *) dlsym(prjobj, "glActiveTextureARB");
- if (qglMTexCoord2f != NULL && qglSelectTexture != NULL)
- {
- gl_mtexable = true;
- gl_mtex_enum = GL_TEXTURE0_ARB;
- }
- else
- {
- if (qglMTexCoord2f == NULL)
- Con_Printf("dlsym(prjobj, \"glMultiTexCoord2fARB\") == NULL!\n");
- if (qglSelectTexture == NULL)
- Con_Printf("dlsym(prjobj, \"glActiveTextureARB\") == NULL!\n");
- }
- }
- if (!gl_mtexable && strstr(gl_extensions, "GL_SGIS_multitexture ")) // Test for SGIS_multitexture (if ARB_multitexture not found)
- {
- Con_Printf("...using GL_SGIS_multitexture\n");
- qglMTexCoord2f = (void *) dlsym(prjobj, "glMTexCoord2fSGIS");
- qglSelectTexture = (void *) dlsym(prjobj, "glSelectTextureSGIS");
- if (qglMTexCoord2f != NULL && qglSelectTexture != NULL)
- {
- gl_mtexable = true;
- gl_mtex_enum = TEXTURE0_SGIS;
- }
- else
- {
- if (qglMTexCoord2f == NULL)
- Con_Printf("dlsym(prjobj, \"glMTexCoord2fSGIS\") == NULL!\n");
- if (qglSelectTexture == NULL)
- Con_Printf("dlsym(prjobj, \"glSelectTextureSGIS\") == NULL!\n");
- }
- }
- if (!gl_mtexable)
- Con_Printf("...multitexture disabled (not detected)\n");
- dlclose(prjobj);
-}
-
-void VID_CheckCVA(void)
-{
- void *prjobj;
- qglLockArraysEXT = NULL;
- qglUnlockArraysEXT = NULL;
- gl_supportslockarrays = false;
- if (COM_CheckParm("-nocva"))
- {
- Con_Printf("...compiled vertex arrays disabled\n");
- return;
- }
- if ((prjobj = dlopen(NULL, RTLD_LAZY)) == NULL)
- {
- Con_Printf("Unable to open symbol list for main program.\n");
- return;
- }
- if (strstr(gl_extensions, "GL_EXT_compiled_vertex_array"))
- {
- Con_Printf("...using compiled vertex arrays\n");
- qglLockArraysEXT = (void *) dlsym(prjobj, "glLockArraysEXT");
- qglUnlockArraysEXT = (void *) dlsym(prjobj, "glUnlockArraysEXT");
- if (qglLockArraysEXT != NULL && qglUnlockArraysEXT != NULL)
- gl_supportslockarrays = true;
- else
- {
- if (qglLockArraysEXT == NULL)
- Con_Printf("dlsym(prjobj, \"glLockArraysEXT\") == NULL!\n");
- if (qglUnlockArraysEXT == NULL)
- Con_Printf("dlsym(prjobj, \"glUnlockArraysEXT\") == NULL!\n");
- Con_Printf("...compiled vertex arrays disabled\n");
- }
- }
- dlclose(prjobj);
-}
-
/*
=================
GL_BeginRendering
qboolean isG200 = false; // LordHavoc: the Matrox G200 can't do per pixel alpha, and it uses a D3D driver for GL... ugh...
qboolean isRagePro = false; // LordHavoc: the ATI Rage Pro has limitations with per pixel alpha (the color scaler does not apply to per pixel alpha images...), although not as bad as a G200.
-// LordHavoc: compiled vertex array support
-qboolean gl_supportslockarrays = false;
-// LordHavoc: ARB multitexture support
-qboolean gl_mtexable = false;
-int gl_mtex_enum = 0;
-// LordHavoc: ARB texture_env_combine support
-qboolean gl_combine_extension = false;
+// LordHavoc: GL_ARB_multitexture support
+int gl_mtexable = false;
+// LordHavoc: GL_ARB_texture_env_combine support
+int gl_combine_extension = false;
+// LordHavoc: GL_EXT_compiled_vertex_array support
+int gl_supportslockarrays = false;
cvar_t vid_mode = {0, "vid_mode", "0"};
cvar_t vid_mouse = {CVAR_SAVE, "vid_mouse", "1"};
cvar_t vid_fullscreen = {0, "vid_fullscreen", "1"};
cvar_t gl_combine = {0, "gl_combine", "0"};
-void (GLAPIENTRY *qglMTexCoord2f) (GLenum, GLfloat, GLfloat);
-void (GLAPIENTRY *qglSelectTexture) (GLenum);
+// GL_ARB_multitexture
+void (GLAPIENTRY *qglMultiTexCoord2f) (GLenum, GLfloat, GLfloat);
+void (GLAPIENTRY *qglActiveTexture) (GLenum);
+void (GLAPIENTRY *qglClientActiveTexture) (GLenum);
+
+// GL_EXT_compiled_vertex_array
void (GLAPIENTRY *qglLockArraysEXT) (GLint first, GLint count);
void (GLAPIENTRY *qglUnlockArraysEXT) (void);
-void Force_CenterView_f (void)
+typedef struct
{
- cl.viewangles[PITCH] = 0;
+ char *name;
+ void **funcvariable;
}
+gl_extensionfunctionlist_t;
+
+typedef struct
+{
+ char *name;
+ gl_extensionfunctionlist_t *funcs;
+ int *enablevariable;
+ char *disableparm;
+}
+gl_extensioninfo_t;
+
+static gl_extensionfunctionlist_t multitexturefuncs[] =
+{
+ {"glMultiTexCoord2fARB", (void **) &qglMultiTexCoord2f},
+ {"glActiveTextureARB", (void **) &qglActiveTexture},
+ {"glClientActiveTextureARB", (void **) &qglClientActiveTexture},
+ {NULL, NULL}
+};
+
+static gl_extensionfunctionlist_t compiledvertexarrayfuncs[] =
+{
+ {"glLockArraysEXT", (void **) &qglLockArraysEXT},
+ {"glUnlockArraysEXT", (void **) &qglUnlockArraysEXT},
+ {NULL, NULL}
+};
+
+static gl_extensioninfo_t gl_extensioninfo[] =
+{
+ {"GL_ARB_multitexture", multitexturefuncs, &gl_mtexable, "-nomtex"},
+ {"GL_ARB_texture_env_combine", NULL, &gl_combine_extension, "-nocombine"},
+ {"GL_EXT_compiled_vertex_array", compiledvertexarrayfuncs, &gl_supportslockarrays, "-nocva"},
+ {NULL, NULL, NULL, NULL}
+};
+
+#ifndef WIN32
+#include <dlfcn.h>
+#endif
+void VID_CheckExtensions(void)
+{
+#ifndef WIN32
+ void *prjobj;
+#endif
+ gl_extensioninfo_t *info;
+ gl_extensionfunctionlist_t *func;
+// multitexturefuncs[0].funcvariable = (void **)&qglMultiTexCoord2f;
+ Con_Printf("Checking OpenGL extensions...\n");
+#ifndef WIN32
+ if ((prjobj = dlopen(NULL, RTLD_LAZY)) == NULL)
+ {
+ Con_Printf("Unable to open symbol list for main program.\n");
+ return;
+ }
+#endif
+ for (info = gl_extensioninfo;info && info->name;info++)
+ {
+ *info->enablevariable = false;
+ for (func = info->funcs;func && func->name;func++)
+ *func->funcvariable = NULL;
+ Con_Printf("checking for %s... ", info->name);
+ if (info->disableparm && COM_CheckParm(info->disableparm))
+ {
+ Con_Printf("disabled by commandline\n");
+ continue;
+ }
+ if (strstr(gl_extensions, info->name))
+ {
+ for (func = info->funcs;func && func->name != NULL;func++)
+ {
+#ifdef WIN32
+ if (!(*func->funcvariable = (void *) wglGetProcAddress(func->name)))
+#else
+ if (!(*func->funcvariable = (void *) dlsym(prjobj, func->name)))
+#endif
+ {
+ Con_Printf("missing function \"%s\"!\n", func->name);
+ goto missingfunc;
+ }
+ }
+ Con_Printf("enabled\n");
+ *info->enablevariable = true;
+ missingfunc:;
+ }
+ else
+ Con_Printf("not detected\n");
+ }
+#ifndef WIN32
+ dlclose(prjobj);
+#endif
+}
+
+/*
void VID_CheckCombine(void)
{
// LordHavoc: although texture_env_combine doesn't require multiple TMUs
Con_Printf("GL_ARB_texture_env_combine not detected\n");
}
}
+*/
+
+void Force_CenterView_f (void)
+{
+ cl.viewangles[PITCH] = 0;
+}
void VID_InitCvars(void)
{
//====================================
-void VID_CheckMultitexture(void)
-{
- qglMTexCoord2f = NULL;
- qglSelectTexture = NULL;
- gl_mtexable = false;
- // Check to see if multitexture is disabled
- if (COM_CheckParm("-nomtex"))
- {
- Con_Printf("...multitexture disabled\n");
- return;
- }
- // Test for ARB_multitexture
- if (!COM_CheckParm("-SGISmtex") && strstr(gl_extensions, "GL_ARB_multitexture "))
- {
- Con_Printf("...using GL_ARB_multitexture\n");
- qglMTexCoord2f = (void *) wglGetProcAddress("glMultiTexCoord2fARB");
- qglSelectTexture = (void *) wglGetProcAddress("glActiveTextureARB");
- gl_mtexable = true;
- gl_mtex_enum = GL_TEXTURE0_ARB;
- }
- else if (strstr(gl_extensions, "GL_SGIS_multitexture ")) // Test for SGIS_multitexture (if ARB_multitexture not found)
- {
- Con_Printf("...using GL_SGIS_multitexture\n");
- qglMTexCoord2f = (void *) wglGetProcAddress("glMTexCoord2fSGIS");
- qglSelectTexture = (void *) wglGetProcAddress("glSelectTextureSGIS");
- gl_mtexable = true;
- gl_mtex_enum = TEXTURE0_SGIS;
- }
- else
- Con_Printf("...multitexture disabled (not detected)\n");
-}
-
-void VID_CheckCVA(void)
-{
- qglLockArraysEXT = NULL;
- qglUnlockArraysEXT = NULL;
- gl_supportslockarrays = false;
- if (COM_CheckParm("-nocva"))
- {
- Con_Printf("...compiled vertex arrays disabled\n");
- return;
- }
- if (strstr(gl_extensions, "GL_EXT_compiled_vertex_array"))
- {
- Con_Printf("...using compiled vertex arrays\n");
- qglLockArraysEXT = (void *) wglGetProcAddress("glLockArraysEXT");
- qglUnlockArraysEXT = (void *) wglGetProcAddress("glUnlockArraysEXT");
- gl_supportslockarrays = true;
- }
-}
-
/*
=================
GL_BeginRendering