summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorAndreas Haas <liu.gam3@gmail.com>2016-06-07 00:19:01 +0200
committerAndreas Haas <liu.gam3@gmail.com>2016-06-07 00:19:01 +0200
commit5cd7611a9ab71a7b72b4aaaab4a2498b3cadc972 (patch)
treea1aa3b52476c0c50b1ee4dfb17358264b01919c5 /platform
parent955ed0a95f61e14e6c941540b11905a16fb40d00 (diff)
x11: fix vsync support
Diffstat (limited to 'platform')
-rw-r--r--platform/x11/context_gl_x11.cpp34
1 files changed, 29 insertions, 5 deletions
diff --git a/platform/x11/context_gl_x11.cpp b/platform/x11/context_gl_x11.cpp
index 4e00dbf0a8..cd325dfc99 100644
--- a/platform/x11/context_gl_x11.cpp
+++ b/platform/x11/context_gl_x11.cpp
@@ -179,14 +179,38 @@ int ContextGL_X11::get_window_height() {
}
void ContextGL_X11::set_use_vsync(bool p_use) {
- GLXDrawable drawable = glXGetCurrentDrawable();
- //GLXSwapIntervalEXT(x11_display, drawable, p_use?1:0);
- use_vsync=p_use;
+ static bool setup = false;
+ static PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT = NULL;
+ static PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalMESA = NULL;
+ static PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI = NULL;
+
+ if (!setup) {
+ setup = true;
+ String extensions = glXQueryExtensionsString(x11_display, DefaultScreen(x11_display));
+ if (extensions.find("GLX_EXT_swap_control") != -1)
+ glXSwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC) glXGetProcAddressARB((const GLubyte*)"glXSwapIntervalEXT");
+ if (extensions.find("GLX_MESA_swap_control") != -1)
+ glXSwapIntervalMESA = (PFNGLXSWAPINTERVALSGIPROC) glXGetProcAddressARB((const GLubyte*)"glXSwapIntervalMESA");
+ if (extensions.find("GLX_SGI_swap_control") != -1)
+ glXSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC) glXGetProcAddressARB((const GLubyte*)"glXSwapIntervalSGI");
+ }
+ int val = p_use ? 1:0;
+ if (glXSwapIntervalMESA) {
+ glXSwapIntervalMESA(val);
+ }
+ else if (glXSwapIntervalSGI) {
+ glXSwapIntervalSGI(val);
+ }
+ else if (glXSwapIntervalEXT) {
+ GLXDrawable drawable = glXGetCurrentDrawable();
+ glXSwapIntervalEXT(x11_display, drawable, val);
+ }
+ else return;
+ use_vsync = p_use;
}
bool ContextGL_X11::is_using_vsync() const {
- return false;
- //return use_vsync;
+ return use_vsync;
}