Debian Codegraph @

tests/manual/blitframebuffer-qml/main.qml

raw
1 // Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB).
2 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4 import QtQuick 2.2 as QQ2
5 import Qt3D.Core 2.0
6 import Qt3D.Render 2.10
7 import Qt3D.Input 2.0
8 import Qt3D.Extras 2.0
9
10 Entity {
11 id: sceneRoot
12
13 Camera {
14 id: camera
15 projectionType: CameraLens.PerspectiveProjection
16 fieldOfView: 45
17 aspectRatio: 16/9
18 nearPlane : 0.1
19 farPlane : 1000.0
20 position: Qt.vector3d( 0.0, 0.0, -40.0 )
21 upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
22 viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
23 }
24
25 RenderTarget {
26 id: intermediateRenderTarget
27 attachments : [
28 RenderTargetOutput {
29 objectName : "color"
30 attachmentPoint : RenderTargetOutput.Color0
31 texture : Texture2D {
32 id : colorAttachment0
33 width : 1024
34 height : 768
35 format : Texture.R32F
36 generateMipMaps : false
37 magnificationFilter : Texture.Linear
38 minificationFilter : Texture.Linear
39 wrapMode {
40 x: WrapMode.ClampToEdge
41 y: WrapMode.ClampToEdge
42 }
43 }
44 },
45 RenderTargetOutput {
46 objectName : "color"
47 attachmentPoint : RenderTargetOutput.Color1
48 texture : Texture2D {
49 id : colorAttachment1
50 width : 1024
51 height : 1024
52 format : Texture.R32F
53 generateMipMaps : false
54 magnificationFilter : Texture.Linear
55 minificationFilter : Texture.Linear
56 wrapMode {
57 x: WrapMode.ClampToEdge
58 y: WrapMode.ClampToEdge
59 }
60 }
61 }
62 ]
63 }
64
65 components: [
66 RenderSettings {
67 activeFrameGraph: RenderSurfaceSelector {
68 Viewport {
69 RenderTargetSelector {
70 target: intermediateRenderTarget
71 NoDraw {}
72 }
73
74 RenderTargetSelector {
75 target: RenderTarget {
76 id: renderTarget
77 attachments : [
78 RenderTargetOutput {
79 objectName : "color"
80 attachmentPoint : RenderTargetOutput.Color0
81 texture : Texture2D {
82 id : colorAttachment
83 width : 1024
84 height : 768
85 format : Texture.RGBA32F
86 generateMipMaps : false
87 magnificationFilter : Texture.Linear
88 minificationFilter : Texture.Linear
89 wrapMode {
90 x: WrapMode.ClampToEdge
91 y: WrapMode.ClampToEdge
92 }
93 }
94 },
95 RenderTargetOutput {
96 objectName : "depth"
97 attachmentPoint : RenderTargetOutput.Depth
98 texture : Texture2D {
99 id : depthAttachment
100 width : 1024
101 height : 1024
102 format : Texture.D32F
103 generateMipMaps : false
104 magnificationFilter : Texture.Linear
105 minificationFilter : Texture.Linear
106 wrapMode {
107 x: WrapMode.ClampToEdge
108 y: WrapMode.ClampToEdge
109 }
110 }
111 }
112 ]
113 }
114 ClearBuffers {
115 clearColor: "white"
116 buffers: ClearBuffers.ColorDepthBuffer
117 CameraSelector {
118 camera: camera
119 }
120 }
121 }
122
123 NoDraw{
124
125 BlitFramebuffer {
126 source: renderTarget
127 destination: intermediateRenderTarget
128 sourceRect: Qt.rect(0,0,1024,768)
129 destinationRect: Qt.rect(0,0,1024,1024)
130 sourceAttachmentPoint: RenderTargetOutput.Color0
131 destinationAttachmentPoint: RenderTargetOutput.Color0
132 interpolationMethod: BlitFramebuffer.Linear
133 }
134
135 BlitFramebuffer {
136 source: intermediateRenderTarget
137 sourceRect: Qt.rect(0,0,1024,1024)
138 destinationRect: Qt.rect(0,0,512,384)
139 sourceAttachmentPoint: RenderTargetOutput.Color0
140 interpolationMethod: BlitFramebuffer.Linear
141 }
142
143 BlitFramebuffer {
144 source: renderTarget
145 sourceRect: Qt.rect(0,0,1024,768)
146 destinationRect: Qt.rect(0,384,512,384)
147 sourceAttachmentPoint: RenderTargetOutput.Color0
148 interpolationMethod: BlitFramebuffer.Linear
149 }
150
151 BlitFramebuffer {
152 source: renderTarget
153 sourceRect: Qt.rect(128,200,256,256)
154 destinationRect: Qt.rect(512,384,512,384)
155 sourceAttachmentPoint: RenderTargetOutput.Color0
156 interpolationMethod: BlitFramebuffer.Linear
157 }
158
159 BlitFramebuffer {
160 source: renderTarget
161 sourceRect: Qt.rect(128,200,256,256)
162 destinationRect: Qt.rect(512,0,512,384)
163 sourceAttachmentPoint: RenderTargetOutput.Color0
164 interpolationMethod: BlitFramebuffer.Nearest
165 }
166 }
167 }
168 }
169 }
170 ]
171
172 PhongMaterial {
173 id: material
174 }
175
176 TorusMesh {
177 id: torusMesh
178 radius: 5
179 minorRadius: 1
180 rings: 100
181 slices: 20
182 }
183
184 Transform {
185 id: torusTransform
186 scale3D: Qt.vector3d(1.5, 1, 0.5)
187 rotation: fromAxisAndAngle(Qt.vector3d(1, 0, 0), 45)
188 }
189
190 Entity {
191 id: torusEntity
192 components: [ torusMesh, material, torusTransform ]
193 }
194
195 SphereMesh {
196 id: sphereMesh
197 radius: 3
198 }
199
200 Transform {
201 id: sphereTransform
202 property real userAngle: 0.0
203 matrix: {
204 var m = Qt.matrix4x4();
205 m.rotate(userAngle, Qt.vector3d(0, 1, 0));
206 m.translate(Qt.vector3d(20, 0, 0));
207 return m;
208 }
209 }
210
211 QQ2.NumberAnimation {
212 target: sphereTransform
213 property: "userAngle"
214 duration: 10000
215 from: 0
216 to: 360
217
218 loops: QQ2.Animation.Infinite
219 running: true
220 }
221
222 Entity {
223 id: sphereEntity
224 components: [ sphereMesh, material, sphereTransform ]
225 }
226 }