From dead1603c3a4f0c1b133d6460f2cd0b611ae65e1 Mon Sep 17 00:00:00 2001 From: havoc Date: Sun, 19 Dec 2004 01:09:34 +0000 Subject: [PATCH] GLX mode now supports GLX_SGI_swap_control for vid_vsync git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4865 d7cf8633-e32d-0410-b094-e92efae38249 --- darkplaces.txt | 6 ++--- vid.h | 2 +- vid_glx.c | 65 ++++++++++++++++++++++++++++---------------------- vid_shared.c | 2 +- 4 files changed, 42 insertions(+), 33 deletions(-) diff --git a/darkplaces.txt b/darkplaces.txt index ba8813d0..bb298c30 100644 --- a/darkplaces.txt +++ b/darkplaces.txt @@ -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 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 chooses which CD drive to use Client: -benchmark 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 chooses 44100 hz, 22100 hz, or 11025 hz sound o Linux ALSA Sound: -sndstereo sets sound output to stereo Linux GLX: -gl_driver 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 chooses 8 bit or 16 bit sound output Linux OSS Sound: -sndmono sets sound output to mono Linux OSS Sound: -sndspeed chooses 44100 hz, 22100 hz, or 11025 hz sound output rate Linux OSS Sound: -sndstereo sets sound output to stereo Linux Sound: -cddev 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 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 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 3ab17614..dbaa81aa 100644 --- 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); diff --git a/vid_glx.c b/vid_glx.c index 46ccdb26..4df6fb70 100644 --- 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; diff --git a/vid_shared.c b/vid_shared.c index 2720bb57..eeac1c57 100644 --- a/vid_shared.c +++ b/vid_shared.c @@ -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; -- 2.39.2