1 | /**************************************************************************** |
---|---|
2 | ** |
3 | ** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). |
4 | ** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies). |
5 | ** Contact: https://www.qt.io/licensing/ |
6 | ** |
7 | ** This file is part of the Qt3D module of the Qt Toolkit. |
8 | ** |
9 | ** $QT_BEGIN_LICENSE:LGPL$ |
10 | ** Commercial License Usage |
11 | ** Licensees holding valid commercial Qt licenses may use this file in |
12 | ** accordance with the commercial license agreement provided with the |
13 | ** Software or, alternatively, in accordance with the terms contained in |
14 | ** a written agreement between you and The Qt Company. For licensing terms |
15 | ** and conditions see https://www.qt.io/terms-conditions. For further |
16 | ** information use the contact form at https://www.qt.io/contact-us. |
17 | ** |
18 | ** GNU Lesser General Public License Usage |
19 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
20 | ** General Public License version 3 as published by the Free Software |
21 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
22 | ** packaging of this file. Please review the following information to |
23 | ** ensure the GNU Lesser General Public License version 3 requirements |
24 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
25 | ** |
26 | ** GNU General Public License Usage |
27 | ** Alternatively, this file may be used under the terms of the GNU |
28 | ** General Public License version 2.0 or (at your option) the GNU General |
29 | ** Public license version 3 or any later version approved by the KDE Free |
30 | ** Qt Foundation. The licenses are as published by the Free Software |
31 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
32 | ** included in the packaging of this file. Please review the following |
33 | ** information to ensure the GNU General Public License requirements will |
34 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
35 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
36 | ** |
37 | ** $QT_END_LICENSE$ |
38 | ** |
39 | ****************************************************************************/ |
40 | |
41 | #include "renderstates_p.h" |
42 | |
43 | #include <Qt3DRender/qrenderstate.h> |
44 | #include <Qt3DRender/qcullface.h> |
45 | #include <Qt3DRender/qpointsize.h> |
46 | |
47 | #include <Qt3DRender/private/qstenciloperation_p.h> |
48 | #include <Qt3DRender/private/qstenciltest_p.h> |
49 | #include <Qt3DRender/qblendequationarguments.h> |
50 | #include <Qt3DRender/qblendequation.h> |
51 | #include <Qt3DRender/qalphatest.h> |
52 | #include <Qt3DRender/qdepthrange.h> |
53 | #include <Qt3DRender/qdepthtest.h> |
54 | #include <Qt3DRender/qrastermode.h> |
55 | #include <Qt3DRender/qfrontface.h> |
56 | #include <Qt3DRender/qscissortest.h> |
57 | #include <Qt3DRender/qpolygonoffset.h> |
58 | #include <Qt3DRender/qcolormask.h> |
59 | #include <Qt3DRender/qclipplane.h> |
60 | #include <Qt3DRender/qstencilmask.h> |
61 | #include <Qt3DRender/qlinewidth.h> |
62 | |
63 | QT_BEGIN_NAMESPACE |
64 | |
65 | namespace Qt3DRender { |
66 | namespace Render { |
67 | |
68 | void RenderStateImpl::updateProperties(const QRenderState *) |
69 | { |
70 | } |
71 | |
72 | void BlendEquationArguments::updateProperties(const QRenderState *node) |
73 | { |
74 | const QBlendEquationArguments *args = static_cast<const QBlendEquationArguments *>(node); |
75 | |
76 | std::get<0>(t&: m_values) = args->sourceRgb(); |
77 | std::get<1>(t&: m_values) = args->destinationRgb(); |
78 | std::get<2>(t&: m_values) = args->sourceAlpha(); |
79 | std::get<3>(t&: m_values) = args->destinationAlpha(); |
80 | std::get<4>(t&: m_values) = args->isEnabled(); |
81 | std::get<5>(t&: m_values) = args->bufferIndex(); |
82 | } |
83 | |
84 | void BlendEquation::updateProperties(const QRenderState *node) |
85 | { |
86 | const QBlendEquation *equation = static_cast<const QBlendEquation *>(node); |
87 | std::get<0>(t&: m_values) = equation->blendFunction(); |
88 | } |
89 | |
90 | void AlphaFunc::updateProperties(const QRenderState *node) |
91 | { |
92 | const QAlphaTest *alphaTest = static_cast<const QAlphaTest *>(node); |
93 | std::get<0>(t&: m_values) = alphaTest->alphaFunction(); |
94 | std::get<1>(t&: m_values) = alphaTest->referenceValue(); |
95 | } |
96 | |
97 | void MSAAEnabled::updateProperties(const QRenderState *node) |
98 | { |
99 | std::get<0>(t&: m_values) = node->isEnabled(); |
100 | } |
101 | |
102 | void DepthRange::updateProperties(const QRenderState *node) |
103 | { |
104 | const QDepthRange *depthRange = static_cast<const QDepthRange *>(node); |
105 | |
106 | std::get<0>(t&: m_values) = depthRange->nearValue(); |
107 | std::get<1>(t&: m_values) = depthRange->farValue(); |
108 | } |
109 | |
110 | void DepthTest::updateProperties(const QRenderState *node) |
111 | { |
112 | const QDepthTest *depthTest = static_cast<const QDepthTest *>(node); |
113 | |
114 | std::get<0>(t&: m_values) = depthTest->depthFunction(); |
115 | } |
116 | |
117 | void RasterMode::updateProperties(const QRenderState *node) |
118 | { |
119 | const QRasterMode *rasterMode = static_cast<const QRasterMode *>(node); |
120 | |
121 | std::get<0>(t&: m_values) = rasterMode->faceMode(); |
122 | std::get<1>(t&: m_values) = rasterMode->rasterMode(); |
123 | } |
124 | |
125 | void CullFace::updateProperties(const QRenderState *node) |
126 | { |
127 | const QCullFace *cullFace = static_cast<const QCullFace *>(node); |
128 | |
129 | std::get<0>(t&: m_values) = cullFace->mode(); |
130 | } |
131 | |
132 | void FrontFace::updateProperties(const QRenderState *node) |
133 | { |
134 | const QFrontFace *frontFace = static_cast<const QFrontFace *>(node); |
135 | |
136 | std::get<0>(t&: m_values) = frontFace->direction(); |
137 | } |
138 | |
139 | void NoDepthMask::updateProperties(const QRenderState *node) |
140 | { |
141 | std::get<0>(t&: m_values) = !node->isEnabled(); |
142 | } |
143 | |
144 | void ScissorTest::updateProperties(const QRenderState *node) |
145 | { |
146 | const QScissorTest *scissorTest = static_cast<const QScissorTest *>(node); |
147 | |
148 | std::get<0>(t&: m_values) = scissorTest->left(); |
149 | std::get<1>(t&: m_values) = scissorTest->bottom(); |
150 | std::get<2>(t&: m_values) = scissorTest->width(); |
151 | std::get<3>(t&: m_values) = scissorTest->height(); |
152 | } |
153 | |
154 | void StencilTest::updateProperties(const QRenderState *node) |
155 | { |
156 | const QStencilTest *stencilTest = static_cast<const QStencilTest *>(node); |
157 | std::get<0>(t&: m_values) = stencilTest->front()->stencilFunction(); |
158 | std::get<1>(t&: m_values) = stencilTest->front()->referenceValue(); |
159 | std::get<2>(t&: m_values) = stencilTest->front()->comparisonMask(); |
160 | std::get<3>(t&: m_values) = stencilTest->back()->stencilFunction(); |
161 | std::get<4>(t&: m_values) = stencilTest->back()->referenceValue(); |
162 | std::get<5>(t&: m_values) = stencilTest->back()->comparisonMask(); |
163 | } |
164 | |
165 | void PointSize::updateProperties(const QRenderState *node) |
166 | { |
167 | const QPointSize *pointSize = static_cast<const QPointSize *>(node); |
168 | |
169 | std::get<0>(t&: m_values) = (pointSize->sizeMode() == QPointSize::Programmable); |
170 | std::get<1>(t&: m_values) = pointSize->value(); |
171 | } |
172 | |
173 | void PolygonOffset::updateProperties(const QRenderState *node) |
174 | { |
175 | const QPolygonOffset *offset = static_cast<const QPolygonOffset *>(node); |
176 | |
177 | std::get<0>(t&: m_values) = offset->scaleFactor(); |
178 | std::get<1>(t&: m_values) = offset->depthSteps(); |
179 | } |
180 | |
181 | void ColorMask::updateProperties(const QRenderState *node) |
182 | { |
183 | const QColorMask *colorMask = static_cast<const QColorMask *>(node); |
184 | |
185 | std::get<0>(t&: m_values) = colorMask->isRedMasked(); |
186 | std::get<1>(t&: m_values) = colorMask->isGreenMasked(); |
187 | std::get<2>(t&: m_values) = colorMask->isBlueMasked(); |
188 | std::get<3>(t&: m_values) = colorMask->isAlphaMasked(); |
189 | } |
190 | |
191 | void ClipPlane::updateProperties(const QRenderState *node) |
192 | { |
193 | const QClipPlane *clipPlane = static_cast<const QClipPlane *>(node); |
194 | |
195 | std::get<0>(t&: m_values) = clipPlane->planeIndex(); |
196 | std::get<1>(t&: m_values) = clipPlane->normal(); |
197 | std::get<2>(t&: m_values) = clipPlane->distance(); |
198 | } |
199 | |
200 | void StencilOp::updateProperties(const QRenderState *node) |
201 | { |
202 | const QStencilOperation *stencilOp = static_cast<const QStencilOperation *>(node); |
203 | |
204 | std::get<0>(t&: m_values) = stencilOp->front()->stencilTestFailureOperation(); |
205 | std::get<1>(t&: m_values) = stencilOp->front()->depthTestFailureOperation(); |
206 | std::get<2>(t&: m_values) = stencilOp->front()->allTestsPassOperation(); |
207 | std::get<3>(t&: m_values) = stencilOp->back()->stencilTestFailureOperation(); |
208 | std::get<4>(t&: m_values) = stencilOp->back()->depthTestFailureOperation(); |
209 | std::get<5>(t&: m_values) = stencilOp->back()->allTestsPassOperation(); |
210 | } |
211 | |
212 | void StencilMask::updateProperties(const QRenderState *node) |
213 | { |
214 | const QStencilMask *stencilMask = static_cast<const QStencilMask *>(node); |
215 | std::get<0>(t&: m_values) = stencilMask->frontOutputMask(); |
216 | std::get<1>(t&: m_values) = stencilMask->backOutputMask(); |
217 | } |
218 | |
219 | void LineWidth::updateProperties(const QRenderState *node) |
220 | { |
221 | const QLineWidth *lineWidth = static_cast<const QLineWidth *>(node); |
222 | std::get<0>(t&: m_values) = lineWidth->value(); |
223 | std::get<1>(t&: m_values) = lineWidth->smooth(); |
224 | } |
225 | |
226 | } // namespace Render |
227 | } // namespace Qt3DRender |
228 | |
229 | QT_END_NAMESPACE |
230 |