4 // LordHavoc: these are only set in wgl
5 qboolean isG200 = false; // LordHavoc: the Matrox G200 can't do per pixel alpha, and it uses a D3D driver for GL... ugh...
6 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.
8 // LordHavoc: GL_ARB_multitexture support
10 // LordHavoc: GL_ARB_texture_env_combine or GL_EXT_texture_env_combine support
11 int gl_combine_extension = false;
12 // LordHavoc: GL_EXT_compiled_vertex_array support
13 int gl_supportslockarrays = false;
15 cvar_t vid_mode = {0, "vid_mode", "0"};
16 cvar_t vid_mouse = {CVAR_SAVE, "vid_mouse", "1"};
17 cvar_t vid_fullscreen = {0, "vid_fullscreen", "1"};
18 cvar_t gl_combine = {0, "gl_combine", "1"};
20 // GL_ARB_multitexture
21 void (GLAPIENTRY *qglMultiTexCoord2f) (GLenum, GLfloat, GLfloat);
22 void (GLAPIENTRY *qglActiveTexture) (GLenum);
23 void (GLAPIENTRY *qglClientActiveTexture) (GLenum);
25 // GL_EXT_compiled_vertex_array
26 void (GLAPIENTRY *qglLockArraysEXT) (GLint first, GLint count);
27 void (GLAPIENTRY *qglUnlockArraysEXT) (void);
34 gl_extensionfunctionlist_t;
39 gl_extensionfunctionlist_t *funcs;
45 static gl_extensionfunctionlist_t multitexturefuncs[] =
47 {"glMultiTexCoord2fARB", (void **) &qglMultiTexCoord2f},
48 {"glActiveTextureARB", (void **) &qglActiveTexture},
49 {"glClientActiveTextureARB", (void **) &qglClientActiveTexture},
53 static gl_extensionfunctionlist_t compiledvertexarrayfuncs[] =
55 {"glLockArraysEXT", (void **) &qglLockArraysEXT},
56 {"glUnlockArraysEXT", (void **) &qglUnlockArraysEXT},
64 static void *prjobj = NULL;
66 static void gl_getfuncs_begin(void)
72 prjobj = dlopen(NULL, RTLD_LAZY);
75 Con_Printf("Unable to open symbol list for main program.\n");
81 static void gl_getfuncs_end(void)
92 static void *gl_getfuncaddress(char *name)
95 return (void *) wglGetProcAddress(name);
97 return (void *) dlsym(prjobj, name);
101 static int gl_checkextension(char *name, gl_extensionfunctionlist_t *funcs, char *disableparm)
103 gl_extensionfunctionlist_t *func;
105 Con_Printf("checking for %s... ", name);
107 for (func = funcs;func && func->name;func++)
108 *func->funcvariable = NULL;
110 if (disableparm && COM_CheckParm(disableparm))
112 Con_Printf("disabled by commandline\n");
116 if (strstr(gl_extensions, name))
118 for (func = funcs;func && func->name != NULL;func++)
120 if (!(*func->funcvariable = (void *) gl_getfuncaddress(func->name)))
122 Con_Printf("missing function \"%s\"!\n", func->name);
126 Con_Printf("enabled\n");
131 Con_Printf("not detected\n");
136 void VID_CheckExtensions(void)
138 Con_Printf("Checking OpenGL extensions...\n");
142 gl_combine_extension = false;
143 gl_supportslockarrays = false;
146 if (gl_checkextension("GL_ARB_multitexture", multitexturefuncs, "-nomtex"))
148 glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &gl_textureunits);
149 if (gl_textureunits > 1)
150 gl_combine_extension = gl_checkextension("GL_ARB_texture_env_combine", NULL, "-nocombine") || gl_checkextension("GL_EXT_texture_env_combine", NULL, "-nocombine");
152 gl_textureunits = 1; // for sanity sake, make sure it's not 0
155 gl_supportslockarrays = gl_checkextension("GL_EXT_compiled_vertex_array", compiledvertexarrayfuncs, "-nocva");
160 void Force_CenterView_f (void)
162 cl.viewangles[PITCH] = 0;
165 void VID_InitCvars(void)
167 Cvar_RegisterVariable(&vid_mode);
168 Cvar_RegisterVariable(&vid_mouse);
169 Cvar_RegisterVariable(&vid_fullscreen);
170 Cvar_RegisterVariable(&gl_combine);
171 Cmd_AddCommand("force_centerview", Force_CenterView_f);