diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2017-11-20 22:39:52 +0100 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2018-08-27 14:07:40 -0700 |
commit | 1e454642c8bc99698d25105fe0034916e2930fe6 (patch) | |
tree | 3d9b60c1366033c97dfe51d4285d6bf3edf992ed | |
parent | fd1ed8ce48fc9eaf6793e852381d8c7e648386af (diff) | |
download | qtlocation-mapboxgl-1e454642c8bc99698d25105fe0034916e2930fe6.tar.gz |
[build] allow WITH_EGL for macOS as well (SwiftShader) and enable EGL for GLFW
-rw-r--r-- | CMakeLists.txt | 10 | ||||
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | cmake/mason-dependencies.cmake | 6 | ||||
-rw-r--r-- | cmake/mbgl.cmake | 2 | ||||
-rw-r--r-- | platform/android/config.cmake | 3 | ||||
-rw-r--r-- | platform/darwin/mbgl/gl/gl_impl.hpp | 12 | ||||
-rw-r--r-- | platform/glfw/glfw_view.cpp | 10 | ||||
-rw-r--r-- | platform/ios/config.cmake | 2 | ||||
-rw-r--r-- | platform/macos/config.cmake | 16 |
9 files changed, 52 insertions, 13 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index b007b541b7..98d6676ef1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ if(WITH_OSMESA AND WITH_EGL) endif() if(WITH_EGL) - add_definitions(-DMBGL_USE_GLES2=1) + set(USE_GLES2 ON) endif() if($ENV{CI}) @@ -144,6 +144,14 @@ endif() include(platform/${MBGL_PLATFORM}/config.cmake) +if(WITH_EGL) + add_definitions(-DMBGL_WITH_EGL=1) +endif() + +if(USE_GLES2) + add_definitions(-DMBGL_USE_GLES2=1) +endif() + if (COMMAND mbgl_filesource) include(cmake/filesource.cmake) endif() @@ -74,7 +74,8 @@ MACOS_XCODEBUILD = xcodebuild \ $(MACOS_PROJ_PATH): $(BUILD_DEPS) $(MACOS_USER_DATA_PATH)/WorkspaceSettings.xcsettings mkdir -p $(MACOS_OUTPUT_PATH) - (cd $(MACOS_OUTPUT_PATH) && cmake -G Xcode ../..) + (cd $(MACOS_OUTPUT_PATH) && cmake -G Xcode ../.. \ + -DWITH_EGL=${WITH_EGL}) $(MACOS_USER_DATA_PATH)/WorkspaceSettings.xcsettings: platform/macos/WorkspaceSettings.xcsettings mkdir -p "$(MACOS_USER_DATA_PATH)" @@ -174,6 +175,7 @@ $(MACOS_COMPDB_PATH)/Makefile: mkdir -p $(MACOS_COMPDB_PATH) (cd $(MACOS_COMPDB_PATH) && cmake ../../../.. \ -DCMAKE_BUILD_TYPE=$(BUILDTYPE) \ + -DWITH_EGL=${WITH_EGL} \ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON) .PHONY: diff --git a/cmake/mason-dependencies.cmake b/cmake/mason-dependencies.cmake index 826dcf2e45..4a886bef21 100644 --- a/cmake/mason-dependencies.cmake +++ b/cmake/mason-dependencies.cmake @@ -36,13 +36,17 @@ elseif(MBGL_PLATFORM STREQUAL "linux") mason_use(args VERSION 6.2.0 HEADER_ONLY) if(WITH_EGL) - mason_use(swiftshader VERSION 2017-11-20) + mason_use(swiftshader VERSION 2018-05-31) endif() elseif(MBGL_PLATFORM STREQUAL "macos") mason_use(glfw VERSION 2018-06-27-0be4f3f) mason_use(benchmark VERSION 1.4.1) mason_use(icu VERSION 58.1-min-size) mason_use(args VERSION 6.2.0 HEADER_ONLY) + + if(WITH_EGL) + mason_use(swiftshader VERSION 2018-05-31) + endif() elseif(MBGL_PLATFORM STREQUAL "qt") mason_use(optional VERSION f27e7908 HEADER_ONLY) mason_use(tao_tuple VERSION 28626e99 HEADER_ONLY) diff --git a/cmake/mbgl.cmake b/cmake/mbgl.cmake index fdb435ccca..da020cc93f 100644 --- a/cmake/mbgl.cmake +++ b/cmake/mbgl.cmake @@ -174,7 +174,7 @@ function(set_xcconfig_target_properties target) list(APPEND link_flags ${item}) endif() endforeach() - string(REPLACE ";-framework " ";-framework;" link_flags "${link_flags}") + string(REGEX REPLACE "(^|;)-framework " "\\1-framework;" link_flags "${link_flags}") string(REPLACE ";" "\" \"" link_flags "${link_flags}") set_xcode_property(${target} XCCONFIG_LINK_LIBRARIES "${link_flags}") endfunction() diff --git a/platform/android/config.cmake b/platform/android/config.cmake index a0143aee9d..714d566bd8 100644 --- a/platform/android/config.cmake +++ b/platform/android/config.cmake @@ -1,4 +1,5 @@ -add_definitions(-DMBGL_USE_GLES2=1) +set(USE_GLES2 ON) + include(cmake/nunicode.cmake) # Build thin archives. diff --git a/platform/darwin/mbgl/gl/gl_impl.hpp b/platform/darwin/mbgl/gl/gl_impl.hpp index b4c062a474..0db125c7b4 100644 --- a/platform/darwin/mbgl/gl/gl_impl.hpp +++ b/platform/darwin/mbgl/gl/gl_impl.hpp @@ -8,9 +8,15 @@ #include <OpenGLES/ES2/gl.h> #include <OpenGLES/ES2/glext.h> #elif TARGET_OS_MAC - #include <OpenGL/OpenGL.h> - #include <OpenGL/gl.h> - #include <OpenGL/glext.h> + #if MBGL_USE_GLES2 + #define GL_GLEXT_PROTOTYPES + #include <GLES2/gl2.h> + #include <GLES2/gl2ext.h> + #else + #include <OpenGL/OpenGL.h> + #include <OpenGL/gl.h> + #include <OpenGL/glext.h> + #endif #else #error Unsupported Apple platform #endif diff --git a/platform/glfw/glfw_view.cpp b/platform/glfw/glfw_view.cpp index f1cbdbbaeb..9179113139 100644 --- a/platform/glfw/glfw_view.cpp +++ b/platform/glfw/glfw_view.cpp @@ -54,13 +54,19 @@ GLFWView::GLFWView(bool fullscreen_, bool benchmark_) height = videoMode->height; } +#if __APPLE__ glfwWindowHint(GLFW_COCOA_GRAPHICS_SWITCHING, GL_TRUE); +#endif + +#if MBGL_WITH_EGL + glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API); +#endif #ifdef DEBUG glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE); #endif -#ifdef GL_ES_VERSION_2_0 +#if MBGL_USE_GLES2 glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); @@ -652,7 +658,7 @@ void GLFWView::toggle3DExtrusions(bool visible) { namespace mbgl { namespace platform { -#ifndef GL_ES_VERSION_2_0 +#ifndef MBGL_USE_GLES2 void showDebugImage(std::string name, const char *data, size_t width, size_t height) { glfwInit(); diff --git a/platform/ios/config.cmake b/platform/ios/config.cmake index 48bb27a696..6bed436f64 100644 --- a/platform/ios/config.cmake +++ b/platform/ios/config.cmake @@ -1,4 +1,4 @@ -add_definitions(-DMBGL_USE_GLES2=1) +set(USE_GLES2 ON) macro(initialize_ios_target target) set_xcode_property(${target} IPHONEOS_DEPLOYMENT_TARGET "9.0") diff --git a/platform/macos/config.cmake b/platform/macos/config.cmake index d53f61f3b3..f164b8491e 100644 --- a/platform/macos/config.cmake +++ b/platform/macos/config.cmake @@ -27,7 +27,6 @@ macro(mbgl_platform_core) PRIVATE platform/default/mbgl/gl/headless_frontend.hpp PRIVATE platform/default/mbgl/gl/headless_backend.cpp PRIVATE platform/default/mbgl/gl/headless_backend.hpp - PRIVATE platform/darwin/src/headless_backend_cgl.cpp # Snapshotting PRIVATE platform/default/mbgl/map/map_snapshotter.cpp @@ -40,6 +39,20 @@ macro(mbgl_platform_core) PRIVATE platform/default/mbgl/util/default_thread_pool.cpp ) + if(WITH_EGL) + target_sources(mbgl-core + PRIVATE platform/linux/src/headless_backend_egl.cpp + ) + target_add_mason_package(mbgl-core PUBLIC swiftshader) + else() + target_sources(mbgl-core + PRIVATE platform/darwin/src/headless_backend_cgl.cpp + ) + target_link_libraries(mbgl-core + PUBLIC "-framework OpenGL" + ) + endif() + target_add_mason_package(mbgl-core PUBLIC geojson) target_add_mason_package(mbgl-core PUBLIC polylabel) target_add_mason_package(mbgl-core PRIVATE icu) @@ -58,7 +71,6 @@ macro(mbgl_platform_core) PUBLIC "-framework Foundation" PUBLIC "-framework CoreText" PUBLIC "-framework CoreGraphics" - PUBLIC "-framework OpenGL" PUBLIC "-framework ImageIO" PUBLIC "-framework CoreServices" PUBLIC "-framework SystemConfiguration" |