summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/qt3d/basket/basket.pro1
-rw-r--r--src/quick3d/qdeclarativeitem3d.cpp1
-rw-r--r--src/threed/scene/qglsceneanimation.cpp2
-rw-r--r--src/threed/scene/qglscenenode.cpp2
-rw-r--r--src/threed/surfaces/qglabstractsurface.cpp2
-rw-r--r--src/threed/viewing/qglmockview.cpp161
-rw-r--r--src/threed/viewing/qglmockview.h78
-rw-r--r--src/threed/viewing/qglmockview_p.h61
-rw-r--r--src/threed/viewing/viewing.pri7
-rw-r--r--tests/auto/threed/qgeometrydata/tst_qgeometrydata.cpp9
-rw-r--r--tests/auto/threed/qglabstractsurface/tst_qglabstractsurface.cpp217
-rw-r--r--tests/auto/threed/qglmaterial/tst_qglmaterial.cpp9
-rw-r--r--tests/auto/threed/qglvertexbundle/tst_qglvertexbundle.cpp21
-rw-r--r--tutorials/quick3d/quick3d.pro2
-rw-r--r--tutorials/quick3d/shadertut/main.cpp43
-rw-r--r--tutorials/quick3d/shadertut/qml/TutorialTeapot.qml (renamed from tutorials/quick3d/shadertut/TutorialTeapot.qml)0
-rw-r--r--tutorials/quick3d/shadertut/qml/meshes/teapot.bez (renamed from tutorials/quick3d/shadertut/meshes/teapot.bez)0
-rw-r--r--tutorials/quick3d/shadertut/qml/shader-tutorial-1-textures.qml (renamed from tutorials/quick3d/shadertut/shader-tutorial-1-textures.qml)0
-rw-r--r--tutorials/quick3d/shadertut/qml/shader-tutorial-2-vertex-shader.qml (renamed from tutorials/quick3d/shadertut/shader-tutorial-2-vertex-shader.qml)0
-rw-r--r--tutorials/quick3d/shadertut/qml/shader-tutorial-3-transformed-coordinates.qml (renamed from tutorials/quick3d/shadertut/shader-tutorial-3-transformed-coordinates.qml)0
-rw-r--r--tutorials/quick3d/shadertut/qml/shader-tutorial-lighting.qml (renamed from tutorials/quick3d/shadertut/shader-tutorial-lighting.qml)0
-rw-r--r--tutorials/quick3d/shadertut/qml/shader-tutorial-varying.qml (renamed from tutorials/quick3d/shadertut/shader-tutorial-varying.qml)0
-rw-r--r--tutorials/quick3d/shadertut/qml/shader-tutorial.qml (renamed from tutorials/quick3d/shadertut/shader-tutorial.qml)0
-rw-r--r--tutorials/quick3d/shadertut/shaders.pro7
-rw-r--r--tutorials/quick3d/shadertut/shadertut.pro41
25 files changed, 481 insertions, 183 deletions
diff --git a/examples/qt3d/basket/basket.pro b/examples/qt3d/basket/basket.pro
index 27f11d281..c96bc4aab 100644
--- a/examples/qt3d/basket/basket.pro
+++ b/examples/qt3d/basket/basket.pro
@@ -7,7 +7,6 @@ include(../../../pkg.pri)
SOURCES = basketview.cpp main.cpp
HEADERS = basketview.h basket_data.h
-RESOURCES = basket.qrc
OTHER_FILES += \
basket.rc
diff --git a/src/quick3d/qdeclarativeitem3d.cpp b/src/quick3d/qdeclarativeitem3d.cpp
index addc55cfd..c3f2199c3 100644
--- a/src/quick3d/qdeclarativeitem3d.cpp
+++ b/src/quick3d/qdeclarativeitem3d.cpp
@@ -1294,6 +1294,7 @@ void QDeclarativeItem3D::draw(QGLPainter *painter)
QOpenGLContext* pOpenGLContext = pCanvas->openglContext();
Q_ASSERT(pOpenGLContext);
bool Ok = QObject::connect(pOpenGLContext, SIGNAL(aboutToBeDestroyed()), this, SLOT(handleOpenglContextIsAboutToBeDestroyed()), Qt::DirectConnection);
+ Q_UNUSED(Ok); // quell compiler warning
Q_ASSERT(Ok);
d->bConnectedToOpenGLContextSignal = true;
}
diff --git a/src/threed/scene/qglsceneanimation.cpp b/src/threed/scene/qglsceneanimation.cpp
index 4671e6d20..0ab06019f 100644
--- a/src/threed/scene/qglsceneanimation.cpp
+++ b/src/threed/scene/qglsceneanimation.cpp
@@ -56,7 +56,7 @@ public:
};
QGLSceneAnimationPrivate::QGLSceneAnimationPrivate() :
- m_name("unnamed")
+ m_name(QLatin1String("unnamed"))
{
}
diff --git a/src/threed/scene/qglscenenode.cpp b/src/threed/scene/qglscenenode.cpp
index b008dd004..abe3b959d 100644
--- a/src/threed/scene/qglscenenode.cpp
+++ b/src/threed/scene/qglscenenode.cpp
@@ -1530,7 +1530,7 @@ void QGLSceneNode::setPickNode(QGLPickNode *node)
*/
QGLSceneNode *QGLSceneNode::findSceneNode(QString &nodePath)
{
- QRegExp splitExpression("::");
+ QRegExp splitExpression(QLatin1String("::"));
QStringList nodePathList = nodePath.split(splitExpression);
return findSceneNode(nodePathList);
}
diff --git a/src/threed/surfaces/qglabstractsurface.cpp b/src/threed/surfaces/qglabstractsurface.cpp
index 1886ef36a..9d70e61d4 100644
--- a/src/threed/surfaces/qglabstractsurface.cpp
+++ b/src/threed/surfaces/qglabstractsurface.cpp
@@ -283,7 +283,7 @@ void QGLAbstractSurface::setFramebufferObject(QOpenGLFramebufferObject *framebuf
This function calls viewportGL() and then flips the rectangle
upside down using the height of device() so that the origin
- is at the top-left instead of the bottom-right.
+ is at the top-left instead of the bottom-left.
\sa viewportGL(), device()
*/
diff --git a/src/threed/viewing/qglmockview.cpp b/src/threed/viewing/qglmockview.cpp
new file mode 100644
index 000000000..82174d949
--- /dev/null
+++ b/src/threed/viewing/qglmockview.cpp
@@ -0,0 +1,161 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qglmockview.h"
+#include "qglmockview_p.h"
+
+#include <QOpenGLContext>
+#include <QDebug>
+
+/*!
+ \class QGLMockView
+ \brief The QGLMockView class exists purely for unit testing.
+ \since 4.8
+ \ingroup qt3d
+ \ingroup qt3d::viewing
+
+ The QGLMockView class exists purely for unit test writing and should
+ never be used for creating actual applications. QGLMockView is for
+ advanced, mostly internal use and is not supported as part of the Qt3D
+ functional API.
+*/
+
+QGLMockViewPrivate::QGLMockViewPrivate()
+ : valid(false)
+ , ctx(0)
+{
+ // nothing to do here
+}
+
+QGLMockViewPrivate::~QGLMockViewPrivate()
+{
+ delete ctx;
+}
+
+/*!
+ Create a new QGLMockView object. Internally this sets up the underlying
+ QWindow with some typical values useful for unit-testing, and then tries
+ to create the window. If this fails the instance is invalid and it can
+ be assumed the unit test environment does not support GL.
+*/
+QGLMockView::QGLMockView(QWindow *parent)
+ : QWindow(parent)
+ , dptr(new QGLMockViewPrivate)
+{
+ setGeometry(QRect(50, 50, 100, 100));
+ setSurfaceType(QWindow::OpenGLSurface);
+ create();
+ dptr->valid = ensureContext();
+ if (!dptr->valid)
+ qWarning() << "Could not get valid GL in QGLMockView - test may fail";
+}
+
+/*!
+ Destroys this QGLMockView object, recovering any resources.
+*/
+QGLMockView::~QGLMockView()
+{
+ // nothing to do here - dptr cleaned up automatically
+}
+
+/*!
+ Returns true if this QGLMockView object can be used for testing.
+
+ \code
+ QGLMockView view;
+ if (!view.isValid())
+ QSKIP("GL not supported on this test platform");
+ \endcode
+
+ The isValid() function will be false typically if the underlying
+ GL context could not be created for this window.
+*/
+bool QGLMockView::isValid() const
+{
+ return dptr->valid;
+}
+
+/*!
+ Returns the QOpenGLContext for this mock view, if one exists.
+
+ By default this value is null, but the constructor will attempt
+ to set it to a non-null and valid context, and then make that
+ context current on this window.
+
+ \code
+ QGLMockView view;
+ QCOMPARE(view.context(), QOpenGLContext::currentContext());
+ \endcode
+*/
+QOpenGLContext *QGLMockView::context()
+{
+ return dptr->ctx;
+}
+
+bool QGLMockView::ensureContext()
+{
+ QSurfaceFormat format;
+ format.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
+ if (!dptr->ctx)
+ dptr->ctx = new QOpenGLContext;
+ dptr->ctx->setFormat(format);
+#ifndef QT_NO_DEBUG_STREAM
+ QSurfaceFormat oldFormat = format;
+#endif
+ dptr->ctx->create();
+ if (!dptr->ctx->isValid())
+ return false;
+ // TODO: is it possible that the platform will downgrade the actual
+ // format, or will it just fail if it can't deliver the actual format
+ format = dptr->ctx->format();
+#ifndef QT_NO_DEBUG_STREAM
+ if (oldFormat.swapBehavior() != format.swapBehavior())
+ qWarning() << "Could not specify swap behavior"
+ << oldFormat.swapBehavior();
+#endif
+ bool res = dptr->ctx->makeCurrent(this);
+#ifndef QT_NO_DEBUG_STREAM
+ if (!res)
+ qWarning() << "Could not make context current!";
+#endif
+ return res;
+}
+
diff --git a/src/threed/viewing/qglmockview.h b/src/threed/viewing/qglmockview.h
new file mode 100644
index 000000000..3a6345e8a
--- /dev/null
+++ b/src/threed/viewing/qglmockview.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGLMOCKVIEW_H
+#define QGLMOCKVIEW_H
+
+#include "qt3dglobal.h"
+
+#include <QWindow>
+#include <QSharedPointer>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Qt3D)
+
+class QGLMockViewPrivate;
+
+class Q_QT3D_EXPORT QGLMockView : public QWindow
+{
+ Q_OBJECT
+public:
+ explicit QGLMockView(QWindow *parent = 0);
+ ~QGLMockView();
+
+ bool isValid() const;
+ QOpenGLContext *context();
+
+private:
+ bool ensureContext();
+
+ QSharedPointer<QGLMockViewPrivate> dptr;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QGLMOCKVIEW_H
diff --git a/src/threed/viewing/qglmockview_p.h b/src/threed/viewing/qglmockview_p.h
new file mode 100644
index 000000000..a61b39186
--- /dev/null
+++ b/src/threed/viewing/qglmockview_p.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGLMOCKVIEW_P_H
+#define QGLMOCKVIEW_P_H
+
+QT_BEGIN_NAMESPACE
+
+class QOpenGLContext;
+
+class QGLMockViewPrivate
+{
+public:
+ QGLMockViewPrivate();
+ ~QGLMockViewPrivate();
+
+ bool valid;
+ QOpenGLContext *ctx;
+};
+
+QT_END_NAMESPACE
+
+#endif // QGLMOCKVIEW_P_H
diff --git a/src/threed/viewing/viewing.pri b/src/threed/viewing/viewing.pri
index a6d7f7fdc..873ff28ba 100644
--- a/src/threed/viewing/viewing.pri
+++ b/src/threed/viewing/viewing.pri
@@ -4,9 +4,12 @@ VPATH += $$PWD
HEADERS += \
viewing/qglcamera.h \
viewing/qglcameraanimation.h \
- viewing/qglview.h
+ viewing/qglview.h \
+ viewing/qglmockview.h \
+ viewing/qglmockview_p.h
SOURCES += \
qglcamera.cpp \
qglcameraanimation.cpp \
- qglview.cpp
+ qglview.cpp \
+ viewing/qglmockview.cpp
diff --git a/tests/auto/threed/qgeometrydata/tst_qgeometrydata.cpp b/tests/auto/threed/qgeometrydata/tst_qgeometrydata.cpp
index 348e399be..382817539 100644
--- a/tests/auto/threed/qgeometrydata/tst_qgeometrydata.cpp
+++ b/tests/auto/threed/qgeometrydata/tst_qgeometrydata.cpp
@@ -46,7 +46,7 @@
#include "qvector_utils_p.h"
#include "qtest_helpers.h"
#include "qglpainter.h"
-#include "qglview.h"
+#include "qglmockview.h"
#include <QtCore/qdebug.h>
@@ -564,7 +564,6 @@ void tst_QGeometryData::generateTextureCoordinates()
void tst_QGeometryData::clear()
{
- QSKIP("QWidget: Cannot create a QWidget when no GUI is being used");
QVector3D a(1.1, 1.2, 1.3);
QVector3D b(2.1, 2.2, 2.3);
QVector3D c(3.1, 3.2, 3.3);
@@ -606,7 +605,6 @@ void tst_QGeometryData::clear()
void tst_QGeometryData::draw()
{
- QSKIP("QWidget: Cannot create a QWidget when no GUI is being used");
QVector3D a(1.1, 1.2, 1.3);
QVector3D b(2.1, 2.2, 2.3);
QVector3D c(3.1, 3.2, 3.3);
@@ -620,7 +618,10 @@ void tst_QGeometryData::draw()
data.appendVertex(a, b, c, d);
data.appendNormal(an, bn, cn, dn);
- QGLView w;
+ QGLMockView w;
+ if (!w.isValid())
+ QSKIP("Cannot create valid GL Context");
+
QGLPainter p(&w);
data.draw(&p, 0, 4);
}
diff --git a/tests/auto/threed/qglabstractsurface/tst_qglabstractsurface.cpp b/tests/auto/threed/qglabstractsurface/tst_qglabstractsurface.cpp
index 5bcf3b4fe..1f1489289 100644
--- a/tests/auto/threed/qglabstractsurface/tst_qglabstractsurface.cpp
+++ b/tests/auto/threed/qglabstractsurface/tst_qglabstractsurface.cpp
@@ -43,10 +43,9 @@
#include "qglabstractsurface.h"
#include "qglwindowsurface.h"
#include "qglframebufferobjectsurface.h"
-
#include "qglsubsurface.h"
#include "qopenglfunctions.h"
-
+#include <qglmockview.h>
#include <QtGui/QOpenGLContext>
class tst_QGLAbstractSurface : public QObject
@@ -59,7 +58,6 @@ public:
private slots:
void glWindowSurface();
void fboSurface();
- // TODO: void pbufferSurface();
void subSurface();
private:
@@ -78,83 +76,74 @@ bool tst_QGLAbstractSurface::isFboCurrent(QOpenGLFramebufferObject *fbo)
return currentFbo == 0;
}
-static void ensureContext(QWindow &win, QOpenGLContext &ctx)
-{
- QSurfaceFormat format;
- format.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
- ctx.setFormat(format);
-#ifndef QT_NO_DEBUG_STREAM
- QSurfaceFormat oldFormat = format;
-#endif
- ctx.create();
- // TODO: is it possible that the platform will downgrade the actual
- // format, or will it just fail if it can't deliver the actual format
- format = ctx.format();
-#ifndef QT_NO_DEBUG_STREAM
- if (oldFormat.swapBehavior() != format.swapBehavior())
- qWarning() << "Could not create context for swap behavior"
- << oldFormat.swapBehavior();
-#endif
- ctx.makeCurrent(&win);
-}
-
void tst_QGLAbstractSurface::glWindowSurface()
{
- QWindow glw;
- glw.setSurfaceType(QWindow::OpenGLSurface);
- QOpenGLContext ctx;
- ensureContext(glw, ctx);
- if (!ctx.isValid())
- {
- QSKIP("GL Implementation not valid");
- }
+ QGLMockView glw;
+ if (!glw.isValid())
+ QSKIP("GL is not supported on this platform");
+
+ QOpenGLContext *ctx = glw.context();
+ QVERIFY(ctx != 0);
QGLWindowSurface surface1;
QVERIFY(surface1.surfaceType() == QGLAbstractSurface::Window);
QVERIFY(surface1.window() == 0);
surface1.setWindow(&glw);
- QVERIFY(surface1.window() == &glw);
- QCOMPARE(surface1.viewportRect(), glw.geometry());
+ QCOMPARE(surface1.window(), &glw);
QVERIFY(surface1.activate());
- QVERIFY(QOpenGLContext::currentContext() == &ctx);
+ QVERIFY(QOpenGLContext::currentContext() == ctx);
+
+#ifndef Q_OS_WIN
+ // TODO: these geometry tests are buggy on Windows QPA due to frame
+ // geometry issues - FIXME: http://bugreports.qt-project.org/browse/QTBUG-24539
QCOMPARE(surface1.viewportGL(), QRect(0, 0, glw.width(), glw.height()));
+#endif
surface1.deactivate();
- QVERIFY(QOpenGLContext::currentContext() == &ctx); // Left current.
+ QVERIFY(QOpenGLContext::currentContext() == ctx); // Left current.
+
+ QGLMockView glw2;
+ QOpenGLContext *ctx2 = glw2.context();
- QWindow glw2;
- glw2.setSurfaceType(QWindow::OpenGLSurface);
- QOpenGLContext ctx2;
- ensureContext(glw2, ctx2);
+ // This should have been made current by the QGLMockView constructor
+ QVERIFY(ctx2 != 0);
+ QVERIFY(ctx2 == QOpenGLContext::currentContext());
QGLWindowSurface surface2(&glw2);
+ QVERIFY(surface2.activate());
QVERIFY(surface2.surfaceType() == QGLAbstractSurface::Window);
QVERIFY(surface2.window() == &glw2);
QVERIFY(surface1.activate());
QVERIFY(surface1.switchTo(&surface2));
- QVERIFY(QOpenGLContext::currentContext() == &ctx2);
+ QVERIFY(QOpenGLContext::currentContext() == ctx2);
QVERIFY(surface2.switchTo(&surface1));
- QVERIFY(QOpenGLContext::currentContext() == &ctx);
+ QVERIFY(QOpenGLContext::currentContext() == ctx);
}
void tst_QGLAbstractSurface::fboSurface()
{
+ QGLMockView glw;
+ if (!glw.isValid())
+ QSKIP("GL is not supported on this platform");
+
+ QOpenGLContext *ctx = glw.context();
+ QVERIFY(ctx != 0);
+
if (!QOpenGLFramebufferObject::hasOpenGLFramebufferObjects())
QSKIP("fbo's are not supported");
- QWindow glw;
- glw.setSurfaceType(QWindow::OpenGLSurface);
- QOpenGLContext ctx;
- ensureContext(glw, ctx);
- if (!ctx.isValid())
- QSKIP("GL Implementation not valid");
-
QGLWindowSurface surface1(&glw);
QVERIFY(surface1.activate());
+
+#ifdef Q_OS_WIN
+ // The geometry tests all thru this function will fail til this is fixed
+ QSKIP("Windows QPA bug http://bugreports.qt-project.org/browse/QTBUG-24539");
+#endif
+
QCOMPARE(surface1.viewportGL(), QRect(0, 0, glw.width(), glw.height()));
QOpenGLFramebufferObject fbo1(128, 128);
@@ -167,34 +156,33 @@ void tst_QGLAbstractSurface::fboSurface()
QVERIFY(isFboCurrent(0));
QVERIFY(surface2.activate());
- QVERIFY(QOpenGLContext::currentContext() == &ctx);
+ QVERIFY(QOpenGLContext::currentContext() == ctx);
QVERIFY(isFboCurrent(&fbo1));
+
QCOMPARE(surface2.viewportGL(), QRect(QPoint(0, 0), fbo1.size()));
surface2.deactivate();
QVERIFY(isFboCurrent(0));
- QVERIFY(QOpenGLContext::currentContext() == &ctx);
+ QVERIFY(QOpenGLContext::currentContext() == ctx);
- surface2.setContext(&ctx);
+ surface2.setContext(ctx);
- QWindow glw2;
- glw2.setSurfaceType(QWindow::OpenGLSurface);
- QOpenGLContext ctx2;
- ensureContext(glw2, ctx2);
+ QGLMockView glw2;
+ QOpenGLContext *ctx2 = glw2.context();
QGLWindowSurface surface3(&glw2);
QVERIFY(surface3.activate());
- QVERIFY(QOpenGLContext::currentContext() == &ctx2);
+ QVERIFY(QOpenGLContext::currentContext() == ctx2);
QCOMPARE(surface3.viewportGL(), QRect(0, 0, glw2.width(), glw2.height()));
QVERIFY(surface3.switchTo(&surface2));
QVERIFY(isFboCurrent(&fbo1));
- QVERIFY(QOpenGLContext::currentContext() == &ctx);
+ QVERIFY(QOpenGLContext::currentContext() == ctx);
QCOMPARE(surface2.viewportGL(), QRect(QPoint(0, 0), fbo1.size()));
QVERIFY(surface2.switchTo(&surface3));
QVERIFY(isFboCurrent(0));
- QVERIFY(QOpenGLContext::currentContext() == &ctx2);
+ QVERIFY(QOpenGLContext::currentContext() == ctx2);
QCOMPARE(surface3.viewportGL(), QRect(0, 0, glw2.width(), glw2.height()));
surface3.deactivate();
@@ -212,118 +200,37 @@ void tst_QGLAbstractSurface::fboSurface()
QVERIFY(surface4.viewportGL().isNull());
surface4.setFramebufferObject(&fbo2);
QVERIFY(surface4.framebufferObject() == &fbo2);
- surface4.setContext(&ctx);
+ surface4.setContext(ctx);
QVERIFY(surface1.switchTo(&surface2));
- QVERIFY(QOpenGLContext::currentContext() == &ctx);
+ QCOMPARE(QOpenGLContext::currentContext(), ctx);
QVERIFY(isFboCurrent(&fbo1));
QCOMPARE(surface2.viewportGL(), QRect(QPoint(0, 0), fbo1.size()));
QVERIFY(surface2.switchTo(&surface4));
- QVERIFY(QOpenGLContext::currentContext() == &ctx);
+ QVERIFY(QOpenGLContext::currentContext() == ctx);
QVERIFY(isFboCurrent(&fbo2));
QCOMPARE(surface4.viewportGL(), QRect(QPoint(0, 0), fbo2.size()));
QVERIFY(surface3.switchTo(&surface2));
- QVERIFY(QOpenGLContext::currentContext() == &ctx);
+ QVERIFY(QOpenGLContext::currentContext() == ctx);
QVERIFY(isFboCurrent(&fbo1));
QCOMPARE(surface2.viewportGL(), QRect(QPoint(0, 0), fbo1.size()));
QVERIFY(surface2.switchTo(&surface1));
- QVERIFY(QOpenGLContext::currentContext() == &ctx);
+ QVERIFY(QOpenGLContext::currentContext() == ctx);
QVERIFY(isFboCurrent(0));
QCOMPARE(surface1.viewportGL(), QRect(0, 0, glw.width(), glw.height()));
}
-/*
-void tst_QGLAbstractSurface::pbufferSurface()
+void tst_QGLAbstractSurface::subSurface()
{
- if (!QGLPixelBuffer::hasOpenGLPbuffers())
- QSKIP("pbuffer's are not supported");
-
- QGLWidget glw;
+ QGLMockView glw;
if (!glw.isValid())
- QSKIP("GL Implementation not valid");
-
- QGLWindowSurface surface1(&glw);
- QVERIFY(surface1.activate());
- QCOMPARE(surface1.viewportGL(), QRect(0, 0, glw.width(), glw.height()));
-
- QGLPixelBuffer pbuffer1(128, 128);
- QVERIFY(pbuffer1.handle() != 0);
-
- QGLPixelBufferSurface surface2(&pbuffer1);
- QVERIFY(surface2.surfaceType() == QGLAbstractSurface::PixelBuffer);
- QVERIFY(surface2.pixelBuffer() == &pbuffer1);
- QVERIFY(surface2.device() == &pbuffer1);
-
- QVERIFY(surface2.activate());
- QVERIFY(QOpenGLContext::currentContext() != glw.context());
- const QOpenGLContext *surface2ctx = QOpenGLContext::currentContext();
- QCOMPARE(surface2.viewportGL(), QRect(QPoint(0, 0), pbuffer1.size()));
-
- surface2.deactivate();
- QVERIFY(QOpenGLContext::currentContext() == surface2ctx); // Left current.
-
- QGLWidget glw2;
- QGLWindowSurface surface3(&glw2);
- QVERIFY(surface3.activate());
- QVERIFY(QOpenGLContext::currentContext() == glw2.context());
- QCOMPARE(surface3.viewportGL(), QRect(0, 0, glw2.width(), glw2.height()));
-
- QVERIFY(surface3.switchTo(&surface2));
- QVERIFY(QOpenGLContext::currentContext() == surface2ctx);
- QCOMPARE(surface2.viewportGL(), QRect(QPoint(0, 0), pbuffer1.size()));
-
- QVERIFY(surface2.switchTo(&surface3));
- QVERIFY(QOpenGLContext::currentContext() == glw2.context());
- QCOMPARE(surface3.viewportGL(), QRect(0, 0, glw2.width(), glw2.height()));
-
- surface3.deactivate();
-
- surface1.activate();
- QCOMPARE(surface1.viewportGL(), QRect(0, 0, glw.width(), glw.height()));
-
- QGLPixelBuffer pbuffer2(256, 256);
- QVERIFY(pbuffer2.handle() != 0);
+ QSKIP("GL is not supported on this platform");
- QGLPixelBufferSurface surface4;
- QVERIFY(surface4.surfaceType() == QGLAbstractSurface::PixelBuffer);
- QVERIFY(surface4.pixelBuffer() == 0);
- QVERIFY(surface4.device() == 0);
- QVERIFY(!surface4.activate(0));
- QVERIFY(surface4.viewportGL().isNull());
- surface4.setPixelBuffer(&pbuffer2);
- QVERIFY(surface4.pixelBuffer() == &pbuffer2);
- QVERIFY(surface4.device() == &pbuffer2);
-
- QVERIFY(surface1.switchTo(&surface2));
- QVERIFY(QOpenGLContext::currentContext() == surface2ctx);
- QCOMPARE(surface2.viewportGL(), QRect(QPoint(0, 0), pbuffer1.size()));
-
- QVERIFY(surface2.switchTo(&surface4));
- const QOpenGLContext *surface4ctx = QOpenGLContext::currentContext();
- QVERIFY(surface4ctx != glw.context());
- QVERIFY(surface4ctx != surface2ctx);
- QCOMPARE(surface4.viewportGL(), QRect(QPoint(0, 0), pbuffer2.size()));
-
- QVERIFY(surface4.switchTo(&surface2));
- QVERIFY(QOpenGLContext::currentContext() == surface2ctx);
- QCOMPARE(surface2.viewportGL(), QRect(QPoint(0, 0), pbuffer1.size()));
-
- QVERIFY(surface2.switchTo(&surface1));
- QVERIFY(QOpenGLContext::currentContext() == glw.context());
- QCOMPARE(surface1.viewportGL(), QRect(0, 0, glw.width(), glw.height()));
-}
-*/
-void tst_QGLAbstractSurface::subSurface()
-{
- QWindow glw;
- glw.setSurfaceType(QWindow::OpenGLSurface);
- QOpenGLContext ctx;
- ensureContext(glw, ctx);
- if (!ctx.isValid())
- QSKIP("GL Implementation not valid");
+ QOpenGLContext *ctx = glw.context();
+ QVERIFY(ctx != 0);
QGLWindowSurface surface1(&glw);
@@ -333,7 +240,13 @@ void tst_QGLAbstractSurface::subSurface()
QCOMPARE(surface2.region(), QRect(0, 0, 32, 16));
QVERIFY(surface2.activate());
- QVERIFY(QOpenGLContext::currentContext() == &ctx);
+ QVERIFY(QOpenGLContext::currentContext() == ctx);
+
+#ifdef Q_OS_WIN
+ // The geometry tests all thru this function will fail til this is fixed
+ QSKIP("Windows QPA bug http://bugreports.qt-project.org/browse/QTBUG-24539");
+#endif
+
QCOMPARE(surface2.viewportGL(), QRect(0, glw.height() - 16, 32, 16));
QGLSubsurface surface3(&surface1, QRect(16, 8, 32, 16));
@@ -342,7 +255,7 @@ void tst_QGLAbstractSurface::subSurface()
QCOMPARE(surface3.region(), QRect(16, 8, 32, 16));
QVERIFY(surface2.switchTo(&surface3));
- QVERIFY(QOpenGLContext::currentContext() == &ctx);
+ QVERIFY(QOpenGLContext::currentContext() == ctx);
QCOMPARE(surface3.viewportGL(), QRect(16, glw.height() - (8 + 16), 32, 16));
QGLSubsurface surface4;
@@ -357,7 +270,7 @@ void tst_QGLAbstractSurface::subSurface()
QCOMPARE(surface4.region(), QRect(4, 6, 12, 8));
QVERIFY(surface2.switchTo(&surface4));
- QVERIFY(QOpenGLContext::currentContext() == &ctx);
+ QVERIFY(QOpenGLContext::currentContext() == ctx);
QCOMPARE(surface4.viewportGL(), QRect(16 + 4, glw.height() - (6 + 8 + 8), 12, 8));
}
diff --git a/tests/auto/threed/qglmaterial/tst_qglmaterial.cpp b/tests/auto/threed/qglmaterial/tst_qglmaterial.cpp
index 64257cc8f..986f99384 100644
--- a/tests/auto/threed/qglmaterial/tst_qglmaterial.cpp
+++ b/tests/auto/threed/qglmaterial/tst_qglmaterial.cpp
@@ -118,6 +118,7 @@ TestWidget::TestWidget(QWindow *parent)
, paintDone(false)
, clearColor(Qt::black)
{
+ setGeometry(QRect(0, 0, 100, 100));
QVector3DArray positions;
QVector3DArray normals;
QVector2DArray texCoords;
@@ -236,8 +237,10 @@ void TestWidget::paintGL()
void tst_QGLMaterial::initTestCase()
{
- QSKIP("QWidget: Cannot create a QWidget when no GUI is being used");
widget = new TestWidget();
+ widget->show();
+ if (widget->context() == 0)
+ QSKIP("Could not create valid GL context");
}
void tst_QGLMaterial::cleanupTestCase()
@@ -702,6 +705,8 @@ static QColor litColor(const QGLMaterial &material)
void tst_QGLMaterial::standardMaterialDraw()
{
+ QSKIP("not currently working");
+
if (!widget->context()->isValid())
QSKIP("GL Implementation not valid");
@@ -712,6 +717,8 @@ void tst_QGLMaterial::standardMaterialDraw()
void tst_QGLMaterial::colorMaterialDraw()
{
+ QSKIP("not currently working");
+
if (!widget->context()->isValid())
QSKIP("GL Implementation not valid");
diff --git a/tests/auto/threed/qglvertexbundle/tst_qglvertexbundle.cpp b/tests/auto/threed/qglvertexbundle/tst_qglvertexbundle.cpp
index b8f99d701..6469144a7 100644
--- a/tests/auto/threed/qglvertexbundle/tst_qglvertexbundle.cpp
+++ b/tests/auto/threed/qglvertexbundle/tst_qglvertexbundle.cpp
@@ -40,13 +40,14 @@
****************************************************************************/
#include <QtTest/QtTest>
+#include <QOpenGLContext>
-#include "qglview.h"
#include "qglvertexbundle.h"
#include "qvector2darray.h"
#include "qvector3darray.h"
#include "qvector4darray.h"
#include "qcolor4ub.h"
+#include "qglmockview.h"
class tst_QGLVertexBundle : public QObject
{
@@ -100,10 +101,9 @@ void tst_QGLVertexBundle::interleaved()
// with data before doing this to ensure that the client-side part of
// the buffers can be created at application startup time before an
// actual OpenGL context exists.
- QGLView view;
- view.show();
+ QGLMockView view;
QOpenGLContext *ctx = view.context();
- if (!ctx || !ctx->makeCurrent(&view))
+ if (!ctx || !view.isValid())
QSKIP("Could not create an OpenGL context");
// Upload the bundle and bail out if we couldn't upload it
@@ -152,8 +152,7 @@ void tst_QGLVertexBundle::singleAttribute()
QVERIFY(!bundle.isUploaded());
QCOMPARE(bundle.vertexCount(), 4);
- QGLView view;
- view.show();
+ QGLMockView view;
QOpenGLContext *ctx = view.context();
if (!ctx || !ctx->makeCurrent(&view))
QSKIP("Could not create an OpenGL context");
@@ -184,10 +183,9 @@ void tst_QGLVertexBundle::large()
texCoords.append(index * 5 + 3, index * 5 + 4);
}
- QGLView view;
- view.show();
+ QGLMockView view;
QOpenGLContext *ctx = view.context();
- if (!ctx || !ctx->makeCurrent(&view))
+ if (!ctx || !view.isValid())
QSKIP("Could not create an OpenGL context");
QGLVertexBundle bundle;
@@ -223,10 +221,9 @@ void tst_QGLVertexBundle::otherAttributes()
texCoords.append(15.0f);
texCoords.append(20.0f);
- QGLView view;
- view.show();
+ QGLMockView view;
QOpenGLContext *ctx = view.context();
- if (!ctx || !ctx->makeCurrent(&view))
+ if (!ctx || !view.isValid())
QSKIP("Could not create an OpenGL context");
QGLVertexBundle bundle;
diff --git a/tutorials/quick3d/quick3d.pro b/tutorials/quick3d/quick3d.pro
index 85436d8c2..b0ba92d11 100644
--- a/tutorials/quick3d/quick3d.pro
+++ b/tutorials/quick3d/quick3d.pro
@@ -1,2 +1,2 @@
TEMPLATE = subdirs
-SUBDIRS += shaders teapot_bounce_qml teapot_qml
+SUBDIRS += shadertut teapot_bounce_qml teapot_qml
diff --git a/tutorials/quick3d/shadertut/main.cpp b/tutorials/quick3d/shadertut/main.cpp
new file mode 100644
index 000000000..cfef8c94f
--- /dev/null
+++ b/tutorials/quick3d/shadertut/main.cpp
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "../qmlres.h"
+
+QUICK3D_EXAMPLE_MAIN("qml/shader-tutorial.qml")
diff --git a/tutorials/quick3d/shadertut/TutorialTeapot.qml b/tutorials/quick3d/shadertut/qml/TutorialTeapot.qml
index 246aa2675..246aa2675 100644
--- a/tutorials/quick3d/shadertut/TutorialTeapot.qml
+++ b/tutorials/quick3d/shadertut/qml/TutorialTeapot.qml
diff --git a/tutorials/quick3d/shadertut/meshes/teapot.bez b/tutorials/quick3d/shadertut/qml/meshes/teapot.bez
index 02b2ac447..02b2ac447 100644
--- a/tutorials/quick3d/shadertut/meshes/teapot.bez
+++ b/tutorials/quick3d/shadertut/qml/meshes/teapot.bez
diff --git a/tutorials/quick3d/shadertut/shader-tutorial-1-textures.qml b/tutorials/quick3d/shadertut/qml/shader-tutorial-1-textures.qml
index 2be310ef1..2be310ef1 100644
--- a/tutorials/quick3d/shadertut/shader-tutorial-1-textures.qml
+++ b/tutorials/quick3d/shadertut/qml/shader-tutorial-1-textures.qml
diff --git a/tutorials/quick3d/shadertut/shader-tutorial-2-vertex-shader.qml b/tutorials/quick3d/shadertut/qml/shader-tutorial-2-vertex-shader.qml
index 49137ea6f..49137ea6f 100644
--- a/tutorials/quick3d/shadertut/shader-tutorial-2-vertex-shader.qml
+++ b/tutorials/quick3d/shadertut/qml/shader-tutorial-2-vertex-shader.qml
diff --git a/tutorials/quick3d/shadertut/shader-tutorial-3-transformed-coordinates.qml b/tutorials/quick3d/shadertut/qml/shader-tutorial-3-transformed-coordinates.qml
index efe4aabb2..efe4aabb2 100644
--- a/tutorials/quick3d/shadertut/shader-tutorial-3-transformed-coordinates.qml
+++ b/tutorials/quick3d/shadertut/qml/shader-tutorial-3-transformed-coordinates.qml
diff --git a/tutorials/quick3d/shadertut/shader-tutorial-lighting.qml b/tutorials/quick3d/shadertut/qml/shader-tutorial-lighting.qml
index 87a55d613..87a55d613 100644
--- a/tutorials/quick3d/shadertut/shader-tutorial-lighting.qml
+++ b/tutorials/quick3d/shadertut/qml/shader-tutorial-lighting.qml
diff --git a/tutorials/quick3d/shadertut/shader-tutorial-varying.qml b/tutorials/quick3d/shadertut/qml/shader-tutorial-varying.qml
index fea323167..fea323167 100644
--- a/tutorials/quick3d/shadertut/shader-tutorial-varying.qml
+++ b/tutorials/quick3d/shadertut/qml/shader-tutorial-varying.qml
diff --git a/tutorials/quick3d/shadertut/shader-tutorial.qml b/tutorials/quick3d/shadertut/qml/shader-tutorial.qml
index b5e83227f..b5e83227f 100644
--- a/tutorials/quick3d/shadertut/shader-tutorial.qml
+++ b/tutorials/quick3d/shadertut/qml/shader-tutorial.qml
diff --git a/tutorials/quick3d/shadertut/shaders.pro b/tutorials/quick3d/shadertut/shaders.pro
deleted file mode 100644
index e33763fb7..000000000
--- a/tutorials/quick3d/shadertut/shaders.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-TEMPLATE = subdirs
-
-# These examples contain no C++ and can simply be copied
-sources.files = .
-
-sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials
-INSTALLS += sources
diff --git a/tutorials/quick3d/shadertut/shadertut.pro b/tutorials/quick3d/shadertut/shadertut.pro
new file mode 100644
index 000000000..614d697e7
--- /dev/null
+++ b/tutorials/quick3d/shadertut/shadertut.pro
@@ -0,0 +1,41 @@
+TEMPLATE = app
+TARGET = shadertut
+CONFIG += qt warn_on
+QT += declarative quick
+
+SOURCES += main.cpp
+
+ICON_FILE = ../icon.png
+
+QML_FILES = \
+ qml/TutorialTeapot.qml \
+ qml/shader-tutorial-1-textures.qml \
+ qml/shader-tutorial-3-transformed-coordinates.qml \
+ qml/shader-tutorial-varying.qml \
+ qml/shader-tutorial-2-vertex-shader.qml \
+ qml/shader-tutorial-lighting.qml \
+ qml/shader-tutorial.qml
+
+QML_INFRA_FILES = \
+ $$QML_FILES \
+ qml/basket.jpg
+
+QML_MESHES_FILES = \
+ qml/meshes/teapot.bez
+
+CATEGORY = examples
+include(../../../pkg.pri)
+
+INSTALL_DIRS = qml
+mt: INSTALL_FILES = mt.qml
+
+OTHER_FILES += \
+ mt.qml \
+ basket_qml.rc \
+ $$QML_INFRA_FILES
+
+RC_FILE = basket_qml.rc
+
+RESOURCES += \
+ basket.qrc
+