Michal Suchánek 0c36e16292 Replace glew with epoxy
Glew has the problem that it has to be selected at build time if GLX or
EGL is supported by the library, and this in not encoded in the library
name, nor ABI, nor anything.

Then it's easy to get into the situation that a binary is built but
cannot run because glew supports an API different from the one used by
wxWidgets, or the binary fails to link in the end after all objects are
compiled.

epoxy can support both with the same library avoiding this problem.

epoxy is not initialized explicitly, replaced initialization with
version check where one was not done already.

It seems to be available as vcpkg https://vcpkg.link/ports/libepoxy

There are problems related to GL context switching on Windows which does
not seem to be used in kicad
https://github.com/anholt/libepoxy#known-issues-when-running-on-windows
There is also a problem related to multithreaded rendering on Windows
https://github.com/anholt/libepoxy/pull/265 It's harder to tell if
threading is used for rendering but it does not look like kicad is doing
anything complex enough to warrant using multiple rendering threads.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/20630
Fixes https://gitlab.com/kicad/code/kicad/-/issues/12543
2025-04-22 12:54:39 -07:00

72 lines
2.2 KiB
C

/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright The 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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* This file is used for including the proper GLEW header for the platform.
*/
#ifndef KIGLEW_H_
#define KIGLEW_H_
// Pull in the configuration options for wxWidgets
#include <wx/platform.h>
// Apple, in their infinite wisdom, has decided to mark OpenGL as deprecated.
// Luckily we can silence warnings about its deprecation. This is needed on the GLEW
// includes since they transitively include the OpenGL headers.
#define GL_SILENCE_DEPRECATION 1
#include <epoxy/gl.h>
#if defined( __unix__ ) and not defined( __APPLE__ )
#ifdef KICAD_USE_EGL
#if wxUSE_GLCANVAS_EGL
#include <epoxy/egl.h>
#else
#error "KICAD_USE_EGL can only be used when wxWidgets is compiled with the EGL canvas"
#endif
#else // KICAD_USE_EGL
#if wxUSE_GLCANVAS_EGL
#error "KICAD_USE_EGL must be defined since wxWidgets has been compiled with the EGL canvas"
#else
#include <epoxy/glx.h>
#endif
#endif // KICAD_USE_EGL
#endif // defined( __unix__ ) and not defined( __APPLE__ )
#ifdef _WIN32
#include <epoxy/wgl.h>
#endif // _WIN32
#include <GL/glu.h>
#endif // KIGLEW_H_