From 399aa7e4189e4bf8e040dcec00050590cd93cace Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 17 Nov 2022 21:29:11 +0500 Subject: [PATCH] Implement SetSwapInterval on Windows. --- include/gal/opengl/kiglew.h | 8 +++++++- include/gl_utils.h | 19 +++++++++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/include/gal/opengl/kiglew.h b/include/gal/opengl/kiglew.h index 40ff93e2e6..a846731605 100644 --- a/include/gal/opengl/kiglew.h +++ b/include/gal/opengl/kiglew.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2020-2022 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -65,4 +65,10 @@ #endif // __WXGTK__ +#ifdef _WIN32 + + #include + +#endif // _WIN32 + #endif // KIGLEW_H_ diff --git a/include/gl_utils.h b/include/gl_utils.h index 0a80f31991..f2c3d24ec6 100644 --- a/include/gl_utils.h +++ b/include/gl_utils.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2020 Kicad Developers, see AUTHORS.txt for contributors + * Copyright (C) 2020-2022 Kicad Developers, see AUTHORS.txt for contributors * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -41,8 +41,6 @@ public: */ static int SetSwapInterval( int aVal ) { - /// This routine is written for Linux using X11 only. The equivalent functions under - /// Windows would include and call wglSwapIntervalEXT #if defined( __linux__ ) && !defined( KICAD_USE_EGL ) if( Display* dpy = glXGetCurrentDisplay() ) @@ -104,10 +102,19 @@ public: } } - return std::numeric_limits::max(); -#else - return 0; +#elif defined( _WIN32 ) + + if( wglSwapIntervalEXT && wxGLCanvas::IsExtensionSupported( "WGL_EXT_swap_control" ) ) + { + if( aVal == -1 && !wxGLCanvas::IsExtensionSupported( "WGL_EXT_swap_control_tear" ) ) + aVal = 1; + + if( wglSwapIntervalEXT( aVal ) ) + return aVal; + } + #endif + return 0; } };