summaryrefslogtreecommitdiffstats
path: root/src/render/framegraph/qclearbuffers.cpp
blob: 5126042677aad05ae599ebafdecfd28be31dea82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
// Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#include "qclearbuffers.h"
#include "qclearbuffers_p.h"

QT_BEGIN_NAMESPACE

namespace Qt3DRender {
/*!
    \class Qt3DRender::QClearBuffers
    \inmodule Qt3DRender
    \since 5.7
    \ingroup framegraph
    \brief Class to clear buffers.

    A Qt3DRender::QClearBuffers FrameGraph node enables clearing of the specific
    render target buffers with specific values.
 */

/*!
    \qmltype ClearBuffers
    \inqmlmodule Qt3D.Render
    \instantiates Qt3DRender::QClearBuffers
    \inherits FrameGraphNode
    \since 5.7
    \brief Class to clear buffers.

    A Qt3DRender::QClearBuffers FrameGraph node enables clearing of the specific
    render target buffers with specific values.
*/

/*!
    \enum QClearBuffers::BufferType

    This enum type describes types of buffer to be cleared.
    \value None No buffers will be cleared
    \value ColorBuffer Clear color buffers
    \value DepthBuffer Clear depth buffer
    \value StencilBuffer Clear stencil buffer
    \value DepthStencilBuffer Clear depth and stencil buffers
    \value ColorDepthBuffer Clear color and depth buffers
    \value ColorDepthStencilBuffer Clear color, depth and stencil buffers
    \value AllBuffers Clear all buffers
*/

QClearBuffersPrivate::QClearBuffersPrivate()
    : QFrameGraphNodePrivate()
    , m_buffersType(QClearBuffers::None)
    , m_clearDepthValue(1.f)
    , m_clearStencilValue(0)
    , m_buffer(nullptr)
{
}

/*!
    The constructor creates an instance with the specified \a parent.
 */
QClearBuffers::QClearBuffers(QNode *parent)
    : QFrameGraphNode(*new QClearBuffersPrivate, parent)
{
}

/*! \internal */
QClearBuffers::~QClearBuffers()
{
}

/*! \internal */
QClearBuffers::QClearBuffers(QClearBuffersPrivate &dd, QNode *parent)
    : QFrameGraphNode(dd, parent)
{
}


QClearBuffers::BufferType QClearBuffers::buffers() const
{
    Q_D(const QClearBuffers);
    return d->m_buffersType;
}

QColor QClearBuffers::clearColor() const
{
    Q_D(const QClearBuffers);
    return d->m_clearColor;
}

float QClearBuffers::clearDepthValue() const
{
    Q_D(const QClearBuffers);
    return d->m_clearDepthValue;
}

int QClearBuffers::clearStencilValue() const
{
    Q_D(const QClearBuffers);
    return d->m_clearStencilValue;
}

QRenderTargetOutput *QClearBuffers::colorBuffer() const
{
    Q_D(const QClearBuffers);
    return d->m_buffer;
}

/*!
    \property Qt3DRender::QClearBuffers::buffers
    Specifies the buffer type to be used.
 */

/*!
    \qmlproperty enumeration Qt3D.Render::ClearBuffers::buffers
    Specifies the buffer type to be used.
*/
void QClearBuffers::setBuffers(QClearBuffers::BufferType buffers)
{
    Q_D(QClearBuffers);
    if (d->m_buffersType != buffers) {
        d->m_buffersType = buffers;
        emit buffersChanged(buffers);
    }
}

/*!
    \property Qt3DRender::QClearBuffers::clearColor
    Specifies the clear color to be used.
 */
/*!
    \qmlproperty color Qt3D.Render::ClearBuffers::clearColor
    Specifies the clear color to be used.
*/
void QClearBuffers::setClearColor(const QColor &color)
{
    Q_D(QClearBuffers);
    if (d->m_clearColor != color) {
        d->m_clearColor = color;
        emit clearColorChanged(color);
    }
}


/*!
    \property Qt3DRender::QClearBuffers::clearDepthValue
    Specifies the clear depth value to be used.
 */
/*!
    \qmlproperty real Qt3D.Render::ClearBuffers::clearDepthValue
    Specifies the clear depth value to be used.
*/
void QClearBuffers::setClearDepthValue(float clearDepthValue)
{
    Q_D(QClearBuffers);
    if (d->m_clearDepthValue != clearDepthValue) {
        if (clearDepthValue >= 0.f && clearDepthValue <= 1.f) {
            d->m_clearDepthValue = clearDepthValue;
            emit clearDepthValueChanged(clearDepthValue);
        } else qWarning() << "Invalid clear depth value";
    }
}


/*!
    \property Qt3DRender::QClearBuffers::clearStencilValue
    Specifies the stencil value to be used.
 */
/*!
    \qmlproperty int Qt3D.Render::ClearBuffers::clearStencilValue
    Specifies the stencil value to be used.
*/
void QClearBuffers::setClearStencilValue(int clearStencilValue)
{
    Q_D(QClearBuffers);
    if (d->m_clearStencilValue != clearStencilValue) {
        d->m_clearStencilValue = clearStencilValue;
        emit clearStencilValueChanged(clearStencilValue);
    }
}

/*!
    \property Qt3DRender::QClearBuffers::colorBuffer
    Specifies a specific color buffer to clear. If set to NULL (default), and
    ColorBuffer flag is set, all color buffers will be cleared.
 */
/*!
    \qmlproperty RenderTargetOutput Qt3D.Render::ClearBuffers::colorBuffer
    Specifies a specific color buffer to clear. If set to NULL (default), and
    ColorBuffer flag is set, all color buffers will be cleared.
*/
void QClearBuffers::setColorBuffer(QRenderTargetOutput *buffer)
{
    Q_D(QClearBuffers);
    if (d->m_buffer != buffer) {
        d->m_buffer = buffer;
        emit colorBufferChanged(buffer);
    }
}

} // namespace Qt3DRender

QT_END_NAMESPACE

#include "moc_qclearbuffers.cpp"