]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - vid_glx.c
removed R_Mesh_Draw_NativeOnly (it was not used)
[xonotic/darkplaces.git] / vid_glx.c
index 994084da86f5c4ced9396e935591a42f93b58a55..6445cbac8c6221825b22bdf67d356d7181254da5 100644 (file)
--- a/vid_glx.c
+++ b/vid_glx.c
@@ -53,14 +53,11 @@ viddef_t    vid;                            // global video state
 
 static qboolean                mouse_avail = true;
 static qboolean                mouse_active = false, usingmouse = false;
-// static qboolean             dga_active;
 static float   mouse_x, mouse_y;
-static float   old_mouse_x, old_mouse_y;
 static int p_mouse_x, p_mouse_y;
 
 cvar_t vid_dga = {CVAR_SAVE, "vid_dga", "1"};
 cvar_t vid_dga_mouseaccel = {0, "vid_dga_mouseaccel", "1"};
-cvar_t m_filter = {0, "m_filter", "0"};
 
 qboolean vidmode_ext = false;
 
@@ -69,7 +66,6 @@ static int win_x, win_y;
 static int scr_width, scr_height;
 
 static XF86VidModeModeInfo **vidmodes;
-//static int default_dotclock_vidmode;
 static int num_vidmodes;
 static qboolean vidmode_active = false;
 
@@ -78,8 +74,6 @@ static Colormap vidx11_colormap;
 
 /*-----------------------------------------------------------------------*/
 
-float          gldepthmin, gldepthmax;
-
 const char *gl_vendor;
 const char *gl_renderer;
 const char *gl_version;
@@ -87,9 +81,8 @@ const char *gl_extensions;
 
 /*-----------------------------------------------------------------------*/
 static int
-XLateKey(XKeyEvent *ev/*, qboolean modified*/)
+XLateKey(XKeyEvent *ev)
 {
-//     char tmp[2];
        int key = 0;
        KeySym keysym;
 
@@ -183,7 +176,7 @@ XLateKey(XKeyEvent *ev/*, qboolean modified*/)
                        {
                                /* ASCII keys */
                                key = keysym;
-                               if (/*!modified && */((key >= 'A') && (key <= 'Z')))
+                               if ((key >= 'A') && (key <= 'Z'))
                                        key = key + ('a' - 'A');
                        }
                        break;
@@ -200,7 +193,7 @@ static Cursor CreateNullCursor(Display *display, Window root)
        XColor dummycolour;
        Cursor cursor;
 
-       cursormask = XCreatePixmap(display, root, 1, 1, 1/*depth*/);
+       cursormask = XCreatePixmap(display, root, 1, 1, 1);
        xgc.function = GXclear;
        gc =  XCreateGC(display, cursormask, GCFunction, &xgc);
        XFillRectangle(display, cursormask, gc, 0, 0, 1, 1);
@@ -227,7 +220,7 @@ static void install_grabs(void)
 
        XGrabPointer(vidx11_display, win,  True, 0, GrabModeAsync, GrabModeAsync, win, None, CurrentTime);
 
-       if (vid_dga.value)
+       if (vid_dga.integer)
        {
                int MajorVersion, MinorVersion;
 
@@ -235,11 +228,11 @@ static void install_grabs(void)
                {
                        // unable to query, probalby not supported
                        Con_Printf( "Failed to detect XF86DGA Mouse\n" );
-                       vid_dga.value = 0;
+                       vid_dga.integer = 0;
                }
                else
                {
-                       vid_dga.value = 1;
+                       vid_dga.integer = 1;
                        XF86DGADirectVideo(vidx11_display, DefaultScreen(vidx11_display), XF86DGADirectMouse);
                        XWarpPointer(vidx11_display, None, win, 0, 0, 0, 0, 0, 0);
                }
@@ -251,8 +244,6 @@ static void install_grabs(void)
 
        mouse_active = true;
        mouse_x = mouse_y = 0;
-
-//     XSync(vidx11_display, True);
 }
 
 static void uninstall_grabs(void)
@@ -260,7 +251,7 @@ static void uninstall_grabs(void)
        if (!vidx11_display || !win)
                return;
 
-       if (vid_dga.value == 1)
+       if (vid_dga.integer == 1)
                XF86DGADirectVideo(vidx11_display, DefaultScreen(vidx11_display), 0);
 
        XUngrabPointer(vidx11_display, CurrentTime);
@@ -275,7 +266,6 @@ static void uninstall_grabs(void)
 static void HandleEvents(void)
 {
        XEvent event;
-//     KeySym ks;
        qboolean dowarp = false;
 
        if (!vidx11_display)
@@ -295,37 +285,21 @@ static void HandleEvents(void)
                case MotionNotify:
                        if (usingmouse)
                        {
-                               if (vid_dga.value == 1)
+                               if (vid_dga.integer == 1)
                                {
                                        mouse_x += event.xmotion.x_root * vid_dga_mouseaccel.value;
                                        mouse_y += event.xmotion.y_root * vid_dga_mouseaccel.value;
                                }
                                else
                                {
-                                       /*
-                                       if (!p_mouse_x && !p_mouse_y)
-                                       {
-                                               Con_Printf("event->xmotion.x: %d\n", event.xmotion.x);
-                                               Con_Printf("event->xmotion.y: %d\n", event.xmotion.y);
-                                       }
-                                       */
-                                       //if (usingmouse)
-                                       {
-                                               if (!event.xmotion.send_event)
-                                               {
-                                                       mouse_x += event.xmotion.x - p_mouse_x;
-                                                       mouse_y += event.xmotion.y - p_mouse_y;
-                                                       if (abs(scr_width/2 - event.xmotion.x) > scr_width / 4 || abs(scr_height/2 - event.xmotion.y) > scr_height / 4)
-                                                               dowarp = true;
-                                               }
-                                       }
-                                       /*
-                                       else
+                                       
+                                       if (!event.xmotion.send_event)
                                        {
-                                               mouse_x += (event.xmotion.x - p_mouse_x);
-                                               mouse_y += (event.xmotion.y - p_mouse_y);
+                                               mouse_x += event.xmotion.x - p_mouse_x;
+                                               mouse_y += event.xmotion.y - p_mouse_y;
+                                               if (abs(scr_width/2 - event.xmotion.x) > scr_width / 4 || abs(scr_height/2 - event.xmotion.y) > scr_height / 4)
+                                                       dowarp = true;
                                        }
-                                       */
                                        p_mouse_x = event.xmotion.x;
                                        p_mouse_y = event.xmotion.y;
                                }
@@ -441,10 +415,6 @@ void VID_Shutdown(void)
 
                if (vidmode_active)
                        XF86VidModeSwitchToMode(vidx11_display, scrnum, vidmodes[0]);
-/* Disabled, causes a segfault during shutdown.
-               if (ctx)
-                       glXDestroyContext(vidx11_display, ctx);
-*/
                if (win)
                        XDestroyWindow(vidx11_display, win);
                XCloseDisplay(vidx11_display);
@@ -478,31 +448,28 @@ void InitSig(void)
 
 /*
 =================
-GL_BeginRendering
-
+VID_GetWindowSize
 =================
 */
-void GL_BeginRendering (int *x, int *y, int *width, int *height)
+void VID_GetWindowSize (int *x, int *y, int *width, int *height)
 {
        *x = *y = 0;
        *width = scr_width;
        *height = scr_height;
-
-//     glViewport (*x, *y, *width, *height);
 }
 
-
-void GL_EndRendering (void)
+void VID_Finish (void)
 {
        int usemouse;
-       if (!r_render.value)
-               return;
-       glFlush();
-       glXSwapBuffers(vidx11_display, win);
+       if (r_render.integer)
+       {
+               qglFinish();
+               glXSwapBuffers(vidx11_display, win);
+       }
 
 // handle the mouse state when windowed if that's changed
        usemouse = false;
-       if (vid_mouse.value && key_dest == key_game)
+       if (vid_mouse.integer && key_dest == key_game)
                usemouse = true;
        if (vidmode_active)
                usemouse = true;
@@ -627,7 +594,6 @@ void VID_Init(void)
                GLX_DEPTH_SIZE, 1,
                None
        };
-//     char    gldir[MAX_OSPATH];
        int width = 640, height = 480;
        XSetWindowAttributes attr;
        unsigned long mask;
@@ -636,10 +602,8 @@ void VID_Init(void)
        qboolean fullscreen = true;
        int MajorVersion, MinorVersion;
 
-       Cvar_RegisterVariable (&vid_mouse);
        Cvar_RegisterVariable (&vid_dga);
        Cvar_RegisterVariable (&vid_dga_mouseaccel);
-       Cvar_RegisterVariable (&m_filter);
 
 // interpret command-line params
 
@@ -805,9 +769,6 @@ void VID_Init(void)
        GL_Init();
 
        Con_SafePrintf ("Video mode %dx%d initialized.\n", width, height);
-
-       // force a surface cache flush
-//     vid.recalc_refdef = 1;
 }
 
 void Sys_SendKeyEvents(void)
@@ -817,6 +778,8 @@ void Sys_SendKeyEvents(void)
 
 void IN_Init(void)
 {
+       if (COM_CheckParm ("-nomouse"))
+               mouse_avail = false;
 }
 
 void IN_Shutdown(void)
@@ -832,54 +795,11 @@ void IN_Commands (void)
 {
 }
 
-/*
-===========
-IN_Move
-===========
-*/
-void IN_MouseMove (usercmd_t *cmd)
-{
-       if (!mouse_avail)
-               return;
-
-       if (m_filter.value)
-       {
-               mouse_x = (mouse_x + old_mouse_x) * 0.5;
-               mouse_y = (mouse_y + old_mouse_y) * 0.5;
-
-               old_mouse_x = mouse_x;
-               old_mouse_y = mouse_y;
-       }
-
-       mouse_x *= sensitivity.value;
-       mouse_y *= sensitivity.value;
-
-       if (in_strafe.state & 1)
-               cmd->sidemove += m_side.value * mouse_x;
-       else
-               cl.viewangles[YAW] -= m_yaw.value * mouse_x;
-
-       //if (freelook)
-               V_StopPitchDrift ();
-
-       if (/*freelook && */!(in_strafe.state & 1))
-       {
-               cl.viewangles[PITCH] += m_pitch.value * mouse_y;
-               cl.viewangles[PITCH] = bound (-90, cl.viewangles[PITCH], 90);
-       }
-       else
-       {
-               if ((in_strafe.state & 1) && noclip_anglehack)
-                       cmd->upmove -= m_forward.value * mouse_y;
-               else
-                       cmd->forwardmove -= m_forward.value * mouse_y;
-       }
-       mouse_x = mouse_y = 0.0;
-}
-
 void IN_Move (usercmd_t *cmd)
 {
-       IN_MouseMove(cmd);
+       if (mouse_avail)
+               IN_Mouse(cmd, mouse_x, mouse_y);
+       mouse_x = 0;
+       mouse_y = 0;
 }
 
-