1// Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qrendertargetoutput.h"
5#include "qrendertargetoutput_p.h"
6#include "qtexture.h"
7
8QT_BEGIN_NAMESPACE
9
10namespace Qt3DRender {
11
12/*!
13 \class Qt3DRender::QRenderTargetOutput
14 \brief The QRenderTargetOutput class allows the specification of an attachment
15 of a render target (whether it is a color texture, a depth texture, etc... ).
16 \since 5.7
17 \inmodule Qt3DRender
18
19 A QRenderTargetOutput specifies the attachment point and parameters for texture
20 that is attached to render target. In addition to the attachment point, texture
21 miplevel, layer and cubemap face can be specified. The texture attached to the
22 QRenderTargetOutput must be compatible with the given parameters.
23
24 \note Left and Right attachment points are special values. They do not refer to
25 render target objects to be either of the back buffers used for stereo rendering.
26 */
27
28/*!
29 \qmltype RenderTargetOutput
30 \brief The RenderTargetOutput type allows the specification of an attachment
31 of a render target (whether it is a color texture, a depth texture, etc... ).
32 \since 5.7
33 \inqmlmodule Qt3D.Render
34 \inherits Node
35 \nativetype Qt3DRender::QRenderTargetOutput
36
37 A RenderTargetOutput specifies the attachment point and parameters for texture
38 that is attached to render target. In addition to the attachment point, texture
39 miplevel, layer and cubemap face can be specified. The texture attached to the
40 RenderTargetOutput must be compatible with the given parameters.
41
42 \note Left and Right attachment points are special values. They do not refer to
43 render target objects, but rather to either of the back buffers used for stereo rendering.
44 */
45
46/*!
47 \enum Qt3DRender::QRenderTargetOutput::AttachmentPoint
48
49 This enumeration specifies the values for the attachment point.
50
51 \value Color0 Color attachment point at index 0
52 \value Color1 Color attachment point at index 1
53 \value Color2 Color attachment point at index 2
54 \value Color3 Color attachment point at index 3
55 \value Color4 Color attachment point at index 4
56 \value Color5 Color attachment point at index 5
57 \value Color6 Color attachment point at index 6
58 \value Color7 Color attachment point at index 7
59 \value Color8 Color attachment point at index 8
60 \value Color9 Color attachment point at index 9
61 \value Color10 Color attachment point at index 10
62 \value Color11 Color attachment point at index 11
63 \value Color12 Color attachment point at index 12
64 \value Color13 Color attachment point at index 13
65 \value Color14 Color attachment point at index 14
66 \value Color15 Color attachment point at index 15
67 \value Depth Depth attachment point
68 \value Stencil Stencil attachment point
69 \value DepthStencil DepthStencil attachment point
70 \value Left Back Left Draw Buffer
71 \value Right Back Right Draw Buffer
72*/
73
74/*!
75 \qmlproperty enumeration RenderTargetOutput::attachmentPoint
76 Holds the attachment point of the RenderTargetOutput.
77 \list
78 \li RenderTargetOutput.Color0
79 \li RenderTargetOutput.Color1
80 \li RenderTargetOutput.Color2
81 \li RenderTargetOutput.Color3
82 \li RenderTargetOutput.Color4
83 \li RenderTargetOutput.Color5
84 \li RenderTargetOutput.Color6
85 \li RenderTargetOutput.Color7
86 \li RenderTargetOutput.Color8
87 \li RenderTargetOutput.Color9
88 \li RenderTargetOutput.Color10
89 \li RenderTargetOutput.Color11
90 \li RenderTargetOutput.Color12
91 \li RenderTargetOutput.Color13
92 \li RenderTargetOutput.Color14
93 \li RenderTargetOutput.Color15
94 \li RenderTargetOutput.Depth
95 \li RenderTargetOutput.Stencil
96 \li RenderTargetOutput.DepthStencil
97 \li RenderTargetOutput.Left
98 \li RenderTargetOutput.Right
99 \endlist
100
101 \sa Qt3DRender::QRenderTargetOutput::AttachmentPoint
102*/
103
104/*!
105 \qmlproperty Texture RenderTargetOutput::texture
106 Holds the texture attached to the attachment point.
107*/
108
109/*!
110 \qmlproperty int RenderTargetOutput::mipLevel
111 Holds the miplevel of the attached texture the rendering is directed to.
112*/
113
114/*!
115 \qmlproperty int RenderTargetOutput::layer
116 Holds the layer of the attached texture the rendering is directed to.
117*/
118
119/*!
120 \qmlproperty enumeration RenderTargetOutput::face
121 Holds the face of the attached cubemap texture the rendering is directed to.
122 \list
123 \li Texture.CubeMapPositiveX
124 \li Texture.CubeMapNegativeX
125 \li Texture.CubeMapPositiveY
126 \li Texture.CubeMapNegativeY
127 \li Texture.CubeMapPositiveZ
128 \li Texture.CubeMapNegativeZ
129 \endlist
130 \sa Qt3DRender::QAbstractTexture::CubeMapFace
131*/
132
133/*!
134 \property Qt3DRender::QRenderTargetOutput::attachmentPoint
135 Holds the attachment point of the QRenderTargetOutput.
136
137
138*/
139
140/*!
141 \property Qt3DRender::QRenderTargetOutput::texture
142 Holds the texture attached to the attachment point.
143*/
144
145/*!
146 \property Qt3DRender::QRenderTargetOutput::mipLevel
147 Holds the miplevel of the attached texture the rendering is directed to.
148*/
149
150/*!
151 \property Qt3DRender::QRenderTargetOutput::layer
152 Holds the layer of the attached texture the rendering is directed to.
153*/
154
155/*!
156 \property Qt3DRender::QRenderTargetOutput::face
157 Holds the face of the attached cubemap texture the rendering is directed to.
158*/
159
160/*! \internal */
161QRenderTargetOutputPrivate::QRenderTargetOutputPrivate()
162 : QNodePrivate()
163 , m_texture(nullptr)
164 , m_attachmentPoint(QRenderTargetOutput::Color0)
165 , m_mipLevel(0)
166 , m_layer(0)
167 , m_face(QAbstractTexture::CubeMapNegativeX)
168{
169}
170
171/*!
172 The constructor creates a new QRenderTargetOutput::QRenderTargetOutput instance
173 with the specified \a parent.
174 */
175QRenderTargetOutput::QRenderTargetOutput(QNode *parent)
176 : QNode(*new QRenderTargetOutputPrivate, parent)
177{
178}
179
180/*! \internal */
181QRenderTargetOutput::~QRenderTargetOutput()
182{
183}
184
185/*! \internal */
186QRenderTargetOutput::QRenderTargetOutput(QRenderTargetOutputPrivate &dd, QNode *parent)
187 : QNode(dd, parent)
188{
189}
190
191void QRenderTargetOutput::setAttachmentPoint(QRenderTargetOutput::AttachmentPoint attachmentPoint)
192{
193 Q_D(QRenderTargetOutput);
194 if (attachmentPoint != d->m_attachmentPoint) {
195 d->m_attachmentPoint = attachmentPoint;
196 emit attachmentPointChanged(attachmentPoint);
197 }
198}
199
200QRenderTargetOutput::AttachmentPoint QRenderTargetOutput::attachmentPoint() const
201{
202 Q_D(const QRenderTargetOutput);
203 return d->m_attachmentPoint;
204}
205
206void QRenderTargetOutput::setTexture(QAbstractTexture *texture)
207{
208 Q_D(QRenderTargetOutput);
209 if (texture != d->m_texture) {
210
211 if (d->m_texture)
212 d->unregisterDestructionHelper(node: d->m_texture);
213
214 // Handle inline declaration
215 if (texture && !texture->parent())
216 texture->setParent(this);
217
218 d->m_texture = texture;
219
220 // Ensures proper bookkeeping
221 if (d->m_texture)
222 d->registerDestructionHelper(node: d->m_texture, func: &QRenderTargetOutput::setTexture, d->m_texture);
223
224 emit textureChanged(texture);
225 }
226}
227
228QAbstractTexture *QRenderTargetOutput::texture() const
229{
230 Q_D(const QRenderTargetOutput);
231 return d->m_texture;
232}
233
234void QRenderTargetOutput::setMipLevel(int level)
235{
236 Q_D(QRenderTargetOutput);
237 if (d->m_mipLevel != level) {
238 d->m_mipLevel = level;
239 emit mipLevelChanged(mipLevel: level);
240 }
241}
242
243int QRenderTargetOutput::mipLevel() const
244{
245 Q_D(const QRenderTargetOutput);
246 return d->m_mipLevel;
247}
248
249void QRenderTargetOutput::setLayer(int layer)
250{
251 Q_D(QRenderTargetOutput);
252 if (d->m_layer != layer) {
253 d->m_layer = layer;
254 emit layerChanged(layer);
255 }
256}
257
258int QRenderTargetOutput::layer() const
259{
260 Q_D(const QRenderTargetOutput);
261 return d->m_layer;
262}
263
264void QRenderTargetOutput::setFace(QAbstractTexture::CubeMapFace face)
265{
266 Q_D(QRenderTargetOutput);
267 if (d->m_face != face) {
268 d->m_face = face;
269 emit faceChanged(face);
270 }
271}
272
273QAbstractTexture::CubeMapFace QRenderTargetOutput::face() const
274{
275 Q_D(const QRenderTargetOutput);
276 return d->m_face;
277}
278
279} // namespace Qt3DRender
280
281QT_END_NAMESPACE
282
283#include "moc_qrendertargetoutput.cpp"
284

Provided by KDAB

Privacy Policy
Learn to use CMake with our Intro Training
Find out more

source code of qt3d/src/render/frontend/qrendertargetoutput.cpp