CanvasX11GLX: Updates to handle the API change for GLX_EXT_swap_control
(The spec always had a void return value for glXSwapIntervalEXT, however, the
original example and protocol had a return value of int. To make matters worse,
the header files in mesa were updated a year after the spec.). Also, make the
GLX_MESA_swap_control initialization match the new logic for GLX_EXT_swap_control.
diff --git a/src/canvas-x11-glx.cpp b/src/canvas-x11-glx.cpp
index 01d71cc..db3ac70 100644
--- a/src/canvas-x11-glx.cpp
+++ b/src/canvas-x11-glx.cpp
@@ -28,6 +28,7 @@
static PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT_;
static PFNGLXSWAPINTERVALMESAPROC glXSwapIntervalMESA_;
+static PFNGLXGETSWAPINTERVALMESAPROC glXGetSwapIntervalMESA_;
/*********************
* Protected methods *
@@ -60,12 +61,24 @@
return false;
}
- if ((!glXSwapIntervalEXT_ || glXSwapIntervalEXT_(xdpy_, xwin_, 0)) &&
- (!glXSwapIntervalMESA_ || glXSwapIntervalMESA_(0)))
- {
- Log::info("** Failed to set swap interval. Results may be bounded above by refresh rate.\n");
+ unsigned int desired_swap(0);
+ unsigned int actual_swap(-1);
+ if (glXSwapIntervalEXT_) {
+ glXSwapIntervalEXT_(xdpy_, xwin_, desired_swap);
+ glXQueryDrawable(xdpy_, xwin_, GLX_SWAP_INTERVAL_EXT, &actual_swap);
+ if (actual_swap == desired_swap)
+ return true;
}
+ if (glXSwapIntervalMESA_) {
+ glXSwapIntervalMESA_(desired_swap);
+ actual_swap = glXGetSwapIntervalMESA_();
+ if (actual_swap == desired_swap)
+ return true;
+ }
+
+ Log::info("** Failed to set swap interval. Results may be bounded above by refresh rate.\n");
+
return true;
}
@@ -131,6 +144,12 @@
reinterpret_cast<const GLubyte *>("glXSwapIntervalMESA")
)
);
+ glXGetSwapIntervalMESA_ =
+ reinterpret_cast<PFNGLXGETSWAPINTERVALMESAPROC>(
+ glXGetProcAddress(
+ reinterpret_cast<const GLubyte *>("glXGetSwapIntervalMESA")
+ )
+ );
}