summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorChristian Strømme <christian.stromme@qt.io>2018-08-27 22:30:47 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2018-09-20 15:14:57 +0000
commit59923f7725c82ac31c1245a36bd3b1be9bec3cd7 (patch)
tree93dc674e29797ce661090898c46b72c39292dbbe /tests
parent99ea7a57e452c82fd8e62271c5499bc392735f2b (diff)
Add some new types and an example using the QML APIs
Contains some basic types for getting the ball rolling, and isn't very usable outside that. Change-Id: Ib4c186e26d7bd142a9fe51bd74ea54a7bf5fd691 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/manual/manual.pro3
-rw-r--r--tests/manual/qml3dapi/main.cpp75
-rw-r--r--tests/manual/qml3dapi/main.qml132
-rw-r--r--tests/manual/qml3dapi/qml3dapi.pro11
-rw-r--r--tests/manual/qml3dapi/qml3dapi.qrc5
5 files changed, 225 insertions, 1 deletions
diff --git a/tests/manual/manual.pro b/tests/manual/manual.pro
index e2a6b4a..28fa4f4 100644
--- a/tests/manual/manual.pro
+++ b/tests/manual/manual.pro
@@ -8,5 +8,6 @@ qtHaveModule(widgets) {
qtHaveModule(quick) {
SUBDIRS += \
layersinquick \
- pureqml3d
+ pureqml3d \
+ qml3dapi
}
diff --git a/tests/manual/qml3dapi/main.cpp b/tests/manual/qml3dapi/main.cpp
new file mode 100644
index 0000000..01250bb
--- /dev/null
+++ b/tests/manual/qml3dapi/main.cpp
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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 The Qt Company Ltd 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 <QGuiApplication>
+#include <QQuickView>
+#include <q3dsruntimeglobal.h>
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+ qputenv("QSG_INFO", "1");
+ QGuiApplication app(argc, argv);
+
+ // Use the ideal format (i.e. OpenGL version and profile) recommended by
+ // the Qt 3D Studio runtime. Without this the format set on the QQuickView
+ // would be used instead.
+ QSurfaceFormat::setDefaultFormat(Q3DS::surfaceFormat());
+
+ QQuickView viewer;
+ viewer.setSource(QUrl("qrc:/main.qml"));
+
+ viewer.setTitle(QStringLiteral("Qt 3D Studio QML Example"));
+ viewer.setResizeMode(QQuickView::SizeRootObjectToView);
+ viewer.resize(1280, 600);
+ viewer.show();
+
+ return app.exec();
+}
diff --git a/tests/manual/qml3dapi/main.qml b/tests/manual/qml3dapi/main.qml
new file mode 100644
index 0000000..2a131bf
--- /dev/null
+++ b/tests/manual/qml3dapi/main.qml
@@ -0,0 +1,132 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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 The Qt Company Ltd 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtStudio3D 2.1
+import QtQuick.Controls 2.2
+import QtQuick.Layouts 1.0
+
+Rectangle {
+ id: root
+ color: "lightGray"
+
+ Studio3DEngine {
+ id: s3d
+ }
+
+ Rectangle {
+ border.color: "black"
+ border.width: 4
+ color: "transparent"
+ anchors.fill: parent
+
+ Layer3D {
+ engine: s3d
+ anchors.fill: parent
+ Camera3D {
+ id: camera
+ position: Qt.vector3d(0, 0, -500)
+ }
+
+ Light3D {
+ id: light
+ position: Qt.vector3d(0, 200, 0)
+ Model3D {
+ id: lightModel
+ mesh: "#Sphere"
+ scale: Qt.vector3d(0.3, 0.3, 0.3)
+ }
+
+ SequentialAnimation on position {
+ loops: Animation.Infinite
+ PropertyAnimation { duration: 2000; to: Qt.vector3d(500, 200, 0) }
+ PropertyAnimation { duration: 2000; to: Qt.vector3d(-500, 200, 0) }
+ }
+ }
+
+ Model3D {
+ id: model
+ mesh: "#Cube"
+ visible: true
+ anchors.fill: parent
+
+ scale: Qt.vector3d(1, 1, 1);
+ SequentialAnimation on rotation {
+ loops: Animation.Infinite
+ PropertyAnimation { duration: 2000; to: Qt.vector3d(0, 360, 360) }
+ }
+ }
+ }
+ }
+
+ Button {
+ anchors.bottom: parent.bottom
+ text: "Profile UI"
+ onClicked: {
+ prof.visible = !prof.visible
+ }
+ focusPolicy: Qt.NoFocus
+ }
+
+ Rectangle {
+ id: prof
+ visible: false
+ anchors.fill: parent
+ anchors.margins: 40
+ border.color: "green"
+ border.width: 4
+ color: "transparent"
+
+ Studio3DProfiler {
+ anchors.fill: parent
+ focus: true
+ }
+ }
+}
diff --git a/tests/manual/qml3dapi/qml3dapi.pro b/tests/manual/qml3dapi/qml3dapi.pro
new file mode 100644
index 0000000..e770de6
--- /dev/null
+++ b/tests/manual/qml3dapi/qml3dapi.pro
@@ -0,0 +1,11 @@
+TARGET = qml3dapi
+
+QT += quick 3dstudioruntime2
+
+SOURCES += \
+ main.cpp
+
+RESOURCES += qml3dapi.qrc
+
+OTHER_FILES += \
+ main.qml
diff --git a/tests/manual/qml3dapi/qml3dapi.qrc b/tests/manual/qml3dapi/qml3dapi.qrc
new file mode 100644
index 0000000..5f6483a
--- /dev/null
+++ b/tests/manual/qml3dapi/qml3dapi.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>main.qml</file>
+ </qresource>
+</RCC>