From c0d76c69cc6f3abbc2be44c79f387bab114a0875 Mon Sep 17 00:00:00 2001 From: Nathan Gass Date: Thu, 19 Aug 2021 20:57:56 +0200 Subject: [PATCH] Egl option (#135) * minimal changes to get platform linux to compile again * adapt mbgl-glfw api for keyss to mbgl-offline and mbgl-render, use maptiler configuration for all three binaries * add an option to compile with the egl backend on linux --- CMakeLists.txt | 1 + platform/glfw/CMakeLists.txt | 7 +++++++ platform/linux/linux.cmake | 29 ++++++++++++++++++++++++++--- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d2708d82..b60baf530 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,7 @@ option(MBGL_WITH_QT "Build Mapbox GL Qt bindings" OFF) option(MBGL_WITH_SANITIZER "Use [address|thread|undefined] here" OFF) option(MBGL_WITH_RTTI "Compile with runtime type information" OFF) option(MBGL_WITH_OPENGL "Build with OpenGL renderer" ON) +option(MBGL_WITH_EGL "Build with EGL renderer" OFF) option(MBGL_WITH_WERROR "Make all compilation warnings errors" ON) add_library( diff --git a/platform/glfw/CMakeLists.txt b/platform/glfw/CMakeLists.txt index 986d3b013..d2eeac925 100644 --- a/platform/glfw/CMakeLists.txt +++ b/platform/glfw/CMakeLists.txt @@ -29,6 +29,13 @@ if(MBGL_WITH_OPENGL) ) endif() +if(MBGL_WITH_EGL) + target_compile_definitions( + mbgl-glfw + PRIVATE MBGL_WITH_EGL=1 + ) +endif() + target_include_directories( mbgl-glfw PRIVATE diff --git a/platform/linux/linux.cmake b/platform/linux/linux.cmake index e78274270..ca34943ba 100644 --- a/platform/linux/linux.cmake +++ b/platform/linux/linux.cmake @@ -2,7 +2,6 @@ find_package(CURL REQUIRED) find_package(ICU OPTIONAL_COMPONENTS i18n) find_package(ICU OPTIONAL_COMPONENTS uc) find_package(JPEG REQUIRED) -find_package(OpenGL REQUIRED GLX) find_package(PNG REQUIRED) find_package(PkgConfig REQUIRED) find_package(X11 REQUIRED) @@ -50,9 +49,34 @@ target_sources( ${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/util/timer.cpp ${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/util/utf.cpp ${PROJECT_SOURCE_DIR}/platform/linux/src/gl_functions.cpp - ${PROJECT_SOURCE_DIR}/platform/linux/src/headless_backend_glx.cpp ) +if(MBGL_WITH_EGL) + find_package(OpenGL REQUIRED EGL) + target_sources( + mbgl-core + PRIVATE + ${PROJECT_SOURCE_DIR}/platform/linux/src/headless_backend_egl.cpp + ) + target_link_libraries( + mbgl-core + PRIVATE + OpenGL::EGL + ) +else() + find_package(OpenGL REQUIRED GLX) + target_sources( + mbgl-core + PRIVATE + ${PROJECT_SOURCE_DIR}/platform/linux/src/headless_backend_glx.cpp + ) + target_link_libraries( + mbgl-core + PRIVATE + OpenGL::GLX + ) +endif() + # FIXME: Should not be needed, but now needed by node because of the headless frontend. target_include_directories( mbgl-core @@ -91,7 +115,6 @@ target_link_libraries( $<$>:ICU::i18n> $<$>:ICU::uc> $<$:mbgl-vendor-icu> - OpenGL::GLX PNG::PNG mbgl-vendor-nunicode mbgl-vendor-sqlite