]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
GLX mode now supports GLX_SGI_swap_control for vid_vsync
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 19 Dec 2004 01:09:34 +0000 (01:09 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 19 Dec 2004 01:09:34 +0000 (01:09 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4865 d7cf8633-e32d-0410-b094-e92efae38249

darkplaces.txt
vid.h
vid_glx.c
vid_shared.c

index ba8813d0d533bf77fd9481c9600e9de8f7ee0f77..bb298c303c2c15762b8625b58f7862b872bac116 100644 (file)
@@ -189,7 +189,7 @@ Many more features documented in dpextensions.qc. (bullet tracing on models, qc
 Commandline options as of 2004-10-05:
 BSD GLX: -gl_driver <drivername> selects a GL driver library, default is libGL.so.1, useful only for using fxmesa or similar, if you don't know what this is for, you don't need it
 BSD GLX: -nogetprocaddress disables GLX_ARB_get_proc_address (not required, more formal method of getting extension functions)
-BSD GLX: -novideosync disables GLX_SGI_video_sync
+BSD GLX: -novideosync disables GLX_SGI_swap_control
 BSD Sound: -cddev <devicepath> chooses which CD drive to use
 Client: -benchmark <demoname> runs a timedemo and quits, results of any timedemo can be found in gamedir/benchmark.log (for example id1/benchmark.log)
 Client: -forceqmenu disables menu.dat (same as +forceqmenu 1)
@@ -244,14 +244,14 @@ Linux ALSA Sound: -sndspeed <hz> chooses 44100 hz, 22100 hz, or 11025 hz sound o
 Linux ALSA Sound: -sndstereo sets sound output to stereo
 Linux GLX: -gl_driver <drivername> selects a GL driver library, default is libGL.so.1, useful only for using fxmesa or similar, if you don't know what this is for, you don't need it
 Linux GLX: -nogetprocaddress disables GLX_ARB_get_proc_address (not required, more formal method of getting extension functions)
-Linux GLX: -novideosync disables GLX_SGI_video_sync
+Linux GLX: -novideosync disables GLX_SGI_swap_control
 Linux OSS Sound: -sndbits <bits> chooses 8 bit or 16 bit sound output
 Linux OSS Sound: -sndmono sets sound output to mono
 Linux OSS Sound: -sndspeed <hz> chooses 44100 hz, 22100 hz, or 11025 hz sound output rate
 Linux OSS Sound: -sndstereo sets sound output to stereo
 Linux Sound: -cddev <devicepath> chooses which CD drive to use
 MacOSX GLX: -nogetprocaddress disables GLX_ARB_get_proc_address (not required, more formal method of getting extension functions)
-MacOSX GLX: -novideosync disables GLX_SGI_video_sync
+MacOSX GLX: -novideosync disables GLX_SGI_swap_control
 SDL GL: -gl_driver <drivername> selects a GL driver library, default is libGL.so.1 (Linux/BSD) or opengl32.dll (windows) or OpenGL.framework (MacOSX), useful only for 3dfxogl.dll/3dfxvgl.dll or fxmesa or similar, if you don't know what this is for, you don't need it
 SDL Sound: -sndspeed <hz> chooses 44100 hz, 22100 hz, or 11025 hz sound output rate
 Server: -dedicated [playerlimit] starts a dedicated server (with a command console), default playerlimit is 8
diff --git a/vid.h b/vid.h
index 3ab176142c232e05b26a80042fd361fa41167e17..dbaa81aafc285c12ef1b590d8a21535412f177c6 100644 (file)
--- a/vid.h
+++ b/vid.h
@@ -93,7 +93,7 @@ extern char gl_driver[256];
 extern qboolean isG200;
 extern qboolean isRagePro;
 
-// LordHavoc: GLX_SGI_video_sync and WGL_EXT_swap_control
+// LordHavoc: GLX_SGI_swap_control and WGL_EXT_swap_control
 extern int gl_videosyncavailable;
 
 int GL_OpenLibrary(const char *name);
index 46ccdb262f1ad6cb2923cd9fba0cac4c75278142..4df6fb707ab1a0bf7afcf2181f9e1f2804ddcf9c 100644 (file)
--- a/vid_glx.c
+++ b/vid_glx.c
@@ -62,14 +62,12 @@ static dllfunction_t getprocaddressfuncs[] =
        {NULL, NULL}
 };
 
-//GLX_SGI_video_sync
-GLint (GLAPIENTRY *qglXGetVideoSyncSGI)(GLuint *count);
-GLint (GLAPIENTRY *qglXWaitVideoSyncSGI)(GLint divisor, GLint remainder, GLuint *count);
+//GLX_SGI_swap_control
+GLint (GLAPIENTRY *qglXSwapIntervalSGI)(GLint interval);
 
-static dllfunction_t videosyncfuncs[] =
+static dllfunction_t swapcontrolfuncs[] =
 {
-       {"glXGetVideoSyncSGI", (void **) &qglXGetVideoSyncSGI},
-       {"glXWaitVideoSyncSGI", (void **) &qglXWaitVideoSyncSGI},
+       {"glXSwapIntervalSGI", (void **) &qglXSwapIntervalSGI},
        {NULL, NULL}
 };
 
@@ -88,8 +86,13 @@ Atom wm_delete_window_atom;
                LeaveWindowMask)
 
 
-static qboolean                mouse_avail = true;
-static qboolean                mouse_active = false, usingmouse = false, ignoremousemove = false;
+static qboolean mouse_avail = true;
+static qboolean mouse_active = false;
+static qboolean vid_usingmouse = false;
+static qboolean vid_usemouse = false;
+static qboolean vid_usingvsync = false;
+static qboolean vid_usevsync = false;
+static qboolean ignoremousemove = false;
 static float   mouse_x, mouse_y;
 static int p_mouse_x, p_mouse_y;
 
@@ -338,7 +341,7 @@ static void HandleEvents(void)
 
                case MotionNotify:
                        // mouse moved
-                       if (usingmouse)
+                       if (vid_usingmouse)
                        {
 #ifndef __APPLE__
                                if (vid_dga.integer == 1)
@@ -554,7 +557,7 @@ void VID_Shutdown(void)
                return;
 
        vid_hidden = true;
-       usingmouse = false;
+       vid_usingmouse = false;
        if (vidx11_display)
        {
                VID_RestoreSystemGamma();
@@ -612,36 +615,42 @@ void VID_GetWindowSize (int *x, int *y, int *width, int *height)
 
 void VID_Finish (void)
 {
-       int usemouse;
-       if (r_render.integer)
+       vid_usevsync = vid_vsync.integer && !cls.timedemo && gl_videosyncavailable;
+       if (vid_usingvsync != vid_usevsync && gl_videosyncavailable)
        {
-               if (r_speeds.integer || gl_finish.integer)
-                       qglFinish();
-               qglXSwapBuffers(vidx11_display, win);
+               vid_usingvsync = vid_usevsync;
+               qglXSwapIntervalSGI (vid_usevsync);
        }
 
 // handle the mouse state when windowed if that's changed
-       usemouse = false;
+       vid_usemouse = false;
        if (vid_mouse.integer && !key_consoleactive)
-               usemouse = true;
+               vid_usemouse = true;
        if (vidmode_active)
-               usemouse = true;
-       if (usemouse)
+               vid_usemouse = true;
+       if (vid_usemouse)
        {
-               if (!usingmouse)
+               if (!vid_usingmouse)
                {
-                       usingmouse = true;
+                       vid_usingmouse = true;
                        IN_ActivateMouse ();
                }
        }
        else
        {
-               if (usingmouse)
+               if (vid_usingmouse)
                {
-                       usingmouse = false;
+                       vid_usingmouse = false;
                        IN_DeactivateMouse ();
                }
        }
+
+       if (r_render.integer)
+       {
+               if (r_speeds.integer || gl_finish.integer)
+                       qglFinish();
+               qglXSwapBuffers(vidx11_display, win);
+       }
 }
 
 int VID_SetGamma(unsigned short *ramps)
@@ -862,12 +871,12 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp)
 // COMMANDLINEOPTION: BSD GLX: -nogetprocaddress disables GLX_ARB_get_proc_address (not required, more formal method of getting extension functions)
 // COMMANDLINEOPTION: MacOSX GLX: -nogetprocaddress disables GLX_ARB_get_proc_address (not required, more formal method of getting extension functions)
        GL_CheckExtension("GLX_ARB_get_proc_address", getprocaddressfuncs, "-nogetprocaddress", false);
-// COMMANDLINEOPTION: Linux GLX: -novideosync disables GLX_SGI_video_sync
-// COMMANDLINEOPTION: BSD GLX: -novideosync disables GLX_SGI_video_sync
-// COMMANDLINEOPTION: MacOSX GLX: -novideosync disables GLX_SGI_video_sync
-       gl_videosyncavailable = GL_CheckExtension("GLX_SGI_video_sync", videosyncfuncs, "-novideosync", false);
+// COMMANDLINEOPTION: Linux GLX: -novideosync disables GLX_SGI_swap_control
+// COMMANDLINEOPTION: BSD GLX: -novideosync disables GLX_SGI_swap_control
+// COMMANDLINEOPTION: MacOSX GLX: -novideosync disables GLX_SGI_swap_control
+       gl_videosyncavailable = GL_CheckExtension("GLX_SGI_swap_control", swapcontrolfuncs, "-novideosync", false);
 
-       usingmouse = false;
+       vid_usingmouse = false;
        ignoremousemove = true;
        vid_hidden = false;
        vid_activewindow = true;
index 2720bb57f2fe3999ab5a7e31eb4748e01ee3582d..eeac1c579591204c83f732df236716ed2d93929a 100644 (file)
@@ -21,7 +21,7 @@ int gl_textureunits = 1;
 int gl_combine_extension = false;
 // GL_EXT_compiled_vertex_array
 int gl_supportslockarrays = false;
-// GLX_SGI_video_sync or WGL_EXT_swap_control
+// GLX_SGI_swap_control or WGL_EXT_swap_control
 int gl_videosyncavailable = false;
 // stencil available
 int gl_stencil = false;