| 1 |
// Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies). |
| 2 |
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 |
|
| 4 |
import QtQuick 2.2 |
| 5 |
import QtQuick.Layouts 1.3 |
| 6 |
import QtQuick.Controls 2.12 |
| 7 |
import Qt3D.Render 2.9 |
| 8 |
import QtQuick.Scene3D 2.0 |
| 9 |
|
| 10 |
Item { |
| 11 |
|
| 12 |
width: 1250 |
| 13 |
height: 700 |
| 14 |
|
| 15 |
RowLayout { |
| 16 |
anchors.fill: parent |
| 17 |
anchors.margins: 10 |
| 18 |
|
| 19 |
Rectangle { |
| 20 |
id: background |
| 21 |
width: 600 |
| 22 |
height: 600 |
| 23 |
|
| 24 |
color: "blue" |
| 25 |
|
| 26 |
Scene3D { |
| 27 |
id: scene3d |
| 28 |
anchors.fill: parent |
| 29 |
multisample: msacheckbox.checked |
| 30 |
|
| 31 |
aspects: ["input", "logic"] |
| 32 |
|
| 33 |
CaptureScene { |
| 34 |
id: scene |
| 35 |
} |
| 36 |
} |
| 37 |
} |
| 38 |
|
| 39 |
ColumnLayout { |
| 40 |
|
| 41 |
Button { |
| 42 |
id: button |
| 43 |
text: "Render Capture" |
| 44 |
|
| 45 |
property var reply |
| 46 |
property bool continuous : checkbox.checked |
| 47 |
property int cid: 1 |
| 48 |
|
| 49 |
function doRenderCapture() |
| 50 |
{ |
| 51 |
reply = scene.requestRenderCapture() |
| 52 |
console.log(reply) |
| 53 |
reply.completed.connect(onRenderCaptureComplete) |
| 54 |
} |
| 55 |
|
| 56 |
function onRenderCaptureComplete() |
| 57 |
{ |
| 58 |
_renderCaptureProvider.updateImage(reply) |
| 59 |
image.source = "image://rendercapture/" + cid |
| 60 |
reply.saveImage("capture" + cid + ".png") |
| 61 |
reply.destroy() |
| 62 |
cid++ |
| 63 |
if (continuous === true) |
| 64 |
doRenderCapture() |
| 65 |
} |
| 66 |
|
| 67 |
onClicked: doRenderCapture() |
| 68 |
} |
| 69 |
RowLayout { |
| 70 |
CheckBox { |
| 71 |
id: checkbox |
| 72 |
text: "continuous" |
| 73 |
} |
| 74 |
CheckBox { |
| 75 |
id: msacheckbox |
| 76 |
text: "multisample" |
| 77 |
} |
| 78 |
} |
| 79 |
Image { |
| 80 |
id: image |
| 81 |
cache: false |
| 82 |
source: "image://rendercapture/0" |
| 83 |
Layout.maximumWidth: 600 |
| 84 |
Layout.minimumWidth: 600 |
| 85 |
Layout.maximumHeight: 600 |
| 86 |
Layout.minimumHeight: 600 |
| 87 |
} |
| 88 |
} |
| 89 |
} |
| 90 |
} |