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 cvar_t m_filter = {CVAR_SAVE, "m_filter","0"};
25 // GL_ARB_multitexture
26 //void (GLAPIENTRY *qglMultiTexCoord2f) (GLenum, GLfloat, GLfloat);
27 void (GLAPIENTRY *qglActiveTexture) (GLenum);
28 void (GLAPIENTRY *qglClientActiveTexture) (GLenum);
30 // GL_EXT_compiled_vertex_array
31 void (GLAPIENTRY *qglLockArraysEXT) (GLint first, GLint count);
32 void (GLAPIENTRY *qglUnlockArraysEXT) (void);
39 gl_extensionfunctionlist_t;
44 gl_extensionfunctionlist_t *funcs;
50 static gl_extensionfunctionlist_t multitexturefuncs[] =
52 //{"glMultiTexCoord2fARB", (void **) &qglMultiTexCoord2f},
53 {"glActiveTextureARB", (void **) &qglActiveTexture},
54 {"glClientActiveTextureARB", (void **) &qglClientActiveTexture},
58 static gl_extensionfunctionlist_t compiledvertexarrayfuncs[] =
60 {"glLockArraysEXT", (void **) &qglLockArraysEXT},
61 {"glUnlockArraysEXT", (void **) &qglUnlockArraysEXT},
70 static void *prjobj = NULL;
73 static void gl_getfuncs_begin(void)
79 prjobj = dlopen(NULL, RTLD_LAZY);
82 Con_Printf("Unable to open symbol list for main program.\n");
88 static void gl_getfuncs_end(void)
99 static void *gl_getfuncaddress(char *name)
102 return (void *) wglGetProcAddress(name);
104 return (void *) dlsym(prjobj, name);
108 static int gl_checkextension(char *name, gl_extensionfunctionlist_t *funcs, char *disableparm)
110 gl_extensionfunctionlist_t *func;
112 Con_Printf("checking for %s... ", name);
114 for (func = funcs;func && func->name;func++)
115 *func->funcvariable = NULL;
117 if (disableparm && COM_CheckParm(disableparm))
119 Con_Printf("disabled by commandline\n");
123 if (strstr(gl_extensions, name))
125 for (func = funcs;func && func->name != NULL;func++)
127 if (!(*func->funcvariable = (void *) gl_getfuncaddress(func->name)))
129 Con_Printf("missing function \"%s\"!\n", func->name);
133 Con_Printf("enabled\n");
138 Con_Printf("not detected\n");
143 void VID_CheckExtensions(void)
145 Con_Printf("Checking OpenGL extensions...\n");
149 gl_combine_extension = false;
150 gl_supportslockarrays = false;
153 if (gl_checkextension("GL_ARB_multitexture", multitexturefuncs, "-nomtex"))
155 glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &gl_textureunits);
156 if (gl_textureunits > 1)
157 gl_combine_extension = gl_checkextension("GL_ARB_texture_env_combine", NULL, "-nocombine") || gl_checkextension("GL_EXT_texture_env_combine", NULL, "-nocombine");
159 gl_textureunits = 1; // for sanity sake, make sure it's not 0
162 gl_supportslockarrays = gl_checkextension("GL_EXT_compiled_vertex_array", compiledvertexarrayfuncs, "-nocva");
167 void Force_CenterView_f (void)
169 cl.viewangles[PITCH] = 0;
172 void IN_PreMove(void)
176 void CL_AdjustAngles(void);
177 void IN_PostMove(void)
179 // clamp after the move as well to prevent messed up rendering angles
183 void IN_Mouse(usercmd_t *cmd, float mx, float my)
185 int mouselook = (in_mlook.state & 1) || freelook.integer;
186 float mouse_x, mouse_y;
187 static float old_mouse_x = 0, old_mouse_y = 0;
189 if (m_filter.integer)
191 mouse_x = (mx + old_mouse_x) * 0.5;
192 mouse_y = (my + old_mouse_y) * 0.5;
203 // LordHavoc: viewzoom affects mouse sensitivity for sniping
204 mouse_x *= sensitivity.value * cl.viewzoom;
205 mouse_y *= sensitivity.value * cl.viewzoom;
207 // Add mouse X/Y movement to cmd
208 if ( (in_strafe.state & 1) || (lookstrafe.integer && mouselook))
209 cmd->sidemove += m_side.value * mouse_x;
211 cl.viewangles[YAW] -= m_yaw.value * mouse_x;
216 if (mouselook && !(in_strafe.state & 1))
217 cl.viewangles[PITCH] += m_pitch.value * mouse_y;
220 if ((in_strafe.state & 1) && noclip_anglehack)
221 cmd->upmove -= m_forward.value * mouse_y;
223 cmd->forwardmove -= m_forward.value * mouse_y;
227 void VID_InitCvars(void)
229 Cvar_RegisterVariable(&vid_mode);
230 Cvar_RegisterVariable(&vid_mouse);
231 Cvar_RegisterVariable(&vid_fullscreen);
232 Cvar_RegisterVariable(&gl_combine);
233 Cvar_RegisterVariable(&in_pitch_min);
234 Cvar_RegisterVariable(&in_pitch_max);
235 Cvar_RegisterVariable(&m_filter);
236 Cmd_AddCommand("force_centerview", Force_CenterView_f);