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},
68 static void *prjobj = NULL;
71 static void gl_getfuncs_begin(void)
77 prjobj = dlopen(NULL, RTLD_LAZY);
80 Con_Printf("Unable to open symbol list for main program.\n");
86 static void gl_getfuncs_end(void)
97 static void *gl_getfuncaddress(char *name)
100 return (void *) wglGetProcAddress(name);
102 return (void *) dlsym(prjobj, name);
106 static int gl_checkextension(char *name, gl_extensionfunctionlist_t *funcs, char *disableparm)
108 gl_extensionfunctionlist_t *func;
110 Con_Printf("checking for %s... ", name);
112 for (func = funcs;func && func->name;func++)
113 *func->funcvariable = NULL;
115 if (disableparm && COM_CheckParm(disableparm))
117 Con_Printf("disabled by commandline\n");
121 if (strstr(gl_extensions, name))
123 for (func = funcs;func && func->name != NULL;func++)
125 if (!(*func->funcvariable = (void *) gl_getfuncaddress(func->name)))
127 Con_Printf("missing function \"%s\"!\n", func->name);
131 Con_Printf("enabled\n");
136 Con_Printf("not detected\n");
141 void VID_CheckExtensions(void)
143 Con_Printf("Checking OpenGL extensions...\n");
147 gl_combine_extension = false;
148 gl_supportslockarrays = false;
151 if (gl_checkextension("GL_ARB_multitexture", multitexturefuncs, "-nomtex"))
153 glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &gl_textureunits);
154 if (gl_textureunits > 1)
155 gl_combine_extension = gl_checkextension("GL_ARB_texture_env_combine", NULL, "-nocombine") || gl_checkextension("GL_EXT_texture_env_combine", NULL, "-nocombine");
157 gl_textureunits = 1; // for sanity sake, make sure it's not 0
160 gl_supportslockarrays = gl_checkextension("GL_EXT_compiled_vertex_array", compiledvertexarrayfuncs, "-nocva");
165 void Force_CenterView_f (void)
167 cl.viewangles[PITCH] = 0;
170 void VID_InitCvars(void)
172 Cvar_RegisterVariable(&vid_mode);
173 Cvar_RegisterVariable(&vid_mouse);
174 Cvar_RegisterVariable(&vid_fullscreen);
175 Cvar_RegisterVariable(&gl_combine);
176 Cvar_RegisterVariable(&in_pitch_min);
177 Cvar_RegisterVariable(&in_pitch_max);
178 Cmd_AddCommand("force_centerview", Force_CenterView_f);