Swap Interval

From OpenGL Wiki
Revision as of 17:26, 5 December 2008 by V-man (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

In Windows, if WGL_EXT_swap_control is present in the string returned by glGetString(GL_EXTENSIONS), then you can use wglSwapIntervalEXT(0) to disable vsync or you can use wglSwapIntervalEXT(1) to enable vsync (aka vertical synchronization).
For historical reasons, WGL_EXT_swap_control is included in the GL_EXTENSIONS string as returned from glGetString.
http://www.opengl.org/registry/specs/EXT/wgl_swap_control.txt
It is also included in the string returned by wglGetExtensionsStringARB(), which is the more correct place for it.
You should check for the presence in both locations to make sure it is really present. Either place will do.
We should also mention that there are duplicate extensions : WGL_EXT_extensions_string, WGL_ARB_extensions_string.
http://www.opengl.org/registry/specs/EXT/wgl_extensions_string.txt defines wglGetExtensionsStringEXT
http://www.opengl.org/registry/specs/ARB/wgl_extensions_string.txt defines wglGetExtensionsStringARB

Use wglGetExtensionsStringARB. Don't bother with wglGetExtensionsStringEXT.

In Linux, things are much simpler.
If GLX_SGI_swap_control is present in the string returned by glGetString(GL_EXTENSIONS), then you can use glXSwapIntervalSGI(0) to disable vsync or you can use glXSwapIntervalSGI(1) to enable vsync (aka vertical synchronization).
Apparently, an EXT or ARB version has not been created.
http://www.opengl.org/registry/specs/SGI/swap_control.txt
The extension doesn't say it but it is assumed that glGetString(GL_EXTENSIONS) returns GLX_SGI_swap_control.

Note : It has been reported that in some case (some driver) with ATI, it doesn't give GLX_SGI_swap_control. It gives WGL_EXT_swap_control yet the driver doesn't export wglSwapIntervalEXT but it does export glXSwapIntervalSGI and it works.
PS : if the driver is configed to ignore application settings, your calls to glXSwapIntervalSGI will get ignored.