Mesa (master): glxgears: Support GLX_EXT_swap_control for querying the current swap interval.

Brian Paul brianp at kemper.freedesktop.org
Tue Jan 26 19:01:26 UTC 2010


Module: Mesa
Branch: master
Commit: cec0e7c086d04c73e5c0a516cb6e3df9bc250cb2
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=cec0e7c086d04c73e5c0a516cb6e3df9bc250cb2

Author: Aaron Plattner <aplattner at nvidia.com>
Date:   Tue Jan 26 10:14:11 2010 -0800

glxgears: Support GLX_EXT_swap_control for querying the current swap interval.

Signed-off-by: Aaron Plattner <aplattner at nvidia.com>
Signed-off-by: Brian Paul <brianp at vmware.com>

---

 progs/xdemos/glxgears.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/progs/xdemos/glxgears.c b/progs/xdemos/glxgears.c
index 2993c82..92c75ca 100644
--- a/progs/xdemos/glxgears.c
+++ b/progs/xdemos/glxgears.c
@@ -35,6 +35,7 @@
 #include <X11/keysym.h>
 #include <GL/gl.h>
 #include <GL/glx.h>
+#include <GL/glxext.h>
 
 #ifndef GLX_MESA_swap_control
 #define GLX_MESA_swap_control 1
@@ -586,11 +587,17 @@ is_glx_extension_supported(Display *dpy, const char *query)
  * Attempt to determine whether or not the display is synched to vblank.
  */
 static void
-query_vsync(Display *dpy)
+query_vsync(Display *dpy, GLXDrawable drawable)
 {
    int interval = 0;
 
-
+#if defined(GLX_EXT_swap_control)
+   if (is_glx_extension_supported(dpy, "GLX_EXT_swap_control")) {
+       unsigned int tmp = -1;
+       glXQueryDrawable(dpy, drawable, GLX_SWAP_INTERVAL_EXT, &tmp);
+       interval = tmp;
+   } else
+#endif
    if (is_glx_extension_supported(dpy, "GLX_MESA_swap_control")) {
       PFNGLXGETSWAPINTERVALMESAPROC pglXGetSwapIntervalMESA =
           (PFNGLXGETSWAPINTERVALMESAPROC)
@@ -749,7 +756,7 @@ main(int argc, char *argv[])
    make_window(dpy, "glxgears", x, y, winWidth, winHeight, &win, &ctx);
    XMapWindow(dpy, win);
    glXMakeCurrent(dpy, win, ctx);
-   query_vsync(dpy);
+   query_vsync(dpy, win);
 
    if (printInfo) {
       printf("GL_RENDERER   = %s\n", (char *) glGetString(GL_RENDERER));




More information about the mesa-commit mailing list