]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - vid_glx.c
fixed bullets-going-through-walls bug in q3bsp collision code, this was a really...
[xonotic/darkplaces.git] / vid_glx.c
index cc503fda5e474a92d26b2b52e18a40d0c5fac42e..84a16a846d750183b3839fc2494043d45f0d6f10 100644 (file)
--- a/vid_glx.c
+++ b/vid_glx.c
@@ -45,6 +45,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 // Tell startup code that we have a client
 int cl_available = true;
 
+// note: if we used the XRandR extension we could support refresh rates
+qboolean vid_supportrefreshrate = false;
+
 //GLX prototypes
 XVisualInfo *(GLAPIENTRY *qglXChooseVisual)(Display *dpy, int screen, int *attribList);
 GLXContext (GLAPIENTRY *qglXCreateContext)(Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct);
@@ -94,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;
@@ -519,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);
@@ -588,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);
 }
 
@@ -625,7 +640,7 @@ void VID_BuildGLXAttrib(int *attrib, int stencil)
        *attrib++ = None;
 }
 
-int VID_InitMode(int fullscreen, int width, int height, int bpp)
+int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate)
 {
        int i;
        int attrib[32];
@@ -698,6 +713,14 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp)
                // 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;
@@ -734,6 +757,8 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp)
                        }
                        else
                                fullscreen = 0;
+
+                       free(vidmodes);
                }
        }