From cea2a9b9f454192bccb1bf0b1f5561d601022d00 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 17 Dec 2021 09:37:34 -0500 Subject: Call glXQueryDrawable() from within the GLX context This fixes getting the PUGL_SWAP_INTERVAL hint on some NVidia drivers. --- src/x11_gl.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/x11_gl.c') diff --git a/src/x11_gl.c b/src/x11_gl.c index 80eb448..fa5739e 100644 --- a/src/x11_gl.c +++ b/src/x11_gl.c @@ -182,12 +182,20 @@ puglX11GlCreate(PuglView* view) (PFNGLXSWAPINTERVALEXTPROC)glXGetProcAddress( (const uint8_t*)"glXSwapIntervalEXT"); + // Note that some drivers (NVidia) require the context to be entered here puglX11GlEnter(view, NULL); // Set the swap interval if the user requested a specific value if (view->hints[PUGL_SWAP_INTERVAL] != PUGL_DONT_CARE) { glXSwapIntervalEXT(display, impl->win, view->hints[PUGL_SWAP_INTERVAL]); } + + // Get the actual current swap interval + glXQueryDrawable(impl->display, + impl->win, + GLX_SWAP_INTERVAL_EXT, + (unsigned int*)&view->hints[PUGL_SWAP_INTERVAL]); + puglX11GlLeave(view, NULL); } @@ -196,11 +204,6 @@ puglX11GlCreate(PuglView* view) GLX_DOUBLEBUFFER, &view->hints[PUGL_DOUBLE_BUFFER]); - glXQueryDrawable(display, - impl->win, - GLX_SWAP_INTERVAL_EXT, - (unsigned int*)&view->hints[PUGL_SWAP_INTERVAL]); - return PUGL_SUCCESS; } -- cgit v1.2.1