diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2017-09-25 21:35:04 +0200 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2017-09-28 13:48:36 -0400 |
commit | 64c75b442c4d387e4867757abf49462c561e5955 (patch) | |
tree | 63f572961f6309a851d2e85ebe191e6a3cb7e5ab /platform/qt/src | |
parent | d73e33eb62858b91212314d97bfe9cf49e857141 (diff) | |
download | qtlocation-mapboxgl-64c75b442c4d387e4867757abf49462c561e5955.tar.gz |
[build] split out DefaultFileSource and dependents to a separate target
We don't want to link it into the node bindings, so keep it in a separate target
Diffstat (limited to 'platform/qt/src')
-rw-r--r-- | platform/qt/src/headless_backend_qt.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/platform/qt/src/headless_backend_qt.cpp b/platform/qt/src/headless_backend_qt.cpp new file mode 100644 index 0000000000..5f95b2f96a --- /dev/null +++ b/platform/qt/src/headless_backend_qt.cpp @@ -0,0 +1,46 @@ +#include <mbgl/gl/headless_backend.hpp> + +#include <QGLWidget> + +#if QT_VERSION >= 0x050000 +#include <QOpenGLContext> +#else +#include <QGLContext> +#endif + +#include <cassert> + +namespace mbgl { + +struct QtImpl : public HeadlessBackend::Impl { + void activateContext() final { + widget.makeCurrent(); + } + + void deactivateContext() final { + widget.doneCurrent(); + } + + QGLWidget widget; +}; + +gl::ProcAddress HeadlessBackend::initializeExtension(const char* name) { +#if QT_VERSION >= 0x050000 + QOpenGLContext* thisContext = QOpenGLContext::currentContext(); + return thisContext->getProcAddress(name); +#else + const QGLContext* thisContext = QGLContext::currentContext(); + return reinterpret_cast<gl::ProcAddress>(thisContext->getProcAddress(name)); +#endif +} + +bool HeadlessBackend::hasDisplay() { + return true; +}; + +void HeadlessBackend::createContext() { + assert(!hasContext()); + impl.reset(new QtImpl); +} + +} // namespace mbgl |