diff options
author | Erik Faye-Lund <erik.faye-lund@collabora.com> | 2020-04-16 23:35:42 +0200 |
---|---|---|
committer | Erik Faye-Lund <erik.faye-lund@collabora.com> | 2020-04-20 11:53:23 +0200 |
commit | 35ce140e756326b402686e57f318769e4080060d (patch) | |
tree | 304fb9eec934aeaae946470e074445d39bd5031d | |
parent | a81375c8e14eb45f1eaefa8f83f82d2b90239398 (diff) |
wglgears: check what the current vsync setting is
This seems to work fine on NVIDIA, but seems to report incorrect results
on Intel drivers. Reading the WGL_EXT_swap_control specification, this
seems like subtle driver-bug, and not an application problem, so let's
do this anyway.
Reviewed-by: Brian Paul <brianp@vmware.com>
-rw-r--r-- | src/wgl/wglgears.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/wgl/wglgears.c b/src/wgl/wglgears.c index 2e1e9a1e..5f18d89d 100644 --- a/src/wgl/wglgears.c +++ b/src/wgl/wglgears.c @@ -554,6 +554,33 @@ is_wgl_extension_supported(HDC hdc, const char *query) } +/** + * Attempt to determine whether or not the display is synched to vblank. + */ +static void +query_vsync() +{ + int interval = 0; + if (is_wgl_extension_supported(hDC, "WGL_EXT_swap_control")) { + PFNWGLGETSWAPINTERVALEXTPROC wglGetSwapIntervalEXT_func = + (PFNWGLGETSWAPINTERVALEXTPROC) + wglGetProcAddress("wglGetSwapIntervalEXT"); + interval = wglGetSwapIntervalEXT_func(); + } + + if (interval > 0) { + printf("Running synchronized to the vertical refresh. The framerate should be\n"); + if (interval == 1) { + printf("approximately the same as the monitor refresh rate.\n"); + } + else if (interval > 1) { + printf("approximately 1/%d the monitor refresh rate.\n", + interval); + } + } +} + + static void event_loop(void) { @@ -659,6 +686,7 @@ main(int argc, char *argv[]) make_window("wglgears", x, y, winWidth, winHeight); reshape(winWidth, winHeight); + query_vsync(); if (printInfo) { printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); |