summaryrefslogtreecommitdiffstats
path: root/examples/qt3d
diff options
context:
space:
mode:
authorSarah Smith <sarah.j.smith@nokia.com>2011-10-02 18:18:42 +1000
committerQt by Nokia <qt-info@nokia.com>2011-10-03 11:47:31 +0200
commitaa6850d950e8523c47cacdaf54c918de53299d80 (patch)
treed40864bc3a4b3e8cf07010be32c5ee0625d95e93 /examples/qt3d
parent2b61e0a75b09f8dc05b298069da43d477db69910 (diff)
Fixes for surface vs QOpenGLContext & QWindow.
With the qt5 refactor branch going in the ability to get a QPaintDevice has gone away - this was really a "relic from the desktop days". Painting still applies for FBO's and so on, but in the case of QML we are on an SG view and there is no paint device there. So move the QGLView to using a QWindow and QOpenGLContext as well to follow suit and replace all the logic in surface stuff to cope with that. Also update all examples, demos, tutorials and tests. Change-Id: Ie8dbeb97c87ef0821326fb7ccf5d5d4b1f90fd06 Reviewed-on: http://codereview.qt-project.org/5900 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Sarah Jane Smith <sarah.j.smith@nokia.com>
Diffstat (limited to 'examples/qt3d')
-rw-r--r--examples/qt3d/basket/basketview.cpp2
-rw-r--r--examples/qt3d/basket/basketview.h3
-rw-r--r--examples/qt3d/basket/main.cpp35
-rw-r--r--examples/qt3d/builder/builder.cpp2
-rw-r--r--examples/qt3d/builder/builder.h2
-rw-r--r--examples/qt3d/builder/main.cpp29
-rw-r--r--examples/qt3d/cube/cubeview.cpp2
-rw-r--r--examples/qt3d/cube/cubeview.h2
-rw-r--r--examples/qt3d/cube/main.cpp29
-rw-r--r--examples/qt3d/cylinder/cylinderview.cpp2
-rw-r--r--examples/qt3d/cylinder/cylinderview.h2
-rw-r--r--examples/qt3d/cylinder/main.cpp29
-rw-r--r--examples/qt3d/geometry/geometryview.cpp4
-rw-r--r--examples/qt3d/geometry/geometryview.h2
-rw-r--r--examples/qt3d/geometry/main.cpp29
-rw-r--r--examples/qt3d/nesting/cubeview.cpp8
-rw-r--r--examples/qt3d/nesting/cubeview.h6
-rw-r--r--examples/qt3d/nesting/main.cpp29
-rw-r--r--examples/qt3d/solarsystem/main.cpp29
-rw-r--r--examples/qt3d/solarsystem/solarsystem.cpp2
-rw-r--r--examples/qt3d/solarsystem/solarsystem.h2
-rw-r--r--examples/qt3d/tank/main.cpp29
-rw-r--r--examples/qt3d/tank/tankview.cpp5
-rw-r--r--examples/qt3d/tank/tankview.h2
-rw-r--r--examples/qt3d/teapot/main.cpp29
-rw-r--r--examples/qt3d/teapot/teapotview.h2
26 files changed, 247 insertions, 70 deletions
diff --git a/examples/qt3d/basket/basketview.cpp b/examples/qt3d/basket/basketview.cpp
index 41b20dfbb..f4680dbf8 100644
--- a/examples/qt3d/basket/basketview.cpp
+++ b/examples/qt3d/basket/basketview.cpp
@@ -45,7 +45,7 @@
#include "qglbuilder.h"
#include "qglscenenode.h"
-BasketView::BasketView(QWidget *parent)
+BasketView::BasketView(QWindow *parent)
: QGLView(parent)
, m_angle(0)
{
diff --git a/examples/qt3d/basket/basketview.h b/examples/qt3d/basket/basketview.h
index 03a8d61fd..b52b2f36e 100644
--- a/examples/qt3d/basket/basketview.h
+++ b/examples/qt3d/basket/basketview.h
@@ -44,6 +44,7 @@
#include "qglview.h"
class QGLSceneNode;
+class QWindow;
//! [1]
class BasketView : public QGLView
@@ -55,7 +56,7 @@ public:
void setAngle(qreal angle) { m_angle = angle; update(); }
//! [1]
- BasketView(QWidget *parent = 0);
+ BasketView(QWindow *parent = 0);
~BasketView();
protected:
diff --git a/examples/qt3d/basket/main.cpp b/examples/qt3d/basket/main.cpp
index a97b10775..43551279f 100644
--- a/examples/qt3d/basket/main.cpp
+++ b/examples/qt3d/basket/main.cpp
@@ -38,22 +38,43 @@
**
****************************************************************************/
-#include <QApplication>
+#include <QtGui/QGuiApplication>
+#include <QtCore/QtDebug>
+
#include "basketview.h"
int main(int argc, char *argv[])
{
- QApplication app(argc, argv);
+ QGuiApplication app(argc, argv);
BasketView view;
if (view.stereoType() != QGLView::RedCyanAnaglyph)
view.camera()->setEyeSeparation(0.3f);
- if (QApplication::arguments().contains(QLatin1String("-maximize")))
- view.showMaximized();
- else if (QApplication::arguments().contains(QLatin1String("-fullscreen")))
- view.showFullScreen();
+ QStringList args = QCoreApplication::arguments();
+ int w_pos = args.indexOf("-width");
+ int h_pos = args.indexOf("-height");
+ if (w_pos >= 0 && h_pos >= 0)
+ {
+ bool ok = true;
+ int w = args.at(w_pos + 1).toInt(&ok);
+ if (!ok)
+ {
+ qWarning() << "Could not parse width argument:" << args;
+ return 1;
+ }
+ int h = args.at(h_pos + 1).toInt(&ok);
+ if (!ok)
+ {
+ qWarning() << "Could not parse height argument:" << args;
+ return 1;
+ }
+ view.resize(w, h);
+ }
else
- view.show();
+ {
+ view.resize(800, 600);
+ }
+ view.show();
return app.exec();
}
diff --git a/examples/qt3d/builder/builder.cpp b/examples/qt3d/builder/builder.cpp
index 3628b4d43..a780bf35d 100644
--- a/examples/qt3d/builder/builder.cpp
+++ b/examples/qt3d/builder/builder.cpp
@@ -50,7 +50,7 @@
#include <QtCore/qmath.h>
-BuilderView::BuilderView(QWidget *parent)
+BuilderView::BuilderView(QWindow *parent)
: QGLView(parent)
, canScene(new QGLSceneNode(this))
{
diff --git a/examples/qt3d/builder/builder.h b/examples/qt3d/builder/builder.h
index a54dea6bf..1f4e00590 100644
--- a/examples/qt3d/builder/builder.h
+++ b/examples/qt3d/builder/builder.h
@@ -50,7 +50,7 @@ class BuilderView : public QGLView
{
Q_OBJECT
public:
- BuilderView(QWidget *parent = 0);
+ BuilderView(QWindow *parent = 0);
~BuilderView();
protected:
diff --git a/examples/qt3d/builder/main.cpp b/examples/qt3d/builder/main.cpp
index 46c68467e..a773471e7 100644
--- a/examples/qt3d/builder/main.cpp
+++ b/examples/qt3d/builder/main.cpp
@@ -49,12 +49,31 @@ int main(int argc, char *argv[])
if (view.stereoType() != QGLView::RedCyanAnaglyph)
view.camera()->setEyeSeparation(0.3f);
- if (QApplication::arguments().contains(QLatin1String("-maximize")))
- view.showMaximized();
- else if (QApplication::arguments().contains(QLatin1String("-fullscreen")))
- view.showFullScreen();
+ QStringList args = QCoreApplication::arguments();
+ int w_pos = args.indexOf("-width");
+ int h_pos = args.indexOf("-height");
+ if (w_pos >= 0 && h_pos >= 0)
+ {
+ bool ok = true;
+ int w = args.at(w_pos + 1).toInt(&ok);
+ if (!ok)
+ {
+ qWarning() << "Could not parse width argument:" << args;
+ return 1;
+ }
+ int h = args.at(h_pos + 1).toInt(&ok);
+ if (!ok)
+ {
+ qWarning() << "Could not parse height argument:" << args;
+ return 1;
+ }
+ view.resize(w, h);
+ }
else
- view.show();
+ {
+ view.resize(800, 600);
+ }
+ view.show();
return app.exec();
}
diff --git a/examples/qt3d/cube/cubeview.cpp b/examples/qt3d/cube/cubeview.cpp
index e8de75168..09a07eafe 100644
--- a/examples/qt3d/cube/cubeview.cpp
+++ b/examples/qt3d/cube/cubeview.cpp
@@ -44,7 +44,7 @@
#include <QtCore/qurl.h>
-CubeView::CubeView(QWidget *parent)
+CubeView::CubeView(QWindow *parent)
: QGLView(parent)
{
QGLBuilder builder;
diff --git a/examples/qt3d/cube/cubeview.h b/examples/qt3d/cube/cubeview.h
index 8996fd342..c184ff046 100644
--- a/examples/qt3d/cube/cubeview.h
+++ b/examples/qt3d/cube/cubeview.h
@@ -49,7 +49,7 @@ class CubeView : public QGLView
{
Q_OBJECT
public:
- CubeView(QWidget *parent = 0);
+ CubeView(QWindow *parent = 0);
~CubeView();
protected:
diff --git a/examples/qt3d/cube/main.cpp b/examples/qt3d/cube/main.cpp
index bad1c4c4f..dd9bc45da 100644
--- a/examples/qt3d/cube/main.cpp
+++ b/examples/qt3d/cube/main.cpp
@@ -48,12 +48,31 @@ int main(int argc, char *argv[])
if (view.stereoType() != QGLView::RedCyanAnaglyph)
view.camera()->setEyeSeparation(0.3f);
- if (QApplication::arguments().contains(QLatin1String("-maximize")))
- view.showMaximized();
- else if (QApplication::arguments().contains(QLatin1String("-fullscreen")))
- view.showFullScreen();
+ QStringList args = QCoreApplication::arguments();
+ int w_pos = args.indexOf("-width");
+ int h_pos = args.indexOf("-height");
+ if (w_pos >= 0 && h_pos >= 0)
+ {
+ bool ok = true;
+ int w = args.at(w_pos + 1).toInt(&ok);
+ if (!ok)
+ {
+ qWarning() << "Could not parse width argument:" << args;
+ return 1;
+ }
+ int h = args.at(h_pos + 1).toInt(&ok);
+ if (!ok)
+ {
+ qWarning() << "Could not parse height argument:" << args;
+ return 1;
+ }
+ view.resize(w, h);
+ }
else
- view.show();
+ {
+ view.resize(800, 600);
+ }
+ view.show();
return app.exec();
}
diff --git a/examples/qt3d/cylinder/cylinderview.cpp b/examples/qt3d/cylinder/cylinderview.cpp
index 2b347ab68..a5db58364 100644
--- a/examples/qt3d/cylinder/cylinderview.cpp
+++ b/examples/qt3d/cylinder/cylinderview.cpp
@@ -44,7 +44,7 @@
#include "qglcylinder.h"
#include <QtCore/qurl.h>
-CylinderView::CylinderView(QWidget *parent)
+CylinderView::CylinderView(QWindow *parent)
: QGLView(parent)
{
QGLBuilder builder;
diff --git a/examples/qt3d/cylinder/cylinderview.h b/examples/qt3d/cylinder/cylinderview.h
index c2f4824b9..828772d78 100644
--- a/examples/qt3d/cylinder/cylinderview.h
+++ b/examples/qt3d/cylinder/cylinderview.h
@@ -49,7 +49,7 @@ class CylinderView : public QGLView
{
Q_OBJECT
public:
- CylinderView(QWidget *parent = 0);
+ CylinderView(QWindow *parent = 0);
~CylinderView();
protected:
diff --git a/examples/qt3d/cylinder/main.cpp b/examples/qt3d/cylinder/main.cpp
index 39297a53d..8b95e76a6 100644
--- a/examples/qt3d/cylinder/main.cpp
+++ b/examples/qt3d/cylinder/main.cpp
@@ -48,12 +48,31 @@ int main(int argc, char *argv[])
if (view.stereoType() != QGLView::RedCyanAnaglyph)
view.camera()->setEyeSeparation(0.3f);
- if (QApplication::arguments().contains(QLatin1String("-maximize")))
- view.showMaximized();
- else if (QApplication::arguments().contains(QLatin1String("-fullscreen")))
- view.showFullScreen();
+ QStringList args = QCoreApplication::arguments();
+ int w_pos = args.indexOf("-width");
+ int h_pos = args.indexOf("-height");
+ if (w_pos >= 0 && h_pos >= 0)
+ {
+ bool ok = true;
+ int w = args.at(w_pos + 1).toInt(&ok);
+ if (!ok)
+ {
+ qWarning() << "Could not parse width argument:" << args;
+ return 1;
+ }
+ int h = args.at(h_pos + 1).toInt(&ok);
+ if (!ok)
+ {
+ qWarning() << "Could not parse height argument:" << args;
+ return 1;
+ }
+ view.resize(w, h);
+ }
else
- view.show();
+ {
+ view.resize(800, 600);
+ }
+ view.show();
return app.exec();
}
diff --git a/examples/qt3d/geometry/geometryview.cpp b/examples/qt3d/geometry/geometryview.cpp
index 762e56fcd..4c690e4ef 100644
--- a/examples/qt3d/geometry/geometryview.cpp
+++ b/examples/qt3d/geometry/geometryview.cpp
@@ -55,7 +55,7 @@
#include "qglmaterialcollection.h"
#include "qgraphicsscale3d.h"
-GeometryView::GeometryView(QWidget *parent)
+GeometryView::GeometryView(QWindow *parent)
: QGLView(parent)
, timer(new QTimer(this))
{
@@ -118,5 +118,5 @@ void GeometryView::paintGL(QGLPainter *painter)
void GeometryView::rotate()
{
angle = (angle + 2) % 360;
- updateGL();
+ update();
}
diff --git a/examples/qt3d/geometry/geometryview.h b/examples/qt3d/geometry/geometryview.h
index 822a7a409..631d48598 100644
--- a/examples/qt3d/geometry/geometryview.h
+++ b/examples/qt3d/geometry/geometryview.h
@@ -57,7 +57,7 @@ class GeometryView : public QGLView
{
Q_OBJECT
public:
- GeometryView(QWidget *parent = 0);
+ GeometryView(QWindow *parent = 0);
~GeometryView();
protected:
diff --git a/examples/qt3d/geometry/main.cpp b/examples/qt3d/geometry/main.cpp
index 725066bb4..6b8ea814d 100644
--- a/examples/qt3d/geometry/main.cpp
+++ b/examples/qt3d/geometry/main.cpp
@@ -48,12 +48,31 @@ int main(int argc, char *argv[])
if (view.stereoType() != QGLView::RedCyanAnaglyph)
view.camera()->setEyeSeparation(0.3f);
- if (QApplication::arguments().contains(QLatin1String("-maximize")))
- view.showMaximized();
- else if (QApplication::arguments().contains(QLatin1String("-fullscreen")))
- view.showFullScreen();
+ QStringList args = QCoreApplication::arguments();
+ int w_pos = args.indexOf("-width");
+ int h_pos = args.indexOf("-height");
+ if (w_pos >= 0 && h_pos >= 0)
+ {
+ bool ok = true;
+ int w = args.at(w_pos + 1).toInt(&ok);
+ if (!ok)
+ {
+ qWarning() << "Could not parse width argument:" << args;
+ return 1;
+ }
+ int h = args.at(h_pos + 1).toInt(&ok);
+ if (!ok)
+ {
+ qWarning() << "Could not parse height argument:" << args;
+ return 1;
+ }
+ view.resize(w, h);
+ }
else
- view.show();
+ {
+ view.resize(800, 600);
+ }
+ view.show();
return app.exec();
}
diff --git a/examples/qt3d/nesting/cubeview.cpp b/examples/qt3d/nesting/cubeview.cpp
index d14b5048e..f3c1e3d6e 100644
--- a/examples/qt3d/nesting/cubeview.cpp
+++ b/examples/qt3d/nesting/cubeview.cpp
@@ -41,11 +41,13 @@
#include "cubeview.h"
#include "qglcube.h"
#include "qglteapot.h"
-#include <QtOpenGL/qglframebufferobject.h>
+
#include <QtCore/qpropertyanimation.h>
+#include <QtGui/QOpenGLFramebufferObject>
+
//! [1]
-CubeView::CubeView(QWidget *parent)
+CubeView::CubeView(QWindow *parent)
: QGLView(parent)
, fbo(0)
, tangle(0.0f)
@@ -105,7 +107,7 @@ CubeView::~CubeView()
//! [4]
void CubeView::initializeGL(QGLPainter *)
{
- fbo = new QGLFramebufferObject(512, 512, QGLFramebufferObject::Depth);
+ fbo = new QOpenGLFramebufferObject(512, 512, QOpenGLFramebufferObject::Depth);
fboSurface.setFramebufferObject(fbo);
//! [4]
diff --git a/examples/qt3d/nesting/cubeview.h b/examples/qt3d/nesting/cubeview.h
index 1fae5de4d..0ce1f4646 100644
--- a/examples/qt3d/nesting/cubeview.h
+++ b/examples/qt3d/nesting/cubeview.h
@@ -45,7 +45,7 @@
#include "qglbuilder.h"
#include "qglframebufferobjectsurface.h"
-class QGLFramebufferObject;
+class QOpenGLFramebufferObject;
class QGLCamera;
class CubeView : public QGLView
@@ -55,7 +55,7 @@ class CubeView : public QGLView
Q_PROPERTY(qreal cubeAngle READ cubeAngle WRITE setCubeAngle)
Q_PROPERTY(qreal orbitAngle READ orbitAngle WRITE setOrbitAngle)
public:
- CubeView(QWidget *parent = 0);
+ CubeView(QWindow *parent = 0);
~CubeView();
qreal teapotAngle() const { return tangle; }
@@ -76,7 +76,7 @@ private:
QGLSceneNode *cube;
QGLSceneNode *teapot;
QGLTexture2D qtlogo;
- QGLFramebufferObject *fbo;
+ QOpenGLFramebufferObject *fbo;
QGLFramebufferObjectSurface fboSurface;
QGLCamera *innerCamera;
qreal tangle;
diff --git a/examples/qt3d/nesting/main.cpp b/examples/qt3d/nesting/main.cpp
index abb38f0f7..f5201ebb8 100644
--- a/examples/qt3d/nesting/main.cpp
+++ b/examples/qt3d/nesting/main.cpp
@@ -46,12 +46,31 @@ int main(int argc, char *argv[])
QApplication app(argc, argv);
CubeView view;
- if (QApplication::arguments().contains(QLatin1String("-maximize")))
- view.showMaximized();
- else if (QApplication::arguments().contains(QLatin1String("-fullscreen")))
- view.showFullScreen();
+ QStringList args = QCoreApplication::arguments();
+ int w_pos = args.indexOf("-width");
+ int h_pos = args.indexOf("-height");
+ if (w_pos >= 0 && h_pos >= 0)
+ {
+ bool ok = true;
+ int w = args.at(w_pos + 1).toInt(&ok);
+ if (!ok)
+ {
+ qWarning() << "Could not parse width argument:" << args;
+ return 1;
+ }
+ int h = args.at(h_pos + 1).toInt(&ok);
+ if (!ok)
+ {
+ qWarning() << "Could not parse height argument:" << args;
+ return 1;
+ }
+ view.resize(w, h);
+ }
else
- view.show();
+ {
+ view.resize(800, 600);
+ }
+ view.show();
return app.exec();
}
diff --git a/examples/qt3d/solarsystem/main.cpp b/examples/qt3d/solarsystem/main.cpp
index 49c7cfb17..d36bf95e4 100644
--- a/examples/qt3d/solarsystem/main.cpp
+++ b/examples/qt3d/solarsystem/main.cpp
@@ -47,12 +47,31 @@ int main(int argc, char *argv[])
QApplication app(argc, argv);
SolarSystemView view;
- if (QApplication::arguments().contains(QLatin1String("-maximize")))
- view.showMaximized();
- else if (QApplication::arguments().contains(QLatin1String("-fullscreen")))
- view.showFullScreen();
+ QStringList args = QCoreApplication::arguments();
+ int w_pos = args.indexOf("-width");
+ int h_pos = args.indexOf("-height");
+ if (w_pos >= 0 && h_pos >= 0)
+ {
+ bool ok = true;
+ int w = args.at(w_pos + 1).toInt(&ok);
+ if (!ok)
+ {
+ qWarning() << "Could not parse width argument:" << args;
+ return 1;
+ }
+ int h = args.at(h_pos + 1).toInt(&ok);
+ if (!ok)
+ {
+ qWarning() << "Could not parse height argument:" << args;
+ return 1;
+ }
+ view.resize(w, h);
+ }
else
- view.show();
+ {
+ view.resize(800, 600);
+ }
+ view.show();
return app.exec();
}
diff --git a/examples/qt3d/solarsystem/solarsystem.cpp b/examples/qt3d/solarsystem/solarsystem.cpp
index 25b0f7699..ad29c3911 100644
--- a/examples/qt3d/solarsystem/solarsystem.cpp
+++ b/examples/qt3d/solarsystem/solarsystem.cpp
@@ -56,7 +56,7 @@
#include <QtCore/qmath.h>
-SolarSystemView::SolarSystemView(QWidget *parent)
+SolarSystemView::SolarSystemView(QWindow *parent)
: QGLView(parent)
, spaceScene(new QGLSceneNode(this))
, sunEffect(0)
diff --git a/examples/qt3d/solarsystem/solarsystem.h b/examples/qt3d/solarsystem/solarsystem.h
index aa166e726..372d1985b 100644
--- a/examples/qt3d/solarsystem/solarsystem.h
+++ b/examples/qt3d/solarsystem/solarsystem.h
@@ -56,7 +56,7 @@ class SolarSystemView : public QGLView
Q_PROPERTY(qreal angle3 READ angle3 WRITE setAngle3)
Q_PROPERTY(qreal glowFactor READ glowFactor WRITE setGlowFactor)
public:
- SolarSystemView(QWidget *parent = 0);
+ SolarSystemView(QWindow *parent = 0);
~SolarSystemView();
qreal angle1() const { return m_angle1; }
diff --git a/examples/qt3d/tank/main.cpp b/examples/qt3d/tank/main.cpp
index ad97805eb..5254b05d2 100644
--- a/examples/qt3d/tank/main.cpp
+++ b/examples/qt3d/tank/main.cpp
@@ -53,12 +53,31 @@ int main(int argc, char *argv[])
if (view.stereoType() != QGLView::RedCyanAnaglyph)
view.camera()->setEyeSeparation(0.3f);
- if (QApplication::arguments().contains(QLatin1String("-maximize")))
- view.showMaximized();
- else if (QApplication::arguments().contains(QLatin1String("-fullscreen")))
- view.showFullScreen();
+ QStringList args = QCoreApplication::arguments();
+ int w_pos = args.indexOf("-width");
+ int h_pos = args.indexOf("-height");
+ if (w_pos >= 0 && h_pos >= 0)
+ {
+ bool ok = true;
+ int w = args.at(w_pos + 1).toInt(&ok);
+ if (!ok)
+ {
+ qWarning() << "Could not parse width argument:" << args;
+ return 1;
+ }
+ int h = args.at(h_pos + 1).toInt(&ok);
+ if (!ok)
+ {
+ qWarning() << "Could not parse height argument:" << args;
+ return 1;
+ }
+ view.resize(w, h);
+ }
else
- view.show();
+ {
+ view.resize(800, 600);
+ }
+ view.show();
return a.exec();
}
diff --git a/examples/qt3d/tank/tankview.cpp b/examples/qt3d/tank/tankview.cpp
index 1c2e706d0..6adc25edc 100644
--- a/examples/qt3d/tank/tankview.cpp
+++ b/examples/qt3d/tank/tankview.cpp
@@ -48,7 +48,7 @@
#include <QMouseEvent>
-TankView::TankView(QWidget *parent)
+TankView::TankView(QWindow *parent)
: QGLView(parent)
, m_tankScene(new QGLSceneNode)
, m_count(0)
@@ -60,7 +60,8 @@ TankView::TankView(QWidget *parent)
Tank *tank = addTank();
connect(tank, SIGNAL(updated()), this, SLOT(update()));
- setToolTip(tr("Double-click to add more tanks"));
+ // TODO: setToolTip not implemented in QWindow
+ // setToolTip(tr("Double-click to add more tanks"));
setWindowTitle(tr("Double-click Me!"));
}
diff --git a/examples/qt3d/tank/tankview.h b/examples/qt3d/tank/tankview.h
index 38b966158..112598ad2 100644
--- a/examples/qt3d/tank/tankview.h
+++ b/examples/qt3d/tank/tankview.h
@@ -49,7 +49,7 @@ class Tank;
class TankView : public QGLView
{
public:
- TankView(QWidget *parent = 0);
+ TankView(QWindow *parent = 0);
~TankView();
protected:
void initializeGL(QGLPainter *painter);
diff --git a/examples/qt3d/teapot/main.cpp b/examples/qt3d/teapot/main.cpp
index f98693f3c..d79340be1 100644
--- a/examples/qt3d/teapot/main.cpp
+++ b/examples/qt3d/teapot/main.cpp
@@ -50,12 +50,31 @@ int main(int argc, char *argv[])
if (view.stereoType() != QGLView::RedCyanAnaglyph)
view.camera()->setEyeSeparation(0.3f);
- if (QApplication::arguments().contains(QLatin1String("-maximize")))
- view.showMaximized();
- else if (QApplication::arguments().contains(QLatin1String("-fullscreen")))
- view.showFullScreen();
+ QStringList args = QCoreApplication::arguments();
+ int w_pos = args.indexOf("-width");
+ int h_pos = args.indexOf("-height");
+ if (w_pos >= 0 && h_pos >= 0)
+ {
+ bool ok = true;
+ int w = args.at(w_pos + 1).toInt(&ok);
+ if (!ok)
+ {
+ qWarning() << "Could not parse width argument:" << args;
+ return 1;
+ }
+ int h = args.at(h_pos + 1).toInt(&ok);
+ if (!ok)
+ {
+ qWarning() << "Could not parse height argument:" << args;
+ return 1;
+ }
+ view.resize(w, h);
+ }
else
- view.show();
+ {
+ view.resize(800, 600);
+ }
+ view.show();
//! [main-args-end]
return app.exec();
diff --git a/examples/qt3d/teapot/teapotview.h b/examples/qt3d/teapot/teapotview.h
index d251f990a..e2ba50b05 100644
--- a/examples/qt3d/teapot/teapotview.h
+++ b/examples/qt3d/teapot/teapotview.h
@@ -51,7 +51,7 @@ class TeapotView : public QGLView
{
Q_OBJECT
public:
- TeapotView(QWidget *parent = 0) : QGLView(parent), teapot(0) {}
+ TeapotView(QWindow *parent = 0) : QGLView(parent), teapot(0) {}
~TeapotView();
protected: