Implement SetSwapInterval on Windows.

This commit is contained in:
Alex 2022-11-17 21:29:11 +05:00
parent db993bc8cc
commit 399aa7e418
2 changed files with 20 additions and 7 deletions

View File

@ -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 <GL/wglew.h>
#endif // _WIN32
#endif // KIGLEW_H_

View File

@ -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 <wglext.h> and call wglSwapIntervalEXT
#if defined( __linux__ ) && !defined( KICAD_USE_EGL )
if( Display* dpy = glXGetCurrentDisplay() )
@ -104,10 +102,19 @@ public:
}
}
return std::numeric_limits<int>::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;
}
};