summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2017-11-20 22:39:52 +0100
committerKonstantin Käfer <mail@kkaefer.com>2018-06-11 15:18:32 +0200
commitea22106feda0e310f1317812306650db10ecec18 (patch)
tree9d20064b91b1e85e7a9851562bda7fe482827112
parentcdda739facf650dac5267d86b98903c4ba1d02ed (diff)
downloadqtlocation-mapboxgl-ea22106feda0e310f1317812306650db10ecec18.tar.gz
[build] allow WITH_EGL for macOS as well (SwiftShader) and enable EGL for GLFW
-rw-r--r--CMakeLists.txt10
-rw-r--r--Makefile4
-rw-r--r--platform/android/config.cmake3
-rw-r--r--platform/darwin/mbgl/gl/gl_impl.hpp12
-rw-r--r--platform/glfw/glfw_view.cpp10
-rw-r--r--platform/ios/config.cmake2
-rw-r--r--platform/macos/config.cmake19
7 files changed, 49 insertions, 11 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 46aea73356..7098eb0137 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -25,7 +25,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})
@@ -137,6 +137,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()
diff --git a/Makefile b/Makefile
index 5c521d674a..6f56c7b780 100644
--- a/Makefile
+++ b/Makefile
@@ -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)"
@@ -171,6 +172,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/platform/android/config.cmake b/platform/android/config.cmake
index 77074dc82c..9ecc275406 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/test-files.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 3988419265..068f33f8ee 100644
--- a/platform/glfw/glfw_view.cpp
+++ b/platform/glfw/glfw_view.cpp
@@ -53,13 +53,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);
@@ -660,7 +666,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 1caf372b25..f6f12766af 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)
mason_use(icu VERSION 58.1-min-size)
diff --git a/platform/macos/config.cmake b/platform/macos/config.cmake
index e929bb55c6..16a9943d7b 100644
--- a/platform/macos/config.cmake
+++ b/platform/macos/config.cmake
@@ -33,7 +33,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
@@ -46,6 +45,23 @@ 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
+ PRIVATE platform/linux/src/headless_display_egl.cpp
+ )
+ mason_use(swiftshader VERSION 2017-11-20)
+ target_add_mason_package(mbgl-core PUBLIC swiftshader)
+ else()
+ target_sources(mbgl-core
+ PRIVATE platform/darwin/src/headless_backend_cgl.cpp
+ PRIVATE platform/darwin/src/headless_display_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)
@@ -64,7 +80,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"