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 "qclearbuffers.h"
5#include "qclearbuffers_p.h"
6
7QT_BEGIN_NAMESPACE
8
9namespace Qt3DRender {
10/*!
11 \class Qt3DRender::QClearBuffers
12 \inmodule Qt3DRender
13 \since 5.7
14 \ingroup framegraph
15 \brief Class to clear buffers.
16
17 A Qt3DRender::QClearBuffers FrameGraph node enables clearing of the specific
18 render target buffers with specific values.
19 */
20
21/*!
22 \qmltype ClearBuffers
23 \inqmlmodule Qt3D.Render
24 \instantiates Qt3DRender::QClearBuffers
25 \inherits FrameGraphNode
26 \since 5.7
27 \brief Class to clear buffers.
28
29 A Qt3DRender::QClearBuffers FrameGraph node enables clearing of the specific
30 render target buffers with specific values.
31*/
32
33/*!
34 \enum QClearBuffers::BufferType
35
36 This enum type describes types of buffer to be cleared.
37 \value None No buffers will be cleared
38 \value ColorBuffer Clear color buffers
39 \value DepthBuffer Clear depth buffer
40 \value StencilBuffer Clear stencil buffer
41 \value DepthStencilBuffer Clear depth and stencil buffers
42 \value ColorDepthBuffer Clear color and depth buffers
43 \value ColorDepthStencilBuffer Clear color, depth and stencil buffers
44 \value AllBuffers Clear all buffers
45*/
46
47QClearBuffersPrivate::QClearBuffersPrivate()
48 : QFrameGraphNodePrivate()
49 , m_buffersType(QClearBuffers::None)
50 , m_clearDepthValue(1.f)
51 , m_clearStencilValue(0)
52 , m_buffer(nullptr)
53{
54}
55
56/*!
57 The constructor creates an instance with the specified \a parent.
58 */
59QClearBuffers::QClearBuffers(QNode *parent)
60 : QFrameGraphNode(*new QClearBuffersPrivate, parent)
61{
62}
63
64/*! \internal */
65QClearBuffers::~QClearBuffers()
66{
67}
68
69/*! \internal */
70QClearBuffers::QClearBuffers(QClearBuffersPrivate &dd, QNode *parent)
71 : QFrameGraphNode(dd, parent)
72{
73}
74
75
76QClearBuffers::BufferType QClearBuffers::buffers() const
77{
78 Q_D(const QClearBuffers);
79 return d->m_buffersType;
80}
81
82QColor QClearBuffers::clearColor() const
83{
84 Q_D(const QClearBuffers);
85 return d->m_clearColor;
86}
87
88float QClearBuffers::clearDepthValue() const
89{
90 Q_D(const QClearBuffers);
91 return d->m_clearDepthValue;
92}
93
94int QClearBuffers::clearStencilValue() const
95{
96 Q_D(const QClearBuffers);
97 return d->m_clearStencilValue;
98}
99
100QRenderTargetOutput *QClearBuffers::colorBuffer() const
101{
102 Q_D(const QClearBuffers);
103 return d->m_buffer;
104}
105
106/*!
107 \property Qt3DRender::QClearBuffers::buffers
108 Specifies the buffer type to be used.
109 */
110
111/*!
112 \qmlproperty enumeration Qt3D.Render::ClearBuffers::buffers
113 Specifies the buffer type to be used.
114*/
115void QClearBuffers::setBuffers(QClearBuffers::BufferType buffers)
116{
117 Q_D(QClearBuffers);
118 if (d->m_buffersType != buffers) {
119 d->m_buffersType = buffers;
120 emit buffersChanged(buffers);
121 }
122}
123
124/*!
125 \property Qt3DRender::QClearBuffers::clearColor
126 Specifies the clear color to be used.
127 */
128/*!
129 \qmlproperty color Qt3D.Render::ClearBuffers::clearColor
130 Specifies the clear color to be used.
131*/
132void QClearBuffers::setClearColor(const QColor &color)
133{
134 Q_D(QClearBuffers);
135 if (d->m_clearColor != color) {
136 d->m_clearColor = color;
137 emit clearColorChanged(color);
138 }
139}
140
141
142/*!
143 \property Qt3DRender::QClearBuffers::clearDepthValue
144 Specifies the clear depth value to be used.
145 */
146/*!
147 \qmlproperty real Qt3D.Render::ClearBuffers::clearDepthValue
148 Specifies the clear depth value to be used.
149*/
150void QClearBuffers::setClearDepthValue(float clearDepthValue)
151{
152 Q_D(QClearBuffers);
153 if (d->m_clearDepthValue != clearDepthValue) {
154 if (clearDepthValue >= 0.f && clearDepthValue <= 1.f) {
155 d->m_clearDepthValue = clearDepthValue;
156 emit clearDepthValueChanged(clearDepthValue);
157 } else qWarning() << "Invalid clear depth value";
158 }
159}
160
161
162/*!
163 \property Qt3DRender::QClearBuffers::clearStencilValue
164 Specifies the stencil value to be used.
165 */
166/*!
167 \qmlproperty int Qt3D.Render::ClearBuffers::clearStencilValue
168 Specifies the stencil value to be used.
169*/
170void QClearBuffers::setClearStencilValue(int clearStencilValue)
171{
172 Q_D(QClearBuffers);
173 if (d->m_clearStencilValue != clearStencilValue) {
174 d->m_clearStencilValue = clearStencilValue;
175 emit clearStencilValueChanged(clearStencilValue);
176 }
177}
178
179/*!
180 \property Qt3DRender::QClearBuffers::colorBuffer
181 Specifies a specific color buffer to clear. If set to NULL (default), and
182 ColorBuffer flag is set, all color buffers will be cleared.
183 */
184/*!
185 \qmlproperty RenderTargetOutput Qt3D.Render::ClearBuffers::colorBuffer
186 Specifies a specific color buffer to clear. If set to NULL (default), and
187 ColorBuffer flag is set, all color buffers will be cleared.
188*/
189void QClearBuffers::setColorBuffer(QRenderTargetOutput *buffer)
190{
191 Q_D(QClearBuffers);
192 if (d->m_buffer != buffer) {
193 d->m_buffer = buffer;
194 emit colorBufferChanged(buffer);
195 }
196}
197
198} // namespace Qt3DRender
199
200QT_END_NAMESPACE
201
202#include "moc_qclearbuffers.cpp"
203

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