]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - vid_glx.c
various printf/fprintf calls are now Con_Printf, and some other minor cleanups
[xonotic/darkplaces.git] / vid_glx.c
index 4df6fb707ab1a0bf7afcf2181f9e1f2804ddcf9c..fbbb5b08eb063b9cab095b1d200280620cae42e6 100644 (file)
--- a/vid_glx.c
+++ b/vid_glx.c
@@ -109,7 +109,7 @@ static int scr_width, scr_height;
 
 static XF86VidModeModeInfo **vidmodes;
 static int num_vidmodes;
-static qboolean vidmode_active = false;
+static qboolean vid_isfullscreen = false;
 
 static Visual *vidx11_visual;
 static Colormap vidx11_colormap;
@@ -551,6 +551,43 @@ static void IN_ActivateMouse( void )
        }
 }
 
+static void *prjobj = NULL;
+
+static void GL_CloseLibrary(void)
+{
+       if (prjobj)
+               dlclose(prjobj);
+       prjobj = NULL;
+       gl_driver[0] = 0;
+       qglXGetProcAddressARB = NULL;
+       gl_extensions = "";
+       gl_platform = "";
+       gl_platformextensions = "";
+}
+
+static int GL_OpenLibrary(const char *name)
+{
+       Con_Printf("Loading OpenGL driver %s\n", name);
+       GL_CloseLibrary();
+       if (!(prjobj = dlopen(name, RTLD_LAZY)))
+       {
+               Con_Printf("Unable to open symbol list for %s\n", name);
+               return false;
+       }
+       strcpy(gl_driver, name);
+       return true;
+}
+
+void *GL_GetProcAddress(const char *name)
+{
+       void *p = NULL;
+       if (qglXGetProcAddressARB != NULL)
+               p = (void *) qglXGetProcAddressARB(name);
+       if (p == NULL)
+               p = (void *) dlsym(prjobj, name);
+       return p;
+}
+
 void VID_Shutdown(void)
 {
        if (!ctx || !vidx11_display)
@@ -564,13 +601,13 @@ void VID_Shutdown(void)
                uninstall_grabs();
 
                // FIXME: glXDestroyContext here?
-               if (vidmode_active)
+               if (vid_isfullscreen)
                        XF86VidModeSwitchToMode(vidx11_display, vidx11_screen, vidmodes[0]);
                if (win)
                        XDestroyWindow(vidx11_display, win);
                XCloseDisplay(vidx11_display);
        }
-       vidmode_active = false;
+       vid_isfullscreen = false;
        vidx11_display = NULL;
        win = 0;
        ctx = NULL;
@@ -581,7 +618,7 @@ void VID_Shutdown(void)
 
 void signal_handler(int sig)
 {
-       printf("Received signal %d, exiting...\n", sig);
+       Con_Printf("Received signal %d, exiting...\n", sig);
        VID_RestoreSystemGamma();
        Sys_Quit();
        exit(0);
@@ -619,14 +656,17 @@ void VID_Finish (void)
        if (vid_usingvsync != vid_usevsync && gl_videosyncavailable)
        {
                vid_usingvsync = vid_usevsync;
-               qglXSwapIntervalSGI (vid_usevsync);
+               if (qglXSwapIntervalSGI (vid_usevsync))
+                       Con_Print("glXSwapIntervalSGI didn't accept the vid_vsync change, it will take effect on next vid_restart (GLX_SGI_swap_control does not allow turning off vsync)\n");
        }
 
 // handle the mouse state when windowed if that's changed
        vid_usemouse = false;
-       if (vid_mouse.integer && !key_consoleactive)
+       if (vid_mouse.integer && !key_consoleactive && !cls.demoplayback)
                vid_usemouse = true;
-       if (vidmode_active)
+       if (!vid_activewindow)
+               vid_usemouse = false;
+       if (vid_isfullscreen)
                vid_usemouse = true;
        if (vid_usemouse)
        {
@@ -793,7 +833,7 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp)
 
                                // change to the mode
                                XF86VidModeSwitchToMode(vidx11_display, vidx11_screen, vidmodes[best_fit]);
-                               vidmode_active = true;
+                               vid_isfullscreen = true;
 
                                // Move the viewport to top left
                                XF86VidModeSetViewPort(vidx11_display, vidx11_screen, 0, 0);
@@ -812,7 +852,7 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp)
        // LordHavoc: save the colormap for later, too
        vidx11_colormap = attr.colormap = XCreateColormap(vidx11_display, root, visinfo->visual, AllocNone);
        attr.event_mask = X_MASK;
-       if (vidmode_active)
+       if (vid_isfullscreen)
        {
                mask = CWBackPixel | CWColormap | CWSaveUnder | CWBackingStore | CWEventMask | CWOverrideRedirect;
                attr.override_redirect = True;
@@ -831,7 +871,7 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp)
        wm_delete_window_atom = XInternAtom(vidx11_display, "WM_DELETE_WINDOW", false);
        XSetWMProtocols(vidx11_display, win, &wm_delete_window_atom, 1);
 
-       if (vidmode_active)
+       if (vid_isfullscreen)
        {
                XMoveWindow(vidx11_display, win, 0, 0);
                XRaiseWindow(vidx11_display, win);
@@ -877,6 +917,7 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp)
        gl_videosyncavailable = GL_CheckExtension("GLX_SGI_swap_control", swapcontrolfuncs, "-novideosync", false);
 
        vid_usingmouse = false;
+       vid_usingvsync = false;
        ignoremousemove = true;
        vid_hidden = false;
        vid_activewindow = true;
@@ -905,41 +946,3 @@ void IN_Move (void)
        mouse_x = 0;
        mouse_y = 0;
 }
-
-static void *prjobj = NULL;
-
-int GL_OpenLibrary(const char *name)
-{
-       Con_Printf("Loading OpenGL driver %s\n", name);
-       GL_CloseLibrary();
-       if (!(prjobj = dlopen(name, RTLD_LAZY)))
-       {
-               Con_Printf("Unable to open symbol list for %s\n", name);
-               return false;
-       }
-       strcpy(gl_driver, name);
-       return true;
-}
-
-void GL_CloseLibrary(void)
-{
-       if (prjobj)
-               dlclose(prjobj);
-       prjobj = NULL;
-       gl_driver[0] = 0;
-       qglXGetProcAddressARB = NULL;
-       gl_extensions = "";
-       gl_platform = "";
-       gl_platformextensions = "";
-}
-
-void *GL_GetProcAddress(const char *name)
-{
-       void *p = NULL;
-       if (qglXGetProcAddressARB != NULL)
-               p = (void *) qglXGetProcAddressARB(name);
-       if (p == NULL)
-               p = (void *) dlsym(prjobj, name);
-       return p;
-}
-