summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2016-11-14 15:18:17 +0100
committerBruno de Oliveira Abinader <bruno@mapbox.com>2016-11-14 17:45:22 +0100
commit1c79147a84fe9f852fa21bcf5629f490e8e2a8bf (patch)
treea11692a0db46908562c05eb20d2c17c79614d046 /platform
parent52da0e6d314db579c4aa040bcd3e68b539d7e24c (diff)
downloadqtlocation-mapboxgl-1c79147a84fe9f852fa21bcf5629f490e8e2a8bf.tar.gz
[android] Update GLSL + ensure binding to OpenGL ES 2.0
Diffstat (limited to 'platform')
-rwxr-xr-xplatform/android/src/native_map_view.cpp46
-rwxr-xr-xplatform/android/src/native_map_view.hpp2
2 files changed, 28 insertions, 20 deletions
diff --git a/platform/android/src/native_map_view.cpp b/platform/android/src/native_map_view.cpp
index f570f7e68e..984fe9d382 100755
--- a/platform/android/src/native_map_view.cpp
+++ b/platform/android/src/native_map_view.cpp
@@ -222,13 +222,6 @@ mbgl::Map &NativeMapView::getMap() { return *map; }
mbgl::DefaultFileSource &NativeMapView::getFileSource() { return *fileSource; }
-bool NativeMapView::inEmulator() {
- // Detect if we are in emulator
- char prop[PROP_VALUE_MAX];
- __system_property_get("ro.kernel.qemu", prop);
- return strtol(prop, nullptr, 0) == 1;
-}
-
void NativeMapView::initializeDisplay() {
mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::initializeDisplay");
@@ -258,22 +251,39 @@ void NativeMapView::initializeDisplay() {
log_egl_string(display, EGL_CLIENT_APIS, "Client APIs");
log_egl_string(display, EGL_EXTENSIONS, "Client Extensions");
- // Detect if we are in emulator
- if (inEmulator()) {
+ // Detect if we are in emulator.
+ const bool inEmulator = []() {
+ char prop[PROP_VALUE_MAX];
+ __system_property_get("ro.kernel.qemu", prop);
+ return strtol(prop, nullptr, 0) == 1;
+ }();
+
+ if (inEmulator) {
+ // XXX https://code.google.com/p/android/issues/detail?id=78977
mbgl::Log::Warning(mbgl::Event::Android, "In emulator! Enabling hacks :-(");
}
+ if (!eglBindAPI(EGL_OPENGL_ES_API)) {
+ mbgl::Log::Error(mbgl::Event::OpenGL, "eglBindAPI(EGL_OPENGL_ES_API) returned error %d", eglGetError());
+ throw std::runtime_error("eglBindAPI() failed");
+ }
+
// Get all configs at least RGB 565 with 16 depth and 8 stencil
EGLint configAttribs[] = {
- EGL_CONFIG_CAVEAT, EGL_NONE, EGL_RENDERABLE_TYPE,
- EGL_OPENGL_ES2_BIT, EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
- EGL_BUFFER_SIZE, 16, EGL_RED_SIZE,
- 5, EGL_GREEN_SIZE, 6,
- EGL_BLUE_SIZE, 5, EGL_DEPTH_SIZE,
- 16, EGL_STENCIL_SIZE, 8,
- (inEmulator() ? EGL_NONE : EGL_CONFORMANT), EGL_OPENGL_ES2_BIT, // Ugly hack
- (inEmulator() ? EGL_NONE : EGL_COLOR_BUFFER_TYPE), EGL_RGB_BUFFER, // Ugly hack
- EGL_NONE};
+ EGL_CONFIG_CAVEAT, EGL_NONE,
+ EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
+ EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
+ EGL_BUFFER_SIZE, 16,
+ EGL_RED_SIZE, 5,
+ EGL_GREEN_SIZE, 6,
+ EGL_BLUE_SIZE, 5,
+ EGL_DEPTH_SIZE, 16,
+ EGL_STENCIL_SIZE, 8,
+ (inEmulator ? EGL_NONE : EGL_CONFORMANT), EGL_OPENGL_ES2_BIT,
+ (inEmulator ? EGL_NONE : EGL_COLOR_BUFFER_TYPE), EGL_RGB_BUFFER,
+ EGL_NONE
+ };
+
EGLint numConfigs;
if (!eglChooseConfig(display, configAttribs, nullptr, 0, &numConfigs)) {
mbgl::Log::Error(mbgl::Event::OpenGL, "eglChooseConfig(NULL) returned error %d",
diff --git a/platform/android/src/native_map_view.hpp b/platform/android/src/native_map_view.hpp
index 18f9ebc144..14b9842c72 100755
--- a/platform/android/src/native_map_view.hpp
+++ b/platform/android/src/native_map_view.hpp
@@ -57,8 +57,6 @@ public:
private:
EGLConfig chooseConfig(const EGLConfig configs[], EGLint numConfigs);
- bool inEmulator();
-
private:
JavaVM *vm = nullptr;
JNIEnv *env = nullptr;