1 | // Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). |
2 | // Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies). |
3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
4 | |
5 | #include "qblendequationarguments.h" |
6 | #include "qblendequationarguments_p.h" |
7 | |
8 | QT_BEGIN_NAMESPACE |
9 | |
10 | namespace Qt3DRender { |
11 | |
12 | /*! |
13 | \class Qt3DRender::QBlendEquationArguments |
14 | \inmodule Qt3DRender |
15 | \since 5.5 |
16 | \brief Encapsulates blending information: specifies how the incoming values (what's going to be drawn) |
17 | are going to affect the existing values (what is already drawn). |
18 | |
19 | OpenGL pre-3.0: Set the same blend state for all draw buffers |
20 | (one QBlendEquationArguments) |
21 | OpenGL 3.0-pre4.0: Set the same blend state for all draw buffers, |
22 | but can disable blending for particular buffers |
23 | (one QBlendEquationArguments for setting glBlendFunc, n QBlendEquationArgumentss |
24 | for enabling/disabling Draw Buffers) |
25 | OpenGL 4.0+: Can set blend state individually for each draw buffer. |
26 | */ |
27 | |
28 | /*! |
29 | \qmltype BlendEquationArguments |
30 | \nativetype Qt3DRender::QBlendEquationArguments |
31 | \inherits RenderState |
32 | \inqmlmodule Qt3D.Render |
33 | \since 5.5 |
34 | \brief Encapsulates blending information: specifies how the incoming values (what's going to be drawn) |
35 | are going to affect the existing values (what is already drawn). |
36 | |
37 | OpenGL pre-3.0: Set the same blend state for all draw buffers |
38 | OpenGL 3.0-pre4.0: Set the same blend state for all draw buffers, |
39 | but can disable blending for particular buffers |
40 | OpenGL 4.0+: Can set blend state individually for each draw buffer. |
41 | */ |
42 | |
43 | /*! |
44 | The constructor creates a new blend state object with the specified \a parent. |
45 | */ |
46 | QBlendEquationArguments::QBlendEquationArguments(QNode *parent) |
47 | : QRenderState(*new QBlendEquationArgumentsPrivate, parent) |
48 | { |
49 | } |
50 | |
51 | /*! |
52 | \internal |
53 | */ |
54 | QBlendEquationArguments::~QBlendEquationArguments() |
55 | { |
56 | } |
57 | |
58 | /*! |
59 | \internal |
60 | */ |
61 | QBlendEquationArguments::QBlendEquationArguments(QBlendEquationArgumentsPrivate &dd, QNode *parent) |
62 | : QRenderState(dd, parent) |
63 | { |
64 | } |
65 | |
66 | /*! |
67 | \enum Qt3DRender::QBlendEquationArguments::Blending |
68 | |
69 | \value Zero GL_ZERO |
70 | \value One GL_ONE |
71 | \value SourceColor GL_SRC_COLOR |
72 | \value SourceAlpha GL_SRC_ALPHA |
73 | \value Source1Alpha GL_SRC1_ALPHA |
74 | \value Source1Color GL_SRC1_COLOR |
75 | \value DestinationColor GL_DST_COLOR |
76 | \value DestinationAlpha GL_DST_ALPHA |
77 | \value SourceAlphaSaturate GL_SRC_ALPHA_SATURATE |
78 | \value ConstantColor 0GL_CONSTANT_COLOR |
79 | \value ConstantAlpha GL_CONSTANT_ALPHA |
80 | \value OneMinusSourceColor GL_ONE_MINUS_SRC_COLOR |
81 | \value OneMinusSourceAlpha GL_ONE_MINUS_SRC_ALPHA |
82 | \value OneMinusDestinationAlpha GL_ONE_MINUS_DST_ALPHA |
83 | \value OneMinusDestinationColor GL_ONE_MINUS_DST_COLOR |
84 | \value OneMinusConstantColor GL_ONE_MINUS_CONSTANT_COLOR |
85 | \value OneMinusConstantAlpha GL_ONE_MINUS_CONSTANT_ALPHA |
86 | \value OneMinusSource1Alpha GL_ONE_MINUS_SRC1_ALPHA |
87 | \value OneMinusSource1Color GL_ONE_MINUS_SRC1_COLOR |
88 | \value OneMinusSource1Color0 GL_ONE_MINUS_SRC1_COLOR (deprecated) |
89 | */ |
90 | |
91 | /*! |
92 | \qmlproperty enumeration BlendEquationArguments::sourceRgb |
93 | |
94 | */ |
95 | |
96 | /*! |
97 | \property Qt3DRender::QBlendEquationArguments::sourceRgb |
98 | |
99 | */ |
100 | QBlendEquationArguments::Blending QBlendEquationArguments::sourceRgb() const |
101 | { |
102 | Q_D(const QBlendEquationArguments); |
103 | return d->m_sourceRgb; |
104 | } |
105 | |
106 | void QBlendEquationArguments::setSourceRgb(QBlendEquationArguments::Blending sourceRgb) |
107 | { |
108 | Q_D(QBlendEquationArguments); |
109 | if (d->m_sourceRgb != sourceRgb) { |
110 | d->m_sourceRgb = sourceRgb; |
111 | emit sourceRgbChanged(sourceRgb); |
112 | |
113 | if (d->m_sourceAlpha == sourceRgb) |
114 | emit sourceRgbaChanged(sourceRgba: sourceRgb); |
115 | } |
116 | } |
117 | |
118 | /*! |
119 | \qmlproperty enumeration BlendEquationArguments::destinationRgb |
120 | |
121 | */ |
122 | |
123 | /*! |
124 | \property Qt3DRender::QBlendEquationArguments::destinationRgb |
125 | |
126 | */ |
127 | QBlendEquationArguments::Blending QBlendEquationArguments::destinationRgb() const |
128 | { |
129 | Q_D(const QBlendEquationArguments); |
130 | return d->m_destinationRgb; |
131 | } |
132 | |
133 | void QBlendEquationArguments::setDestinationRgb(QBlendEquationArguments::Blending destinationRgb) |
134 | { |
135 | Q_D(QBlendEquationArguments); |
136 | if (d->m_destinationRgb != destinationRgb) { |
137 | d->m_destinationRgb = destinationRgb; |
138 | emit destinationRgbChanged(destinationRgb); |
139 | |
140 | if (d->m_destinationAlpha == destinationRgb) |
141 | emit destinationRgbaChanged(destinationRgba: destinationRgb); |
142 | } |
143 | } |
144 | |
145 | /*! |
146 | \qmlproperty enumeration BlendEquationArguments::sourceAlpha |
147 | |
148 | */ |
149 | |
150 | /*! |
151 | \property Qt3DRender::QBlendEquationArguments::sourceAlpha |
152 | |
153 | */ |
154 | QBlendEquationArguments::Blending QBlendEquationArguments::sourceAlpha() const |
155 | { |
156 | Q_D(const QBlendEquationArguments); |
157 | return d->m_sourceAlpha; |
158 | } |
159 | |
160 | void QBlendEquationArguments::setSourceAlpha(QBlendEquationArguments::Blending sourceAlpha) |
161 | { |
162 | Q_D(QBlendEquationArguments); |
163 | if (d->m_sourceAlpha != sourceAlpha) { |
164 | d->m_sourceAlpha = sourceAlpha; |
165 | emit sourceAlphaChanged(sourceAlpha); |
166 | |
167 | if (d->m_sourceRgb == sourceAlpha) |
168 | emit sourceRgbaChanged(sourceRgba: sourceAlpha); |
169 | } |
170 | } |
171 | |
172 | /*! |
173 | \qmlproperty enumeration BlendEquationArguments::destinationAlpha |
174 | |
175 | */ |
176 | |
177 | /*! |
178 | \property Qt3DRender::QBlendEquationArguments::destinationAlpha |
179 | |
180 | */ |
181 | QBlendEquationArguments::Blending QBlendEquationArguments::destinationAlpha() const |
182 | { |
183 | Q_D(const QBlendEquationArguments); |
184 | return d->m_destinationAlpha; |
185 | } |
186 | |
187 | void QBlendEquationArguments::setDestinationAlpha(QBlendEquationArguments::Blending destinationAlpha) |
188 | { |
189 | Q_D(QBlendEquationArguments); |
190 | if (d->m_destinationAlpha != destinationAlpha) { |
191 | d->m_destinationAlpha = destinationAlpha; |
192 | emit destinationAlphaChanged(destinationAlpha); |
193 | |
194 | if (d->m_destinationRgb == destinationAlpha) |
195 | emit destinationRgbaChanged(destinationRgba: destinationAlpha); |
196 | } |
197 | } |
198 | |
199 | /*! |
200 | \fn Qt3DRender::QBlendEquationArguments::sourceRgbaChanged(Blending sourceRgba) |
201 | |
202 | Notify that both sourceRgb and sourceAlpha properties have changed to \a sourceRgba. |
203 | */ |
204 | /*! |
205 | \fn Qt3DRender::QBlendEquationArguments::destinationRgbaChanged(Blending destinationRgba) |
206 | |
207 | Notify that both destinationRgb and destinationAlpha properties have changed to |
208 | \a destinationRgba. |
209 | */ |
210 | |
211 | /*! |
212 | Change both sourceRgb and sourceAlpha properties to \a sourceRgba. |
213 | */ |
214 | void QBlendEquationArguments::setSourceRgba(Blending sourceRgba) |
215 | { |
216 | setSourceRgb(sourceRgba); |
217 | setSourceAlpha(sourceRgba); |
218 | } |
219 | |
220 | /*! |
221 | Change both destinationRgb and destinationAlpha properties to \a destinationRgba. |
222 | */ |
223 | void QBlendEquationArguments::setDestinationRgba(Blending destinationRgba) |
224 | { |
225 | setDestinationRgb(destinationRgba); |
226 | setDestinationAlpha(destinationRgba); |
227 | } |
228 | |
229 | /*! |
230 | \qmlproperty int BlendEquationArguments::bufferIndex |
231 | |
232 | Specifies the index of the Draw Buffer that this BlendEquationArguments applies to. |
233 | If negative, this will apply to all Draw Buffers. |
234 | */ |
235 | |
236 | /*! |
237 | \property Qt3DRender::QBlendEquationArguments::bufferIndex |
238 | |
239 | Specifies the index of the Draw Buffer that this BlendEquationArguments applies to. |
240 | If negative, this will apply to all Draw Buffers. |
241 | */ |
242 | int QBlendEquationArguments::bufferIndex() const |
243 | { |
244 | Q_D(const QBlendEquationArguments); |
245 | return d->m_bufferIndex; |
246 | } |
247 | |
248 | void QBlendEquationArguments::setBufferIndex(int bufferIndex) |
249 | { |
250 | Q_D(QBlendEquationArguments); |
251 | if (d->m_bufferIndex != bufferIndex) { |
252 | d->m_bufferIndex = bufferIndex; |
253 | emit bufferIndexChanged(index: bufferIndex); |
254 | } |
255 | } |
256 | |
257 | } // namespace Qt3DRender |
258 | |
259 | QT_END_NAMESPACE |
260 | |
261 | #include "moc_qblendequationarguments.cpp" |
262 | |