summaryrefslogtreecommitdiff
path: root/platform/linux
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2016-11-11 16:37:44 +0200
committerBruno de Oliveira Abinader <bruno@mapbox.com>2016-11-17 01:01:15 +0100
commitad38ff230b00fdd35dd7eaab79c26f160092af23 (patch)
treeeae0d6fd33f4b98bb1177d6d1424eb44cf0e5e54 /platform/linux
parent0ef52d7f7ceee670e8961e811364d215fde7e980 (diff)
downloadqtlocation-mapboxgl-ad38ff230b00fdd35dd7eaab79c26f160092af23.tar.gz
[linux] Ensure EGL uses OpenGL ES 2.0 client API
Diffstat (limited to 'platform/linux')
-rw-r--r--platform/linux/src/headless_backend_egl.cpp15
-rw-r--r--platform/linux/src/headless_display_egl.cpp6
2 files changed, 16 insertions, 5 deletions
diff --git a/platform/linux/src/headless_backend_egl.cpp b/platform/linux/src/headless_backend_egl.cpp
index 5c68976ada..0fb33ea0e0 100644
--- a/platform/linux/src/headless_backend_egl.cpp
+++ b/platform/linux/src/headless_backend_egl.cpp
@@ -58,11 +58,16 @@ void HeadlessBackend::createContext() {
EGLDisplay display_ = display->attribute<EGLDisplay>();
EGLConfig& config = display->attribute<EGLConfig&>();
- if (!eglBindAPI(EGL_OPENGL_API)) {
- throw std::runtime_error("Error setting the EGL rendering API.\n");
- }
-
- EGLContext glContext = eglCreateContext(display_, config, EGL_NO_CONTEXT, NULL);
+ // EGL initializes the context client version to 1 by default. We want to
+ // use OpenGL ES 2.0 which has the ability to create shader and program
+ // objects and also to write vertex and fragment shaders in the OpenGL ES
+ // Shading Language.
+ const EGLint attribs[] = {
+ EGL_CONTEXT_CLIENT_VERSION, 2,
+ EGL_NONE
+ };
+
+ EGLContext glContext = eglCreateContext(display_, config, EGL_NO_CONTEXT, attribs);
if (glContext == EGL_NO_CONTEXT) {
mbgl::Log::Error(mbgl::Event::OpenGL, "eglCreateContext() returned error 0x%04x",
eglGetError());
diff --git a/platform/linux/src/headless_display_egl.cpp b/platform/linux/src/headless_display_egl.cpp
index 2c0481ddd1..4be519cfcd 100644
--- a/platform/linux/src/headless_display_egl.cpp
+++ b/platform/linux/src/headless_display_egl.cpp
@@ -1,4 +1,5 @@
#include <mbgl/platform/default/headless_display.hpp>
+#include <mbgl/platform/log.hpp>
#include <mbgl/util/string.hpp>
#include <EGL/egl.h>
@@ -25,6 +26,11 @@ HeadlessDisplay::Impl::Impl() {
throw std::runtime_error("eglInitialize() failed.\n");
}
+ 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");
+ }
+
// This shouldn't matter as we're rendering to a framebuffer.
const EGLint attribs[] = { EGL_NONE };
if (!eglChooseConfig(display, attribs, &config, 1, &numConfigs) || numConfigs != 1) {