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 "qrendertargetselector.h"
5#include "qrendertargetselector_p.h"
6#include <Qt3DRender/qrendertarget.h>
7#include <Qt3DRender/private/qrenderpass_p.h>
8
9QT_BEGIN_NAMESPACE
10
11using namespace Qt3DCore;
12
13namespace Qt3DRender {
14/*!
15 \class Qt3DRender::QRenderTargetSelector
16 \inmodule Qt3DRender
17 \since 5.7
18 \brief Provides a way of specifying a render target.
19
20 A Qt3DRender::QRenderTargetSelector is used to select active Qt3DRender::QRenderTarget
21 for the FrameGraph. When QRenderTargetSelector is present in the FrameGraph,
22 the rendering is directed into QTexture objects or draw buffers instead of the surface
23 specified in the Qt3DRender::QRenderSurfaceSelector.
24 */
25
26/*!
27 \qmltype RenderTargetSelector
28 \inqmlmodule Qt3D.Render
29 \since 5.7
30 \instantiates Qt3DRender::QRenderTargetSelector
31 \inherits FrameGraphNode
32 \brief Provides a way of specifying a render target.
33
34 A RenderTargetSelector is used to select active RenderTarget
35 for the FrameGraph. When RenderTargetSelector is present in the FrameGraph,
36 the rendering is directed into Texture objects or draw buffers instead of the surface
37 specified in the RenderSurfaceSelector.
38 */
39
40QRenderTargetSelectorPrivate::QRenderTargetSelectorPrivate()
41 : QFrameGraphNodePrivate()
42 , m_target(nullptr)
43{
44}
45
46/*!
47 Constructs QRenderTargetSelector with given \a parent.
48 */
49QRenderTargetSelector::QRenderTargetSelector(QNode *parent)
50 : QFrameGraphNode(*new QRenderTargetSelectorPrivate, parent)
51{
52}
53
54/*! \internal */
55QRenderTargetSelector::~QRenderTargetSelector()
56{
57}
58
59/*!
60 \property QRenderTargetSelector::target
61 Holds the current render target
62 */
63
64/*! \qmlproperty RenderTarget Qt3D.Render::RenderTargetSelector::target
65
66 Holds the current render target
67 */
68void QRenderTargetSelector::setTarget(QRenderTarget *target)
69{
70 Q_D(QRenderTargetSelector);
71 if (d->m_target != target) {
72
73 if (d->m_target)
74 d->unregisterDestructionHelper(node: d->m_target);
75
76 // For inline declaration cases
77 if (target != nullptr && !target->parent())
78 target->setParent(this);
79
80 d->m_target = target;
81
82 if (d->m_target)
83 d->registerDestructionHelper(node: d->m_target, func: &QRenderTargetSelector::setTarget, d->m_target);
84
85 emit targetChanged(target);
86 }
87}
88
89QRenderTarget *QRenderTargetSelector::target() const
90{
91 Q_D(const QRenderTargetSelector);
92 return d->m_target;
93}
94
95/*! \internal */
96QRenderTargetSelector::QRenderTargetSelector(QRenderTargetSelectorPrivate &dd, QNode *parent)
97 : QFrameGraphNode(dd, parent)
98{
99}
100
101} // namespace Qt3DRender
102
103QT_END_NAMESPACE
104
105#include "moc_qrendertargetselector.cpp"
106

source code of qt3d/src/render/framegraph/qrendertargetselector.cpp