From d98e08d90b3d53dfb0af1438cfcfd812060f9f51 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 17 Nov 2022 21:32:34 +0500 Subject: [PATCH] Set swap interval to 1 if adaptive is unavailable. --- include/gl_utils.h | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/include/gl_utils.h b/include/gl_utils.h index f2c3d24ec6..7f22bb0f92 100644 --- a/include/gl_utils.h +++ b/include/gl_utils.h @@ -28,8 +28,6 @@ #include #include -#include - class GL_UTILS { public: @@ -52,11 +50,11 @@ public: if( glXSwapIntervalEXT && glXQueryDrawable && drawable && exts.find( "GLX_EXT_swap_control" ) != std::string::npos ) { - if( aVal < 0 ) + if( aVal == -1 ) { if( exts.find( "GLX_EXT_swap_control_tear" ) == std::string::npos ) { - aVal = 0; + aVal = 1; } else { @@ -85,20 +83,20 @@ public: if( glXSwapIntervalMESA && glXGetSwapIntervalMESA && exts.find( "GLX_MESA_swap_control" ) != std::string::npos ) { - if( aVal < 0 ) - aVal = 0; + if( aVal == -1 ) + aVal = 1; - glXSwapIntervalMESA( aVal ); - return glXGetSwapIntervalMESA(); + if( !glXSwapIntervalMESA( aVal ) ) + return aVal; } - if( aVal > 0 && glXSwapIntervalSGI - && exts.find( "GLX_SGI_swap_control" ) != std::string::npos ) + if( glXSwapIntervalSGI && exts.find( "GLX_SGI_swap_control" ) != std::string::npos ) { - if( glXSwapIntervalSGI( aVal ) ) - glXSwapIntervalSGI( 1 ); + if( aVal == -1 ) + aVal = 1; - return 1; + if( !glXSwapIntervalSGI( aVal ) ) + return aVal; } }