summaryrefslogtreecommitdiffstats
path: root/tools/qmlviewer
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-09-02 23:32:38 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-09-02 23:32:38 (GMT)
commit48b47f9d242f76e944986df08a16c083bce47bef (patch)
tree3cf9a57b2570f157f70a6b9ca2aa80450af61dc9 /tools/qmlviewer
parented417f18023f1bbd0636c9724b8f79e08c77d51a (diff)
downloadQt-48b47f9d242f76e944986df08a16c083bce47bef.zip
Qt-48b47f9d242f76e944986df08a16c083bce47bef.tar.gz
Qt-48b47f9d242f76e944986df08a16c083bce47bef.tar.bz2
Make it easier to test examples with EGL.
Currently -graphicssystem opengl is not very reliable with EGL, so we've added a -opengl option to qmlviewer which sets the viewport of the view to a QGLWidget and allows for GL testing.
Diffstat (limited to 'tools/qmlviewer')
-rw-r--r--tools/qmlviewer/main.cpp5
-rw-r--r--tools/qmlviewer/qmlviewer.cpp18
-rw-r--r--tools/qmlviewer/qmlviewer.h1
-rw-r--r--tools/qmlviewer/qmlviewer.pro5
4 files changed, 29 insertions, 0 deletions
diff --git a/tools/qmlviewer/main.cpp b/tools/qmlviewer/main.cpp
index a4ed054..87d1232 100644
--- a/tools/qmlviewer/main.cpp
+++ b/tools/qmlviewer/main.cpp
@@ -41,6 +41,7 @@ void usage()
qWarning(" -netcache <size> ......................... set disk cache to size bytes");
qWarning(" -translation <translationfile> ........... set the language to run in");
qWarning(" -L <directory> ........................... prepend to the library search path");
+ qWarning(" -opengl .................................. use a QGLWidget for the viewport");
qWarning(" ");
qWarning(" Press F1 for interactive help");
exit(1);
@@ -79,6 +80,7 @@ int main(int argc, char ** argv)
bool devkeys = false;
int cache = 0;
QString translationFile;
+ bool useGL = false;
for (int i = 1; i < argc; ++i) {
QString arg = argv[i];
@@ -114,6 +116,8 @@ int main(int argc, char ** argv)
usage();
translationFile = argv[i + 1];
++i;
+ } else if (arg == "-opengl") {
+ useGL = true;
} else if (arg == "-L") {
libraries << QString(argv[++i]);
} else if (arg[0] != '-') {
@@ -130,6 +134,7 @@ int main(int argc, char ** argv)
}
QmlViewer viewer(0, frameless ? Qt::FramelessWindowHint : Qt::Widget);
+ viewer.setUseGL(useGL);
foreach (QString lib, libraries)
viewer.addLibraryPath(lib);
viewer.setNetworkCacheSize(cache);
diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp
index 272ebcb..3ae9a97 100644
--- a/tools/qmlviewer/qmlviewer.cpp
+++ b/tools/qmlviewer/qmlviewer.cpp
@@ -45,6 +45,10 @@
#include <QKeyEvent>
#include "proxysettings.h"
+#ifdef GL_SUPPORTED
+#include <QGLWidget>
+#endif
+
QT_BEGIN_NAMESPACE
class PreviewDeviceSkin : public DeviceSkin
@@ -1003,6 +1007,20 @@ void QmlViewer::setNetworkCacheSize(int size)
}
}
+void QmlViewer::setUseGL(bool useGL)
+{
+#ifdef GL_SUPPORTED
+ if (useGL) {
+ QGLFormat format = QGLFormat::defaultFormat();
+ format.setSampleBuffers(false);
+
+ QGLWidget *glWidget = new QGLWidget(format);
+ glWidget->setAutoFillBackground(false);
+ canvas->setViewport(glWidget);
+ }
+#endif
+}
+
QT_END_NAMESPACE
#include "qmlviewer.moc"
diff --git a/tools/qmlviewer/qmlviewer.h b/tools/qmlviewer/qmlviewer.h
index c03c09f..e85acfa 100644
--- a/tools/qmlviewer/qmlviewer.h
+++ b/tools/qmlviewer/qmlviewer.h
@@ -43,6 +43,7 @@ public:
void setDeviceKeys(bool);
void setNetworkCacheSize(int size);
void addLibraryPath(const QString& lib);
+ void setUseGL(bool use);
QStringList builtinSkins() const;
diff --git a/tools/qmlviewer/qmlviewer.pro b/tools/qmlviewer/qmlviewer.pro
index bcf361e..77cae97 100644
--- a/tools/qmlviewer/qmlviewer.pro
+++ b/tools/qmlviewer/qmlviewer.pro
@@ -7,6 +7,11 @@ QT += declarative \
network \
sql
+contains(QT_CONFIG, opengl) {
+ QT += opengl
+ DEFINES += GL_SUPPORTED
+}
+
# Input
HEADERS += qmlviewer.h \
proxysettings.h