]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - vid_glx.c
454
[xonotic/darkplaces.git] / vid_glx.c
index 8f477f3e5151e60fdc2882924858869d461bbed0..84a16a846d750183b3839fc2494043d45f0d6f10 100644 (file)
--- a/vid_glx.c
+++ b/vid_glx.c
@@ -97,16 +97,16 @@ static float        mouse_x, mouse_y;
 static int p_mouse_x, p_mouse_y;
 
 #if !defined(__APPLE__) && !defined(SUNOS)
-cvar_t vid_dga = {CVAR_SAVE, "vid_dga", "1"};
-cvar_t vid_dga_mouseaccel = {0, "vid_dga_mouseaccel", "1"};
+// FIXME: vid_dga_mouseaccel is poorly named, it is actually the multiplier for mouse movement, not an acceleration (which would be a power function or something)
+cvar_t vid_dga = {CVAR_SAVE, "vid_dga", "1", "make use of DGA mouse input"};
+cvar_t vid_dga_mouseaccel = {0, "vid_dga_mouseaccel", "1", "speed of mouse when using DGA mouse input"};
 #endif
 
 qboolean vidmode_ext = false;
 
 static int win_x, win_y;
 
-static XF86VidModeModeInfo **vidmodes;
-static int num_vidmodes;
+static XF86VidModeModeInfo init_vidmode;
 static qboolean vid_isfullscreen = false;
 
 static Visual *vidx11_visual;
@@ -522,7 +522,7 @@ void VID_Shutdown(void)
 
                // FIXME: glXDestroyContext here?
                if (vid_isfullscreen)
-                       XF86VidModeSwitchToMode(vidx11_display, vidx11_screen, vidmodes[0]);
+                       XF86VidModeSwitchToMode(vidx11_display, vidx11_screen, &init_vidmode);
                if (win)
                        XDestroyWindow(vidx11_display, win);
                XCloseDisplay(vidx11_display);
@@ -591,11 +591,23 @@ void VID_Finish (void)
 
 int VID_SetGamma(unsigned short *ramps)
 {
+       int rampsize;
+       // FIXME: it would be good to generate ramps of the size reported by X,
+       // for instance Quadro cards seem to use 1024 color ramps not 256
+       if(!XF86VidModeGetGammaRampSize(vidx11_display, vidx11_screen, &rampsize))
+               return 0;
+       if(rampsize != 256)
+               return 0;
        return XF86VidModeSetGammaRamp(vidx11_display, vidx11_screen, 256, ramps, ramps + 256, ramps + 512);
 }
 
 int VID_GetGamma(unsigned short *ramps)
 {
+       int rampsize;
+       if(!XF86VidModeGetGammaRampSize(vidx11_display, vidx11_screen, &rampsize))
+               return 0;
+       if(rampsize != 256)
+               return 0;
        return XF86VidModeGetGammaRamp(vidx11_display, vidx11_screen, 256, ramps, ramps + 256, ramps + 512);
 }
 
@@ -701,6 +713,14 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate
                // Are we going fullscreen?  If so, let's change video mode
                if (fullscreen)
                {
+                       XF86VidModeModeLine *current_vidmode;
+                       XF86VidModeModeInfo **vidmodes;
+                       int num_vidmodes;
+
+                       // This nice hack comes from the SDL source code
+                       current_vidmode = (XF86VidModeModeLine*)((char*)&init_vidmode + sizeof(init_vidmode.dotclock));
+                       XF86VidModeGetModeLine(vidx11_display, vidx11_screen, (int*)&init_vidmode.dotclock, current_vidmode);
+
                        XF86VidModeGetAllModeLines(vidx11_display, vidx11_screen, &num_vidmodes, &vidmodes);
                        best_dist = 9999999;
                        best_fit = -1;
@@ -737,6 +757,8 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate
                        }
                        else
                                fullscreen = 0;
+
+                       free(vidmodes);
                }
        }