Skip to content

Commit e75076a

Browse files
committed
Revert "Replace glew with epoxy"
This reverts merge request !2217
1 parent 0c36e16 commit e75076a

34 files changed

+85881
-193
lines changed

3d-viewer/3d_canvas/eda_3d_canvas.cpp

+13-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
2323
*/
2424

25-
#include <gal/opengl/kiepoxy.h> // Must be included first
25+
#include <gal/opengl/kiglew.h> // Must be included first
2626
#include <gal/opengl/gl_utils.h>
2727
#include <wx/tokenzr.h>
2828

@@ -226,12 +226,21 @@ bool EDA_3D_CANVAS::initializeOpenGL()
226226
{
227227
wxLogTrace( m_logTrace, wxT( "EDA_3D_CANVAS::initializeOpenGL" ) );
228228

229-
// Check the OpenGL version (minimum 2.1 is required)
230-
if( epoxy_gl_version() < 21 )
229+
const GLenum err = glewInit();
230+
231+
if( GLEW_OK != err )
231232
{
232-
wxLogMessage( wxS( "OpenGL 2.1 or higher is required!" ) );
233+
const wxString msgError = (const char*) glewGetErrorString( err );
234+
235+
wxLogMessage( msgError );
236+
233237
return false;
234238
}
239+
else
240+
{
241+
wxLogTrace( m_logTrace, wxT( "EDA_3D_CANVAS::initializeOpenGL Using GLEW version %s" ),
242+
From_UTF8( (char*) glewGetString( GLEW_VERSION ) ) );
243+
}
235244

236245
SetOpenGLInfo( (const char*) glGetString( GL_VENDOR ), (const char*) glGetString( GL_RENDERER ),
237246
(const char*) glGetString( GL_VERSION ) );

3d-viewer/3d_model_viewer/eda_3d_model_viewer.cpp

+14-8
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* 3d models that come in the original data from the files without any transformations.
2828
*/
2929

30-
#include <gal/opengl/kiepoxy.h> // Must be included first
30+
#include <gal/opengl/kiglew.h> // Must be included first
3131
#include <iostream>
3232
#include "3d_rendering/opengl/3d_model.h"
3333
#include "eda_3d_model_viewer.h"
@@ -183,16 +183,22 @@ void EDA_3D_MODEL_VIEWER::Clear3DModel()
183183

184184
void EDA_3D_MODEL_VIEWER::ogl_initialize()
185185
{
186-
// Check the OpenGL version (minimum 2.1 is required)
187-
if( epoxy_gl_version() < 21 )
188-
wxLogMessage( wxS( "OpenGL 2.1 or higher is required!" ) );
186+
const GLenum err = glewInit();
189187

190-
SetOpenGLInfo( (const char*) glGetString( GL_VENDOR ), (const char*) glGetString( GL_RENDERER ),
191-
(const char*) glGetString( GL_VERSION ) );
188+
if( GLEW_OK != err )
189+
{
190+
const wxString msgError = (const char*) glewGetErrorString( err );
192191

193-
wxString version = From_UTF8( (char*) glGetString( GL_VERSION ) );
192+
wxLogMessage( msgError );
193+
}
194+
else
195+
{
196+
wxLogTrace( m_logTrace, wxT( "EDA_3D_MODEL_VIEWER::ogl_initialize Using GLEW version %s" ),
197+
From_UTF8( (char*) glewGetString( GLEW_VERSION ) ) );
198+
}
194199

195-
wxLogTrace( m_logTrace, wxS( "EDA_3D_MODEL_VIEWER::%s OpenGL version string %s." ), __WXFUNCTION__, version );
200+
SetOpenGLInfo( (const char*) glGetString( GL_VENDOR ), (const char*) glGetString( GL_RENDERER ),
201+
(const char*) glGetString( GL_VERSION ) );
196202

197203
glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );
198204
glHint( GL_LINE_SMOOTH_HINT, GL_NICEST );

3d-viewer/3d_rendering/opengl/3d_model.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*/
2929
#include <algorithm>
3030
#include <stdexcept>
31-
#include <gal/opengl/kiepoxy.h> // Must be included first
31+
#include <gal/opengl/kiglew.h> // Must be included first
3232

3333
#include "3d_model.h"
3434
#include "../common_ogl/ogl_utils.h"

3d-viewer/3d_rendering/opengl/render_3d_opengl.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*/
2525

2626
#include <cstdint>
27-
#include <gal/opengl/kiepoxy.h> // Must be included first
27+
#include <gal/opengl/kiglew.h> // Must be included first
2828

2929
#include "plugins/3dapi/xv3d_types.h"
3030
#include "render_3d_opengl.h"

3d-viewer/3d_rendering/raytracing/render_3d_raytrace_gl.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
2424
*/
2525

26-
#include <gal/opengl/kiepoxy.h> // Must be included first
26+
#include <gal/opengl/kiglew.h> // Must be included first
2727

2828
#include <algorithm>
2929
#include <atomic>
@@ -217,7 +217,7 @@ bool RENDER_3D_RAYTRACE_GL::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
217217

218218
void RENDER_3D_RAYTRACE_GL::initPbo()
219219
{
220-
if( epoxy_has_gl_extension( "GL_ARB_pixel_buffer_object" ) )
220+
if( GLEW_ARB_pixel_buffer_object )
221221
{
222222
m_openglSupportsVertexBufferObjects = true;
223223

@@ -238,6 +238,7 @@ void RENDER_3D_RAYTRACE_GL::initPbo()
238238
glBufferDataARB( GL_PIXEL_UNPACK_BUFFER_ARB, m_pboDataSize, 0, GL_STREAM_DRAW_ARB );
239239
glBindBufferARB( GL_PIXEL_UNPACK_BUFFER_ARB, 0 );
240240

241-
wxLogTrace( m_logTrace, wxS( "RENDER_3D_RAYTRACE_GL:: GL_ARB_pixel_buffer_object is supported" ) );
241+
wxLogTrace( m_logTrace,
242+
wxT( "RENDER_3D_RAYTRACE_GL:: GLEW_ARB_pixel_buffer_object is supported" ) );
242243
}
243244
}

3d-viewer/common_ogl/ogl_utils.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*/
2929

3030
#include <stdexcept>
31-
#include <gal/opengl/kiepoxy.h> // Must be included first
31+
#include <gal/opengl/kiglew.h> // Must be included first
3232

3333
#include "openGL_includes.h"
3434
#include "ogl_utils.h"

CMakeLists.txt

+65-41
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,17 @@ option( KICAD_UPDATE_CHECK
115115
"Build in update check"
116116
ON )
117117

118+
# EGL is only needed on Linux with Wayland
119+
cmake_dependent_option( KICAD_USE_EGL
120+
"Build KiCad with EGL backend support for Wayland."
121+
OFF "UNIX_NOT_APPLE"
122+
OFF)
123+
124+
cmake_dependent_option( KICAD_USE_BUNDLED_GLEW
125+
"Use the bundled version of GLEW - only available when KICAD_USE_EGL is set"
126+
ON "KICAD_USE_EGL"
127+
OFF )
128+
118129
cmake_dependent_option( KICAD_WAYLAND
119130
"Support Wayland features"
120131
ON "KICAD_USE_EGL"
@@ -275,6 +286,16 @@ add_compile_definitions( $<$<BOOL:${KICAD_GAL_PROFILE}>:KICAD_GAL_PROFILE> )
275286
add_compile_definitions( $<$<BOOL:${KICAD_WIN32_VERIFY_CODESIGN}>:KICAD_WIN32_VERIFY_CODESIGN> )
276287
add_compile_definitions( $<$<BOOL:${KICAD_UPDATE_CHECK}>:KICAD_UPDATE_CHECK> )
277288

289+
if( KICAD_USE_EGL )
290+
message( STATUS "Configuring KiCad for the wxGLCanvas EGL backend" )
291+
add_compile_definitions( KICAD_USE_EGL )
292+
endif()
293+
294+
if( KICAD_WAYLAND )
295+
message( STATUS "Configuring KiCad to support Wayland features" )
296+
add_compile_definitions( KICAD_WAYLAND )
297+
endif()
298+
278299
if( KICAD_IPC_API )
279300
add_definitions( -DKICAD_IPC_API )
280301
endif()
@@ -734,6 +755,50 @@ if( KICAD_BUILD_I18N )
734755
find_package( Gettext REQUIRED )
735756
endif()
736757

758+
#
759+
# Find OpenGL library, required
760+
#
761+
if( KICAD_USE_EGL )
762+
find_package( OpenGL REQUIRED COMPONENTS OpenGL EGL )
763+
else()
764+
set( OpenGL_GL_PREFERENCE "LEGACY" ) # CMake 3.11+ setting; see 'cmake --help-policy CMP0072'
765+
find_package( OpenGL REQUIRED )
766+
endif()
767+
768+
#
769+
# Find GLEW library, required
770+
#
771+
# The EGL canvas on GTK requires the use of a GLEW version compiled with an EGL flag.
772+
# The one built in the thirdparty directory has the flag for EGL set, so we use it unless told
773+
# otherwise. Then we search for the system GLEW version and use that instead.
774+
#
775+
if( KICAD_USE_EGL AND KICAD_USE_BUNDLED_GLEW AND UNIX AND NOT APPLE )
776+
if( OpenGL_EGL_FOUND )
777+
message( STATUS "Found OpenGL EGL library: ${OPENGL_egl_LIBRARY}" )
778+
else()
779+
message( FATAL_ERROR "OpenGL EGL library not found" )
780+
endif()
781+
782+
# Add the custom GLEW target
783+
add_subdirectory( thirdparty/glew )
784+
785+
# Set the standard package variables to point to our custom target to mimic the system version.
786+
set( GLEW_LIBRARIES glew )
787+
set( GLEW_FOUND TRUE )
788+
include_directories( SYSTEM $<TARGET_PROPERTY:glew,INCLUDE_DIRECTORIES> )
789+
else()
790+
find_package( GLEW REQUIRED )
791+
check_find_package_result( GLEW_FOUND "GLEW" )
792+
include_directories( SYSTEM ${GLEW_INCLUDE_DIR} )
793+
endif()
794+
795+
#
796+
# Find GLM library, required
797+
#
798+
find_package( GLM 0.9.8 REQUIRED )
799+
add_compile_definitions( GLM_FORCE_CTOR_INIT )
800+
include_directories( SYSTEM ${GLM_INCLUDE_DIR} )
801+
737802
#
738803
# Find zlib library, required
739804
#
@@ -1012,8 +1077,6 @@ else()
10121077
message( FATAL_ERROR "Unable to detect wxWidgets port")
10131078
endif()
10141079

1015-
message(STATUS "wxUSE_GLCANVAS_EGL=${wxWidgets_GLCANVAS_EGL}")
1016-
10171080
if( NOT MSVC )
10181081
if( ${wxWidgets_VERSION_STRING} VERSION_LESS 3.2 )
10191082
message( FATAL_ERROR "wxWidgets 3.2.0 or greater is required" )
@@ -1048,45 +1111,6 @@ if( APPLE )
10481111
)
10491112
endif()
10501113

1051-
#
1052-
# Find OpenGL library, required
1053-
#
1054-
if( wxWidgets_GLCANVAS_EGL EQUAL 1 )
1055-
set( KICAD_USE_EGL ON )
1056-
find_package( OpenGL REQUIRED COMPONENTS OpenGL EGL )
1057-
else()
1058-
set( KICAD_USE_EGL OFF )
1059-
set( OpenGL_GL_PREFERENCE "LEGACY" ) # CMake 3.11+ setting; see 'cmake --help-policy CMP0072'
1060-
find_package( OpenGL REQUIRED )
1061-
endif()
1062-
if( NOT OPENGL_GLU_FOUND )
1063-
MESSAGE( FATAL_ERROR "The OpenGL GLU library is required." )
1064-
endif()
1065-
1066-
if( KICAD_USE_EGL )
1067-
message( STATUS "Configuring KiCad for the wxGLCanvas EGL backend" )
1068-
add_compile_definitions( KICAD_USE_EGL )
1069-
endif()
1070-
1071-
if( KICAD_WAYLAND )
1072-
message( STATUS "Configuring KiCad to support Wayland features" )
1073-
add_compile_definitions( KICAD_WAYLAND )
1074-
endif()
1075-
1076-
#
1077-
# Find Epoxy library, required
1078-
#
1079-
find_package( epoxy REQUIRED )
1080-
check_find_package_result( EPOXY_FOUND "epoxy" )
1081-
include_directories( SYSTEM ${epoxy_INCLUDE_DIR} )
1082-
1083-
#
1084-
# Find GLM library, required
1085-
#
1086-
find_package( GLM 0.9.8 REQUIRED )
1087-
add_compile_definitions( GLM_FORCE_CTOR_INIT )
1088-
include_directories( SYSTEM ${GLM_INCLUDE_DIR} )
1089-
10901114

10911115
if( KICAD_USE_SENTRY )
10921116
set( KICAD_SENTRY_DSN "" CACHE STRING "The sentry DSN used with sentry integration" )

LICENSE.README

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ Licensed under MIT:
3535
- sentry-native in thirdparty/sentry-native
3636
- thread-pool in thirdparty/thread-pool
3737
- tinyspline_lib in thirdparty/tinyspline_lib
38+
Licensed under MIT and BSD:
39+
- glew in thirdparty/glew
3840
Licensed under BSD:
3941
- pybind11 in thirdparty/pybind11
4042
Licensed under BSD2:

cmake/FindGLEW.cmake

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2+
# file Copyright.txt or https://cmake.org/licensing for details.
3+
4+
#.rst:
5+
# FindGLEW
6+
# --------
7+
#
8+
# Find the OpenGL Extension Wrangler Library (GLEW)
9+
#
10+
# IMPORTED Targets
11+
# ^^^^^^^^^^^^^^^^
12+
#
13+
# This module defines the :prop_tgt:`IMPORTED` target ``GLEW::GLEW``,
14+
# if GLEW has been found.
15+
#
16+
# Result Variables
17+
# ^^^^^^^^^^^^^^^^
18+
#
19+
# This module defines the following variables:
20+
#
21+
# ::
22+
#
23+
# GLEW_INCLUDE_DIRS - include directories for GLEW
24+
# GLEW_LIBRARIES - libraries to link against GLEW
25+
# GLEW_FOUND - true if GLEW has been found and can be used
26+
27+
find_path(GLEW_INCLUDE_DIR GL/glew.h)
28+
29+
if(NOT GLEW_LIBRARY)
30+
find_library(GLEW_LIBRARY_RELEASE NAMES GLEW glew32 glew glew32s PATH_SUFFIXES lib64)
31+
find_library(GLEW_LIBRARY_DEBUG NAMES GLEWd glew32d glewd PATH_SUFFIXES lib64)
32+
33+
include(SelectLibraryConfigurations)
34+
select_library_configurations(GLEW)
35+
endif ()
36+
37+
include(FindPackageHandleStandardArgs)
38+
find_package_handle_standard_args(GLEW
39+
REQUIRED_VARS GLEW_INCLUDE_DIR GLEW_LIBRARY)
40+
41+
if(GLEW_FOUND)
42+
set(GLEW_INCLUDE_DIRS ${GLEW_INCLUDE_DIR})
43+
44+
if(NOT GLEW_LIBRARIES)
45+
set(GLEW_LIBRARIES ${GLEW_LIBRARY})
46+
endif()
47+
48+
if (NOT TARGET GLEW::GLEW)
49+
add_library(GLEW::GLEW UNKNOWN IMPORTED)
50+
set_target_properties(GLEW::GLEW PROPERTIES
51+
INTERFACE_INCLUDE_DIRECTORIES "${GLEW_INCLUDE_DIRS}")
52+
53+
if(GLEW_LIBRARY_RELEASE)
54+
set_property(TARGET GLEW::GLEW APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
55+
set_target_properties(GLEW::GLEW PROPERTIES IMPORTED_LOCATION_RELEASE "${GLEW_LIBRARY_RELEASE}")
56+
endif()
57+
58+
if(GLEW_LIBRARY_DEBUG)
59+
set_property(TARGET GLEW::GLEW APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
60+
set_target_properties(GLEW::GLEW PROPERTIES IMPORTED_LOCATION_DEBUG "${GLEW_LIBRARY_DEBUG}")
61+
endif()
62+
63+
if(NOT GLEW_LIBRARY_RELEASE AND NOT GLEW_LIBRARY_DEBUG)
64+
set_property(TARGET GLEW::GLEW APPEND PROPERTY IMPORTED_LOCATION "${GLEW_LIBRARY}")
65+
endif()
66+
endif()
67+
endif()
68+
69+
mark_as_advanced(GLEW_INCLUDE_DIR)

0 commit comments

Comments
 (0)