summaryrefslogtreecommitdiff
path: root/platform/qt
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2017-02-27 18:33:16 +0100
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-03-23 14:50:11 -0700
commit234384ece9c70f2a803ed2b1d1eb55b248ec43d1 (patch)
treea69fa3e64179667d79546f4f3d1b33f041e4ea22 /platform/qt
parent8e5214144ec4f3a4fb40b7a7e4d8f09fd10dbb78 (diff)
downloadqtlocation-mapboxgl-234384ece9c70f2a803ed2b1d1eb55b248ec43d1.tar.gz
[core] Move OpenGL extension initialization to Backend
Diffstat (limited to 'platform/qt')
-rw-r--r--platform/qt/app/mapwindow.cpp2
-rw-r--r--platform/qt/include/qmapbox.hpp2
-rw-r--r--platform/qt/src/qmapbox.cpp23
-rw-r--r--platform/qt/src/qmapboxgl.cpp14
-rw-r--r--platform/qt/src/qmapboxgl_p.hpp3
-rw-r--r--platform/qt/test/headless_backend_qt.cpp4
-rw-r--r--platform/qt/test/qmapboxgl.cpp2
7 files changed, 19 insertions, 31 deletions
diff --git a/platform/qt/app/mapwindow.cpp b/platform/qt/app/mapwindow.cpp
index 926d504904..345c5196ba 100644
--- a/platform/qt/app/mapwindow.cpp
+++ b/platform/qt/app/mapwindow.cpp
@@ -372,8 +372,6 @@ void MapWindow::wheelEvent(QWheelEvent *ev)
void MapWindow::initializeGL()
{
- QMapbox::initializeGLExtensions();
-
m_map.reset(new QMapboxGL(nullptr, m_settings, size(), pixelRatio()));
connect(m_map.data(), SIGNAL(needsRendering()), this, SLOT(update()));
diff --git a/platform/qt/include/qmapbox.hpp b/platform/qt/include/qmapbox.hpp
index f2d96412a9..e69b37108d 100644
--- a/platform/qt/include/qmapbox.hpp
+++ b/platform/qt/include/qmapbox.hpp
@@ -97,8 +97,6 @@ typedef void (*CustomLayerInitializeFunction)(void* context) ;
typedef void (*CustomLayerRenderFunction)(void* context, const CustomLayerRenderParameters&);
typedef void (*CustomLayerDeinitializeFunction)(void* context);
-Q_DECL_EXPORT void initializeGLExtensions();
-
} // namespace QMapbox
Q_DECLARE_METATYPE(QMapbox::Coordinate);
diff --git a/platform/qt/src/qmapbox.cpp b/platform/qt/src/qmapbox.cpp
index 126ece1efa..410e114690 100644
--- a/platform/qt/src/qmapbox.cpp
+++ b/platform/qt/src/qmapbox.cpp
@@ -1,6 +1,5 @@
#include "qmapbox.hpp"
-#include <mbgl/gl/extension.hpp>
#include <mbgl/storage/network_status.hpp>
#include <mbgl/util/default_styles.hpp>
#include <mbgl/util/geometry.hpp>
@@ -255,26 +254,4 @@ Q_DECL_EXPORT QList<QPair<QString, QString> >& defaultStyles()
return styles;
}
-/*!
- \fn void QMapbox::initializeGLExtensions()
-
- Initializes the OpenGL extensions such as Vertex Array Objects (VAOs),
- required by Mapbox GL Native engine.
-
- Should be called only once, after an OpenGL context is available.
- Consecutive calls are ignored.
-*/
-Q_DECL_EXPORT void initializeGLExtensions()
-{
- mbgl::gl::InitializeExtensions([](const char* name) {
-#if QT_VERSION >= 0x050000
- QOpenGLContext* thisContext = QOpenGLContext::currentContext();
- return thisContext->getProcAddress(name);
-#else
- const QGLContext* thisContext = QGLContext::currentContext();
- return reinterpret_cast<mbgl::gl::glProc>(thisContext->getProcAddress(name));
-#endif
- });
-}
-
} // namespace QMapbox
diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp
index 384bdc8ebf..5776502a5b 100644
--- a/platform/qt/src/qmapboxgl.cpp
+++ b/platform/qt/src/qmapboxgl.cpp
@@ -1678,6 +1678,20 @@ void QMapboxGLPrivate::onSourceChanged(mbgl::style::Source&)
emit mapChanged(QMapboxGL::MapChangeSourceDidChange);
}
+/*!
+ Initializes an OpenGL extension function such as Vertex Array Objects (VAOs),
+ required by Mapbox GL Native engine.
+*/
+mbgl::gl::ProcAddress QMapboxGLPrivate::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<mbgl::gl::ProcAddress>(thisContext->getProcAddress(name));
+#endif
+}
+
void QMapboxGLPrivate::connectionEstablished()
{
mbgl::NetworkStatus::Reachable();
diff --git a/platform/qt/src/qmapboxgl_p.hpp b/platform/qt/src/qmapboxgl_p.hpp
index 4112542431..464b66bd73 100644
--- a/platform/qt/src/qmapboxgl_p.hpp
+++ b/platform/qt/src/qmapboxgl_p.hpp
@@ -58,6 +58,9 @@ public:
bool dirty { false };
+private:
+ mbgl::gl::ProcAddress initializeExtension(const char*) override;
+
public slots:
void connectionEstablished();
diff --git a/platform/qt/test/headless_backend_qt.cpp b/platform/qt/test/headless_backend_qt.cpp
index 401ce55a7f..5f95b2f96a 100644
--- a/platform/qt/test/headless_backend_qt.cpp
+++ b/platform/qt/test/headless_backend_qt.cpp
@@ -24,13 +24,13 @@ struct QtImpl : public HeadlessBackend::Impl {
QGLWidget widget;
};
-gl::glProc HeadlessBackend::initializeExtension(const char* name) {
+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<mbgl::gl::glProc>(thisContext->getProcAddress(name));
+ return reinterpret_cast<gl::ProcAddress>(thisContext->getProcAddress(name));
#endif
}
diff --git a/platform/qt/test/qmapboxgl.cpp b/platform/qt/test/qmapboxgl.cpp
index 650c635b99..453604076e 100644
--- a/platform/qt/test/qmapboxgl.cpp
+++ b/platform/qt/test/qmapboxgl.cpp
@@ -20,8 +20,6 @@ public:
this, SLOT(onMapChanged(QMapboxGL::MapChange)));
connect(&map, SIGNAL(needsRendering()),
this, SLOT(onNeedsRendering()));
- QMapbox::initializeGLExtensions();
-
map.resize(fbo.size(), fbo.size());
map.setFramebufferObject(fbo.handle());
map.setCoordinateZoom(QMapbox::Coordinate(60.170448, 24.942046), 14);