summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2014-10-24 17:39:18 +0200
committerKonstantin Käfer <mail@kkaefer.com>2014-10-24 17:44:51 +0200
commit0e928b5204ad5e2a8cfc1dd1a993396be0bd9d87 (patch)
tree1eca3f4f0446c07c38d93049d48a6272b2c989d6 /platform
parentd299e580886353e0813d30f9dee74639f899924a (diff)
downloadqtlocation-mapboxgl-0e928b5204ad5e2a8cfc1dd1a993396be0bd9d87.tar.gz
make tests work
Diffstat (limited to 'platform')
-rw-r--r--platform/darwin/log_nslog.mm2
-rw-r--r--platform/default/headless_display.cpp74
-rw-r--r--platform/default/headless_view.cpp4
3 files changed, 77 insertions, 3 deletions
diff --git a/platform/darwin/log_nslog.mm b/platform/darwin/log_nslog.mm
index 231037b2dd..b196930b23 100644
--- a/platform/darwin/log_nslog.mm
+++ b/platform/darwin/log_nslog.mm
@@ -1,4 +1,4 @@
-#include "log_nslog.hpp"
+#include <mbgl/platform/darwin/log_nslog.hpp>
#import <Foundation/Foundation.h>
diff --git a/platform/default/headless_display.cpp b/platform/default/headless_display.cpp
new file mode 100644
index 0000000000..409fcbf057
--- /dev/null
+++ b/platform/default/headless_display.cpp
@@ -0,0 +1,74 @@
+#include <mbgl/platform/default/headless_display.hpp>
+
+#include <cstring>
+#include <stdexcept>
+
+namespace mbgl {
+
+HeadlessDisplay::HeadlessDisplay() {
+#if MBGL_USE_CGL
+ // TODO: test if OpenGL 4.1 with GL_ARB_ES2_compatibility is supported
+ // If it is, use kCGLOGLPVersion_3_2_Core and enable that extension.
+ CGLPixelFormatAttribute attributes[] = {
+ kCGLPFAOpenGLProfile,
+ (CGLPixelFormatAttribute) kCGLOGLPVersion_Legacy,
+ kCGLPFAAccelerated,
+ (CGLPixelFormatAttribute) 0
+ };
+
+ GLint num;
+ CGLError error = CGLChoosePixelFormat(attributes, &pixelFormat, &num);
+ if (error) {
+ fprintf(stderr, "Error pixel format: %s\n", CGLErrorString(error));
+ return;
+ }
+#endif
+
+#if MBGL_USE_GLX
+ if (!XInitThreads()) {
+ throw std::runtime_error("Failed to XInitThreads");
+ }
+
+ x_display = XOpenDisplay(nullptr);
+ if (x_display == nullptr) {
+ throw std::runtime_error("Failed to open X display");
+ }
+
+ const char *extensions = (char *)glXQueryServerString(x_display, DefaultScreen(x_display), GLX_EXTENSIONS);
+ if (!extensions) {
+ throw std::runtime_error("Cannot read GLX extensions");
+ }
+ if (!strstr(extensions,"GLX_SGIX_fbconfig")) {
+ throw std::runtime_error("Extension GLX_SGIX_fbconfig was not found");
+ }
+ if (!strstr(extensions, "GLX_SGIX_pbuffer")) {
+ throw std::runtime_error("Cannot find glXCreateContextAttribsARB");
+ }
+
+ // We're creating a dummy pbuffer anyway that we're not using.
+ static int pixelFormat[] = {
+ GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT,
+ None
+ };
+
+ int configs = 0;
+ fb_configs = glXChooseFBConfig(x_display, DefaultScreen(x_display), pixelFormat, &configs);
+ if (configs <= 0) {
+ throw std::runtime_error("No Framebuffer configurations");
+ }
+#endif
+}
+
+HeadlessDisplay::~HeadlessDisplay() {
+#if MBGL_USE_CGL
+ CGLDestroyPixelFormat(pixelFormat);
+#endif
+
+#if MBGL_USE_GLX
+ XFree(fb_configs);
+ XCloseDisplay(x_display);
+#endif
+}
+
+}
+
diff --git a/platform/default/headless_view.cpp b/platform/default/headless_view.cpp
index d1d13db5f8..ec5c4aabec 100644
--- a/platform/default/headless_view.cpp
+++ b/platform/default/headless_view.cpp
@@ -1,5 +1,5 @@
-#include "headless_view.hpp"
-#include "headless_display.hpp"
+#include <mbgl/platform/default/headless_view.hpp>
+#include <mbgl/platform/default/headless_display.hpp>
#include <stdexcept>
#include <sstream>