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 cvar_t in_pitch_min = {0, "in_pitch_min", "-90"};
21 cvar_t in_pitch_max = {0, "in_pitch_max", "90"};
23 // GL_ARB_multitexture
24 void (GLAPIENTRY *qglMultiTexCoord2f) (GLenum, GLfloat, GLfloat);
25 void (GLAPIENTRY *qglActiveTexture) (GLenum);
26 void (GLAPIENTRY *qglClientActiveTexture) (GLenum);
28 // GL_EXT_compiled_vertex_array
29 void (GLAPIENTRY *qglLockArraysEXT) (GLint first, GLint count);
30 void (GLAPIENTRY *qglUnlockArraysEXT) (void);
37 gl_extensionfunctionlist_t;
42 gl_extensionfunctionlist_t *funcs;
48 static gl_extensionfunctionlist_t multitexturefuncs[] =
50 {"glMultiTexCoord2fARB", (void **) &qglMultiTexCoord2f},
51 {"glActiveTextureARB", (void **) &qglActiveTexture},
52 {"glClientActiveTextureARB", (void **) &qglClientActiveTexture},
56 static gl_extensionfunctionlist_t compiledvertexarrayfuncs[] =
58 {"glLockArraysEXT", (void **) &qglLockArraysEXT},
59 {"glUnlockArraysEXT", (void **) &qglUnlockArraysEXT},
67 static void *prjobj = NULL;
69 static void gl_getfuncs_begin(void)
75 prjobj = dlopen(NULL, RTLD_LAZY);
78 Con_Printf("Unable to open symbol list for main program.\n");
84 static void gl_getfuncs_end(void)
95 static void *gl_getfuncaddress(char *name)
98 return (void *) wglGetProcAddress(name);
100 return (void *) dlsym(prjobj, name);
104 static int gl_checkextension(char *name, gl_extensionfunctionlist_t *funcs, char *disableparm)
106 gl_extensionfunctionlist_t *func;
108 Con_Printf("checking for %s... ", name);
110 for (func = funcs;func && func->name;func++)
111 *func->funcvariable = NULL;
113 if (disableparm && COM_CheckParm(disableparm))
115 Con_Printf("disabled by commandline\n");
119 if (strstr(gl_extensions, name))
121 for (func = funcs;func && func->name != NULL;func++)
123 if (!(*func->funcvariable = (void *) gl_getfuncaddress(func->name)))
125 Con_Printf("missing function \"%s\"!\n", func->name);
129 Con_Printf("enabled\n");
134 Con_Printf("not detected\n");
139 void VID_CheckExtensions(void)
141 Con_Printf("Checking OpenGL extensions...\n");
145 gl_combine_extension = false;
146 gl_supportslockarrays = false;
149 if (gl_checkextension("GL_ARB_multitexture", multitexturefuncs, "-nomtex"))
151 glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &gl_textureunits);
152 if (gl_textureunits > 1)
153 gl_combine_extension = gl_checkextension("GL_ARB_texture_env_combine", NULL, "-nocombine") || gl_checkextension("GL_EXT_texture_env_combine", NULL, "-nocombine");
155 gl_textureunits = 1; // for sanity sake, make sure it's not 0
158 gl_supportslockarrays = gl_checkextension("GL_EXT_compiled_vertex_array", compiledvertexarrayfuncs, "-nocva");
163 void Force_CenterView_f (void)
165 cl.viewangles[PITCH] = 0;
168 void VID_InitCvars(void)
170 Cvar_RegisterVariable(&vid_mode);
171 Cvar_RegisterVariable(&vid_mouse);
172 Cvar_RegisterVariable(&vid_fullscreen);
173 Cvar_RegisterVariable(&gl_combine);
174 Cvar_RegisterVariable(&in_pitch_min);
175 Cvar_RegisterVariable(&in_pitch_max);
176 Cmd_AddCommand("force_centerview", Force_CenterView_f);