1/****************************************************************************
2**
3** Copyright (C) 2018 Klaralvdalens Datakonsult AB (KDAB).
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt3D module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#include "qrastermode.h"
41#include "qrastermode_p.h"
42#include <Qt3DRender/private/qrenderstatecreatedchange_p.h>
43
44QT_BEGIN_NAMESPACE
45
46namespace Qt3DRender {
47
48/*!
49 \class Qt3DRender::QRasterMode
50 \brief The QRasterMode render state allows to control the type of
51 rasterization to be performed.
52 \since 5.14
53 \inmodule Qt3DRender
54 \ingroup renderstates
55
56 The QRasterMode class is used to control the rasterization step of the
57 primitives at render time. This can be used to choose whether we only
58 want to show points, edges or fill a primitive.
59
60 \note This is not supported when rendering on OpenGL ES 2.0 platforms.
61
62 \sa QAlphaTest, QStencilTest
63 */
64
65/*!
66 \qmltype RasterMode
67 \brief The RasterMode render state allows to control the type of
68 rasterization to be performed.
69 \since 5.14
70 \inqmlmodule Qt3D.Render
71 \inherits RenderState
72 \instantiates Qt3DRender::QRasterMode
73 \ingroup renderstates
74
75 The QRasterMode class is used to control the rasterization step of the
76 primitives at render time. This can be used to choose whether we only
77 want to show points, edges or fill a primitive.
78
79 \note This is not supported when rendering on OpenGL ES 2.0 platforms.
80
81 \sa AlphaTest, StencilTest
82 */
83
84/*!
85 \enum Qt3DRender::QRasterMode::RasterMode
86
87 Enumeration for raster mode values
88 \value Points Vertices at the start of an edge are drawn as points.
89 \value Lines Edges of a polygon are draw as line segments.
90 \value Fill Fills the interior of the primitive.
91*/
92
93/*!
94 \enum Qt3DRender::QRasterMode::FaceMode
95
96 Enumeration for face mode values
97 \value Front Applies to front faces only
98 \value Back Applies to back faces only
99 \value FrontAndBack Applies to front and back faces
100*/
101
102/*!
103 \property QRasterMode::rasterMode
104
105 Holds the raster mode to be used.
106*/
107
108/*!
109 \property QRasterMode::faceMode
110
111 Holds the face mode to be used. Controls on which face the raster mode is
112 to be applied.
113*/
114
115/*!
116 \qmlproperty enumeration RasterMode::rasterMode
117
118 Holds the raster mode to be used.
119
120 \list
121 \li Points Vertices at the start of an edge are drawn as points.
122 \li Lines Edges of a polygon are draw as line segments.
123 \li Fill Fills the interior of the primitive.
124 \endlist
125*/
126
127/*!
128 \qmlproperty enumeration RasterMode::faceMode
129
130 Holds the face mode to be used. Controls on which face the raster mode is
131 to be applied.
132
133 \list
134 \li Front Applies to front faces only
135 \li Back Applies to back faces only
136 \li FrontAndBack Applies to front and back faces
137 \endlist
138*/
139
140
141
142QRasterMode::QRasterMode(QNode *parent)
143 : QRenderState(*new QRasterModePrivate, parent)
144{
145}
146
147/*!
148 \internal
149*/
150QRasterMode::~QRasterMode()
151 = default;
152
153QRasterMode::RasterMode QRasterMode::rasterMode() const
154{
155 Q_D(const QRasterMode);
156 return d->m_rasterMode;
157}
158
159QRasterMode::FaceMode QRasterMode::faceMode() const
160{
161 Q_D(const QRasterMode);
162 return d->m_faceMode;
163}
164
165void QRasterMode::setRasterMode(QRasterMode::RasterMode rasterMode)
166{
167 Q_D(QRasterMode);
168 if (d->m_rasterMode != rasterMode) {
169 d->m_rasterMode = rasterMode;
170 emit rasterModeChanged(rasterMode);
171 }
172}
173
174void QRasterMode::setFaceMode(QRasterMode::FaceMode faceMode)
175{
176 Q_D(QRasterMode);
177 if (d->m_faceMode != faceMode) {
178 d->m_faceMode = faceMode;
179 emit faceModeChanged(faceMode);
180 }
181}
182
183Qt3DCore::QNodeCreatedChangeBasePtr QRasterMode::createNodeCreationChange() const
184{
185 auto creationChange = QRenderStateCreatedChangePtr<QRasterModeData>::create(arguments: this);
186 auto &data = creationChange->data;
187 Q_D(const QRasterMode);
188 data.rasterMode = d->m_rasterMode;
189 data.faceMode = d->m_faceMode;
190 return creationChange;
191}
192
193} // namespace Qt3DRender
194
195QT_END_NAMESPACE
196

source code of qt3d/src/render/renderstates/qrastermode.cpp