diff options
author | Sean Harmer <sean.harmer@kdab.com> | 2017-08-19 15:53:30 +0100 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2017-08-19 16:28:52 +0100 |
commit | 8f863343a9e2e2f3630f22407f4e5e30e72745cf (patch) | |
tree | 5574e3c2215d74345e15df5f45ed3211e065541a /tests/manual | |
parent | 3edb85002b848033bbeefa33001d19fb514ef489 (diff) | |
parent | 9d8c9ada161ad97634992c444196add0abb4f9d1 (diff) |
Merge branch '5.9' into dev
Conflicts:
src/render/backend/renderer.cpp
src/render/backend/renderview.cpp
src/render/graphicshelpers/graphicscontext_p.h
src/render/graphicshelpers/graphicshelperes2_p.h
src/render/graphicshelpers/graphicshelpergl2_p.h
src/render/graphicshelpers/graphicshelpergl3_2_p.h
src/render/graphicshelpers/graphicshelpergl3_3_p.h
src/render/graphicshelpers/graphicshelpergl4_p.h
src/render/graphicshelpers/graphicshelperinterface_p.h
src/render/jobs/pickboundingvolumejob.cpp
tests/auto/animation/clipanimator/tst_clipanimator.cpp
tests/auto/auto.pro
tests/manual/manual.pro
Also disabled the QQmlMetaType codepaths following commit
49a11e882059ee1729f776722e085dd21d378c36 in qtdeclarative. The
QQmlMetaType codepaths will be re-enabled once a qt5.git
integration has succeeded.
Change-Id: Ia654d75425e6d406c472d19864383612208cad2b
Diffstat (limited to 'tests/manual')
-rw-r--r-- | tests/manual/deferred-renderer-qml/SceneEffect.qml | 16 | ||||
-rw-r--r-- | tests/manual/deferred-renderer-qml/SceneEntity.qml | 59 | ||||
-rw-r--r-- | tests/manual/deferred-renderer-qml/ScreenQuadEntity.qml | 98 | ||||
-rw-r--r-- | tests/manual/deferred-renderer-qml/deferred-renderer-qml.pro | 2 | ||||
-rw-r--r-- | tests/manual/deferred-renderer-qml/main.qml | 9 | ||||
-rw-r--r-- | tests/manual/manual.pro | 3 | ||||
-rw-r--r-- | tests/manual/rendercapture-qml-fbo/CaptureScene.qml | 210 | ||||
-rw-r--r-- | tests/manual/rendercapture-qml-fbo/main.cpp | 75 | ||||
-rw-r--r-- | tests/manual/rendercapture-qml-fbo/main.qml | 136 | ||||
-rw-r--r-- | tests/manual/rendercapture-qml-fbo/qml.qrc | 6 | ||||
-rw-r--r-- | tests/manual/rendercapture-qml-fbo/rendercapture-qml-fbo.pro | 18 | ||||
-rw-r--r-- | tests/manual/rendercapture-qml-fbo/rendercaptureprovider.h | 85 |
12 files changed, 653 insertions, 64 deletions
diff --git a/tests/manual/deferred-renderer-qml/SceneEffect.qml b/tests/manual/deferred-renderer-qml/SceneEffect.qml index 3ec1983fe..0ca081355 100644 --- a/tests/manual/deferred-renderer-qml/SceneEffect.qml +++ b/tests/manual/deferred-renderer-qml/SceneEffect.qml @@ -72,15 +72,15 @@ Effect { out vec3 normal0; uniform mat4 mvp; - uniform mat4 modelView; - uniform mat3 modelViewNormal; + uniform mat4 modelMatrix; + uniform mat3 modelNormalMatrix; uniform vec4 meshColor; void main() { color0 = meshColor; - position0 = vec3(modelView * vertexPosition); - normal0 = normalize(modelViewNormal * vertexNormal); + position0 = vec3(modelMatrix * vertexPosition); + normal0 = normalize(modelNormalMatrix * vertexNormal); gl_Position = mvp * vertexPosition; } " @@ -123,15 +123,15 @@ Effect { varying vec3 normal0; uniform mat4 mvp; - uniform mat4 modelView; - uniform mat3 modelViewNormal; + uniform mat4 modelMatrix; + uniform mat3 modelNormalMatrix; uniform vec4 meshColor; void main() { color0 = meshColor; - position0 = vec3(modelView * vertexPosition); - normal0 = normalize(modelViewNormal * vertexNormal); + position0 = vec3(modelMatrix * vertexPosition); + normal0 = normalize(modelNormalMatrix * vertexNormal); gl_Position = mvp * vertexPosition; } " diff --git a/tests/manual/deferred-renderer-qml/SceneEntity.qml b/tests/manual/deferred-renderer-qml/SceneEntity.qml index 001a24854..6a34be7fb 100644 --- a/tests/manual/deferred-renderer-qml/SceneEntity.qml +++ b/tests/manual/deferred-renderer-qml/SceneEntity.qml @@ -48,15 +48,26 @@ Entity { readonly property Camera camera: camera readonly property Layer layer: sceneLayer + readonly property vector3d light1Pos : sphere1.transform.translation + readonly property vector3d light2Pos : sphere2.transform.translation + readonly property vector3d light3Pos : light3Transform.translation + readonly property vector3d light4Pos : Qt.vector3d(5, 2, 7) + property PointLight light: PointLight { color : "white" - intensity : 4.0 + intensity : 0.0 QQ2.ColorAnimation on color { from: "white"; to: "blue"; duration: 4000; loops: 2 } - QQ2.NumberAnimation on intensity { from: 0; to: 5.0; duration: 1000; loops: QQ2.Animation.Infinite } + QQ2.SequentialAnimation on intensity { + QQ2.NumberAnimation { + from: 0; to: 3.0; duration: 500 + } + QQ2.NumberAnimation { + from: 3.0; to: 0.0; duration: 500 + } + loops: QQ2.Animation.Infinite + } } - components: [ root.light ] - // Global elements Camera { id: camera @@ -97,21 +108,15 @@ Entity { QQ2.SequentialAnimation { loops: QQ2.Animation.Infinite - running: false - QQ2.NumberAnimation { target: sphere1Transform; property: "x"; to: 6; duration: 2000 } - QQ2.NumberAnimation { target: sphere1Transform; property: "x"; to: -10; duration: 2000 } - } - - property PointLight light : PointLight { - color : "green" - intensity : 0.3 + running: true + QQ2.NumberAnimation { target: sphere1Transform; property: "x"; to: 3; duration: 2000 } + QQ2.NumberAnimation { target: sphere1Transform; property: "x"; to: -5; duration: 2000 } } components : [ sphereMesh, sphere1.material, sphere1.transform, - sphere1.light, sceneLayer ] } @@ -124,11 +129,6 @@ Entity { parameters : Parameter { name : "meshColor"; value : "green" } } - property PointLight light : PointLight { - color : "orange" - intensity : 0.7 - } - property Transform transform: Transform { translation: Qt.vector3d(5, 0, 5) } @@ -137,17 +137,12 @@ Entity { sphereMesh, sphere2.transform, sphere2.material, - sphere2.light, sceneLayer ] } Entity { id: light3 - property PointLight light : PointLight { - color : "white" - intensity : 0.5 - } property Material material : Material { effect : sceneMaterialEffect @@ -170,26 +165,8 @@ Entity { components: [ sphereMesh, light3.material, - light3.light, light3.transform, sceneLayer ] } - - Entity { - id: light4 - property PointLight light : PointLight { - color : "white" - intensity : 0.2 - } - property Transform transform: Transform { - translation: Qt.vector3d(5, 2, 7) - } - - components: [ - light4.light, - light4.transform, - sceneLayer - ] - } } diff --git a/tests/manual/deferred-renderer-qml/ScreenQuadEntity.qml b/tests/manual/deferred-renderer-qml/ScreenQuadEntity.qml index 6c5284d5e..3dae2b79a 100644 --- a/tests/manual/deferred-renderer-qml/ScreenQuadEntity.qml +++ b/tests/manual/deferred-renderer-qml/ScreenQuadEntity.qml @@ -42,23 +42,95 @@ import Qt3D.Render 2.0 import Qt3D.Extras 2.0 Entity { + id: root + readonly property Layer layer: screenQuadLayer + property PointLight baseLight + property vector3d light1Pos + property vector3d light2Pos + property vector3d light3Pos + property vector3d light4Pos - components : [ - Layer { id: screenQuadLayer }, + Entity { + components: [ + baseLight, + layer + ] + } - PlaneMesh { - width: 2.0 - height: 2.0 - meshResolution: Qt.size(2, 2) - }, + Entity { + readonly property Transform transform1 : Transform { translation: root.light1Pos } + readonly property PointLight light1 : PointLight { + color : "dodgerblue" + intensity : 0.9 + } + components: [ + transform1, + light1, + layer + ] + } - Transform { // We rotate the plane so that it faces us - rotation: fromAxisAndAngle(Qt.vector3d(1, 0, 0), 90) - }, + Entity { + readonly property Transform transform2 : Transform { translation: root.light2Pos } + readonly property PointLight light2 : PointLight { + color : "green" + intensity : 0.5 + } + components: [ + transform2, + light2, + layer + ] + } + + Entity { + readonly property Transform transform3 : Transform { translation: root.light3Pos } + readonly property PointLight light3 : PointLight { + color : "white" + intensity : 2.0 + } + components: [ + transform3, + light3, + layer + ] + } - Material { - effect : FinalEffect {} + Entity { + readonly property Transform transform4 : Transform { translation: root.light4Pos } + readonly property PointLight light4 : PointLight { + color : "white" + intensity : 0.5 } - ] + components: [ + transform4, + light4, + layer + ] + } + + // We need to have the actual screen quad entity separate from the lights. + // If the lights were sub-entities of this screen quad entity, they would + // be affected by the rotation matrix, and their world positions would thus + // be changed. + Entity { + components : [ + Layer { id: screenQuadLayer }, + + PlaneMesh { + width: 2.0 + height: 2.0 + meshResolution: Qt.size(2, 2) + }, + + Transform { // We rotate the plane so that it faces us + rotation: fromAxisAndAngle(Qt.vector3d(1, 0, 0), 90) + }, + + Material { + effect : FinalEffect {} + } + ] + } } diff --git a/tests/manual/deferred-renderer-qml/deferred-renderer-qml.pro b/tests/manual/deferred-renderer-qml/deferred-renderer-qml.pro index 8f7dc12d5..8db1d6dcf 100644 --- a/tests/manual/deferred-renderer-qml/deferred-renderer-qml.pro +++ b/tests/manual/deferred-renderer-qml/deferred-renderer-qml.pro @@ -12,6 +12,8 @@ OTHER_FILES += \ DeferredRenderer.qml \ FinalEffect.qml \ SceneEffect.qml \ + SceneEntity.qml \ + ScreenQuadEntity.qml \ GBuffer.qml RESOURCES += \ diff --git a/tests/manual/deferred-renderer-qml/main.qml b/tests/manual/deferred-renderer-qml/main.qml index 790911723..8b97bb671 100644 --- a/tests/manual/deferred-renderer-qml/main.qml +++ b/tests/manual/deferred-renderer-qml/main.qml @@ -74,7 +74,14 @@ Entity { FirstPersonCameraController { camera: sceneEntity.camera } - ScreenQuadEntity { id: screenQuadEntity } + ScreenQuadEntity { + id: screenQuadEntity + baseLight: sceneEntity.light + light1Pos: sceneEntity.light1Pos + light2Pos: sceneEntity.light2Pos + light3Pos: sceneEntity.light3Pos + light4Pos: sceneEntity.light4Pos + } SceneEntity { id: sceneEntity } GBufferDebugger { id: debugEntity } } diff --git a/tests/manual/manual.pro b/tests/manual/manual.pro index 7c6d2390b..8501a41af 100644 --- a/tests/manual/manual.pro +++ b/tests/manual/manual.pro @@ -53,7 +53,8 @@ SUBDIRS += \ animation-keyframe-programmatic \ layerfilter-qml \ skinned-mesh \ - proximityfilter + proximityfilter \ + rendercapture-qml-fbo qtHaveModule(widgets): { SUBDIRS += \ diff --git a/tests/manual/rendercapture-qml-fbo/CaptureScene.qml b/tests/manual/rendercapture-qml-fbo/CaptureScene.qml new file mode 100644 index 000000000..9c6cb1431 --- /dev/null +++ b/tests/manual/rendercapture-qml-fbo/CaptureScene.qml @@ -0,0 +1,210 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $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.2 as QQ2 +import Qt3D.Core 2.0 +import Qt3D.Render 2.1 +import Qt3D.Input 2.0 +import Qt3D.Extras 2.0 + +Entity { + id: sceneRoot + + function requestRenderCapture() + { + return renderCapture.requestCapture() + } + + Camera { + id: camera + projectionType: CameraLens.PerspectiveProjection + fieldOfView: 45 + aspectRatio: 1 + nearPlane : 0.1 + farPlane : 1000.0 + position: Qt.vector3d(100.0, 100.0, 20.0) + upVector: Qt.vector3d( 0.0, 1.0, 0.0 ) + viewCenter: Qt.vector3d(0.0, 0.0, -8.0) + } + + Camera { + id: camera2 + projectionType: CameraLens.PerspectiveProjection + fieldOfView: 15 + aspectRatio: 1 + nearPlane : 0.1 + farPlane : 1000.0 + position: Qt.vector3d( 0.0, 0.0, -40.0 ) + upVector: Qt.vector3d( 0.0, 1.0, 0.0 ) + viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 ) + } + + OrbitCameraController { + camera: camera + } + + components: [ + RenderSettings { + activeFrameGraph: RenderSurfaceSelector { + Viewport { + normalizedRect: Qt.rect(0, 0, 1, 1) + + // Clear Back Buffer + ClearBuffers { + buffers: ClearBuffers.ColorDepthBuffer + clearColor: Qt.rgba(0, 0.5, 1, 1) + NoDraw { } + } + + // Render to back buffer + CameraSelector { + camera: camera + } + + // FBO + RenderTargetSelector { + target: RenderTarget { + attachments: [ + RenderTargetOutput { + attachmentPoint: RenderTargetOutput.Color0 + texture: Texture2D { + id: colorTexture + width: 400 + height: 400 + format: Texture.RGBAFormat + generateMipMaps: false + magnificationFilter: Texture.Linear + minificationFilter: Texture.Linear + wrapMode { + x: WrapMode.ClampToEdge + y: WrapMode.ClampToEdge + } + } + } + ] + } + // Clear FBO + ClearBuffers { + buffers: ClearBuffers.ColorDepthBuffer + clearColor: Qt.rgba(0, 0.5, 0.5, 1) + NoDraw { } + } + + // Render into FBO + CameraSelector { + camera: camera + // Render Capture + RenderCapture { + id: renderCapture + } + } + } + } + } + }, + // Event Source will be set by the Qt3DQuickWindow + InputSettings { } + ] + + PhongMaterial { + id: material + } + + TorusMesh { + id: torusMesh + radius: 5 + minorRadius: 1 + rings: 100 + slices: 20 + } + + Transform { + id: torusTransform + scale3D: Qt.vector3d(1.5, 1, 0.5) + rotation: fromAxisAndAngle(Qt.vector3d(1, 0, 0), 45) + } + + Entity { + id: torusEntity + components: [ torusMesh, material, torusTransform ] + } + + SphereMesh { + id: sphereMesh + radius: 3 + } + + Transform { + id: sphereTransform + property real userAngle: 0.0 + matrix: { + var m = Qt.matrix4x4(); + m.rotate(userAngle, Qt.vector3d(0, 1, 0)); + m.translate(Qt.vector3d(20, 0, 0)); + return m; + } + } + + QQ2.NumberAnimation { + target: sphereTransform + property: "userAngle" + duration: 10000 + from: 0 + to: 360 + + loops: QQ2.Animation.Infinite + running: true + } + + Entity { + id: sphereEntity + components: [ sphereMesh, material, sphereTransform ] + } +} diff --git a/tests/manual/rendercapture-qml-fbo/main.cpp b/tests/manual/rendercapture-qml-fbo/main.cpp new file mode 100644 index 000000000..5c581c88e --- /dev/null +++ b/tests/manual/rendercapture-qml-fbo/main.cpp @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). +** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $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 <QQuickItem> +#include <QQuickView> +#include <Qt3DQuick/QQmlAspectEngine> +#include <QGuiApplication> +#include <QQmlEngine> +#include <QQmlContext> +#include "rendercaptureprovider.h" + + +int main(int argc, char* argv[]) +{ + QGuiApplication app(argc, argv); + QQuickView view; + RenderCaptureProvider *provider = new RenderCaptureProvider; + qmlRegisterType<RenderCaptureProvider>("Extras", 1, 0, "RenderCaptureProvider"); + + view.engine()->rootContext()->setContextProperty("_renderCaptureProvider", provider); + view.engine()->addImageProvider("rendercapture", provider); + + view.setSource(QUrl("qrc:/main.qml")); + view.show(); + + return app.exec(); +} diff --git a/tests/manual/rendercapture-qml-fbo/main.qml b/tests/manual/rendercapture-qml-fbo/main.qml new file mode 100644 index 000000000..49ccbf7ea --- /dev/null +++ b/tests/manual/rendercapture-qml-fbo/main.qml @@ -0,0 +1,136 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $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.2 +import QtQuick.Layouts 1.3 +import QtQuick.Controls 2.0 +import Qt3D.Render 2.1 +import QtQuick.Scene3D 2.0 + +Item { + + width: 1250 + height: 700 + + RowLayout { + anchors.fill: parent + anchors.margins: 10 + + Rectangle { + id: background + width: 600 + height: 600 + + color: "blue" + + Scene3D { + id: scene3d + anchors.fill: parent + multisample: msacheckbox.checked + + aspects: ["input", "logic"] + + CaptureScene { + id: scene + } + } + } + + ColumnLayout { + + Button { + id: button + anchors.top: parent.top + text: "Render Capture" + + property var reply + property bool continuous : checkbox.checked + property int cid: 1 + + function doRenderCapture() + { + reply = scene.requestRenderCapture() + reply.completeChanged.connect(onRenderCaptureComplete) + } + + function onRenderCaptureComplete() + { + _renderCaptureProvider.updateImage(reply) + image.source = "image://rendercapture/" + cid + reply.saveImage("capture.png") + cid++ + if (continuous === true) + doRenderCapture() + } + + onClicked: doRenderCapture() + } + RowLayout { + CheckBox { + id: checkbox + text: "continuous" + } + CheckBox { + id: msacheckbox + text: "multisample" + } + } + Image { + id: image + cache: false + source: "image://rendercapture/0" + Layout.maximumWidth: 600 + Layout.minimumWidth: 600 + Layout.maximumHeight: 600 + Layout.minimumHeight: 600 + } + } + } +} diff --git a/tests/manual/rendercapture-qml-fbo/qml.qrc b/tests/manual/rendercapture-qml-fbo/qml.qrc new file mode 100644 index 000000000..310d6dfe3 --- /dev/null +++ b/tests/manual/rendercapture-qml-fbo/qml.qrc @@ -0,0 +1,6 @@ +<RCC> + <qresource prefix="/"> + <file>main.qml</file> + <file>CaptureScene.qml</file> + </qresource> +</RCC> diff --git a/tests/manual/rendercapture-qml-fbo/rendercapture-qml-fbo.pro b/tests/manual/rendercapture-qml-fbo/rendercapture-qml-fbo.pro new file mode 100644 index 000000000..bea0fc867 --- /dev/null +++ b/tests/manual/rendercapture-qml-fbo/rendercapture-qml-fbo.pro @@ -0,0 +1,18 @@ +!include( ../manual.pri ) { + error( "Couldn't find the manual.pri file!" ) +} + +QT += 3dcore 3drender 3dinput 3dextras 3dquick 3dlogic qml quick 3dquickextras + +SOURCES += \ + main.cpp + +DISTFILES += \ + main.qml + +RESOURCES += \ + qml.qrc + +HEADERS += \ + rendercaptureprovider.h + diff --git a/tests/manual/rendercapture-qml-fbo/rendercaptureprovider.h b/tests/manual/rendercapture-qml-fbo/rendercaptureprovider.h new file mode 100644 index 000000000..d04dbd276 --- /dev/null +++ b/tests/manual/rendercapture-qml-fbo/rendercaptureprovider.h @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $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$ +** +****************************************************************************/ + +#ifndef RENDERCAPTUREPROVIDER_H +#define RENDERCAPTUREPROVIDER_H + +#include <QtQuick/QQuickImageProvider> +#include <Qt3DRender/QRenderCapture> + +class RenderCaptureProvider : public QObject, public QQuickImageProvider +{ + Q_OBJECT +public: + RenderCaptureProvider() + : QObject(), QQuickImageProvider(Image) + { + m_image = QImage(10,10, QImage::Format_ARGB32); + m_image.fill(QColor("blue").rgba()); + } + + Q_INVOKABLE void updateImage(Qt3DRender::QRenderCaptureReply *reply) + { + m_image = reply->image(); + } + + virtual QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize) + { + Q_UNUSED(id) + Q_UNUSED(requestedSize) + *size = m_image.size(); + return m_image; + } + +private: + QImage m_image; +}; + +#endif |