summaryrefslogtreecommitdiff
path: root/platform/qt/test/qmapboxgl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'platform/qt/test/qmapboxgl.cpp')
-rw-r--r--platform/qt/test/qmapboxgl.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/platform/qt/test/qmapboxgl.cpp b/platform/qt/test/qmapboxgl.cpp
index 8b88a4f6f6..650c635b99 100644
--- a/platform/qt/test/qmapboxgl.cpp
+++ b/platform/qt/test/qmapboxgl.cpp
@@ -2,24 +2,28 @@
#include <mbgl/util/io.hpp>
#include <QApplication>
-#include <QGLWidget>
#include <QMapbox>
#include <QMapboxGL>
+// We're using QGLFramebufferObject, which is only available in Qt 5 and up.
+#if QT_VERSION >= 0x050000
+
+#include <QGLWidget>
+#include <QGLFramebufferObject>
+
class QMapboxGLTest : public QObject, public ::testing::Test {
Q_OBJECT
public:
- QMapboxGLTest() : map(nullptr, settings) {
+ QMapboxGLTest() : fbo((assert(widget.context()->isValid()), widget.makeCurrent(), QSize(512, 512))), map(nullptr, settings) {
connect(&map, SIGNAL(mapChanged(QMapboxGL::MapChange)),
this, SLOT(onMapChanged(QMapboxGL::MapChange)));
connect(&map, SIGNAL(needsRendering()),
this, SLOT(onNeedsRendering()));
-
- widget.makeCurrent();
QMapbox::initializeGLExtensions();
- map.resize(QSize(512, 512), QSize(512, 512));
+ map.resize(fbo.size(), fbo.size());
+ map.setFramebufferObject(fbo.handle());
map.setCoordinateZoom(QMapbox::Coordinate(60.170448, 24.942046), 14);
}
@@ -36,6 +40,7 @@ public:
private:
QGLWidget widget;
+ QGLFramebufferObject fbo;
protected:
QMapboxGLSettings settings;
@@ -51,6 +56,9 @@ private slots:
};
void onNeedsRendering() {
+ widget.makeCurrent();
+ fbo.bind();
+ glViewport(0, 0, fbo.width(), fbo.height());
map.render();
};
};
@@ -88,3 +96,5 @@ TEST_F(QMapboxGLTest, TEST_DISABLED_ON_CI(styleUrl)) {
}
#include "qmapboxgl.moc"
+
+#endif