Set swap interval to 1 if adaptive is unavailable.

This commit is contained in:
Alex 2022-11-17 21:32:34 +05:00
parent 399aa7e418
commit d98e08d90b
1 changed files with 11 additions and 13 deletions

View File

@ -28,8 +28,6 @@
#include <wx/glcanvas.h> #include <wx/glcanvas.h>
#include <wx/utils.h> #include <wx/utils.h>
#include <limits>
class GL_UTILS class GL_UTILS
{ {
public: public:
@ -52,11 +50,11 @@ public:
if( glXSwapIntervalEXT && glXQueryDrawable && drawable if( glXSwapIntervalEXT && glXQueryDrawable && drawable
&& exts.find( "GLX_EXT_swap_control" ) != std::string::npos ) && 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 ) if( exts.find( "GLX_EXT_swap_control_tear" ) == std::string::npos )
{ {
aVal = 0; aVal = 1;
} }
else else
{ {
@ -85,20 +83,20 @@ public:
if( glXSwapIntervalMESA && glXGetSwapIntervalMESA if( glXSwapIntervalMESA && glXGetSwapIntervalMESA
&& exts.find( "GLX_MESA_swap_control" ) != std::string::npos ) && exts.find( "GLX_MESA_swap_control" ) != std::string::npos )
{ {
if( aVal < 0 ) if( aVal == -1 )
aVal = 0; aVal = 1;
glXSwapIntervalMESA( aVal ); if( !glXSwapIntervalMESA( aVal ) )
return glXGetSwapIntervalMESA(); return aVal;
} }
if( aVal > 0 && glXSwapIntervalSGI if( glXSwapIntervalSGI && exts.find( "GLX_SGI_swap_control" ) != std::string::npos )
&& exts.find( "GLX_SGI_swap_control" ) != std::string::npos )
{ {
if( glXSwapIntervalSGI( aVal ) ) if( aVal == -1 )
glXSwapIntervalSGI( 1 ); aVal = 1;
return 1; if( !glXSwapIntervalSGI( aVal ) )
return aVal;
} }
} }