OpenGL: Fix SetSwapInterval logic.
- Don't use GLX extension functions unless they are supported on the connection. GLEW only checks for client library support. - Don't try to set swap interval using glXSwapIntervalSGI when vsync is not requested. Fixes https://gitlab.com/kicad/code/kicad/issues/11751
This commit is contained in:
parent
f5fe1d5462
commit
0e2d3236b5
|
@ -45,15 +45,15 @@ public:
|
|||
/// Windows would include <wglext.h> and call wglSwapIntervalEXT
|
||||
#if defined( __linux__ ) && !defined( KICAD_USE_EGL )
|
||||
|
||||
Display *dpy = glXGetCurrentDisplay();
|
||||
GLXDrawable drawable = glXGetCurrentDrawable();
|
||||
std::string vendor( reinterpret_cast<const char*>( glGetString( GL_VENDOR ) ) );
|
||||
bool is_mesa = ( vendor.find( "Mesa" ) != std::string::npos );
|
||||
|
||||
if( !is_mesa && glXSwapIntervalEXT && glXQueryDrawable && dpy && drawable )
|
||||
if( Display* dpy = glXGetCurrentDisplay() )
|
||||
{
|
||||
GLXDrawable drawable = glXGetCurrentDrawable();
|
||||
|
||||
std::string exts( glXQueryExtensionsString( dpy, DefaultScreen( dpy ) ) );
|
||||
|
||||
if( glXSwapIntervalEXT && glXQueryDrawable && drawable
|
||||
&& exts.find( "GLX_EXT_swap_control" ) != std::string::npos )
|
||||
{
|
||||
if( aVal < 0 )
|
||||
{
|
||||
if( exts.find( "GLX_EXT_swap_control_tear" ) == std::string::npos )
|
||||
|
@ -67,7 +67,8 @@ public:
|
|||
// enabled on the drawable.
|
||||
|
||||
unsigned lateSwapsEnabled = 0;
|
||||
glXQueryDrawable( dpy, drawable, GLX_LATE_SWAPS_TEAR_EXT, &lateSwapsEnabled );
|
||||
glXQueryDrawable( dpy, drawable, GLX_LATE_SWAPS_TEAR_EXT,
|
||||
&lateSwapsEnabled );
|
||||
|
||||
if( !lateSwapsEnabled )
|
||||
{
|
||||
|
@ -83,7 +84,8 @@ public:
|
|||
return clampedInterval;
|
||||
}
|
||||
|
||||
if( glXSwapIntervalMESA &&glXGetSwapIntervalMESA )
|
||||
if( glXSwapIntervalMESA && glXGetSwapIntervalMESA
|
||||
&& exts.find( "GLX_MESA_swap_control" ) != std::string::npos )
|
||||
{
|
||||
if( aVal < 0 )
|
||||
aVal = 0;
|
||||
|
@ -92,16 +94,15 @@ public:
|
|||
return glXGetSwapIntervalMESA();
|
||||
}
|
||||
|
||||
if( glXSwapIntervalSGI )
|
||||
if( aVal > 0 && glXSwapIntervalSGI
|
||||
&& exts.find( "GLX_SGI_swap_control" ) != std::string::npos )
|
||||
{
|
||||
if( aVal < 1 )
|
||||
aVal = 1;
|
||||
|
||||
if( glXSwapIntervalSGI( aVal ) )
|
||||
glXSwapIntervalSGI( 1 );
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return std::numeric_limits<int>::max();
|
||||
#else
|
||||
|
@ -111,4 +112,3 @@ public:
|
|||
};
|
||||
|
||||
#endif /* GL_CONTEXT_MANAGER_H */
|
||||
|
||||
|
|
Loading…
Reference in New Issue