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 | |
6 | #include "qcullface.h" |
7 | #include "qcullface_p.h" |
8 | |
9 | QT_BEGIN_NAMESPACE |
10 | |
11 | namespace Qt3DRender { |
12 | |
13 | /*! |
14 | \class Qt3DRender::QCullFace |
15 | \brief The QCullFace class specifies whether front or back face culling |
16 | is enabled. |
17 | \since 5.7 |
18 | \inmodule Qt3DRender |
19 | \ingroup renderstates |
20 | |
21 | QCullFace sets whether the front or back facets are culled. |
22 | Facets include triangles, quadrilaterals, polygons and rectangles. |
23 | |
24 | It can be added by calling the addRenderState() method on a QRenderPass: |
25 | |
26 | \code |
27 | // using namespace Qt3DRender; |
28 | |
29 | QRenderPass *renderPass = new QRenderPass(); |
30 | |
31 | // Create a front face culling render state |
32 | QCullFace *cullFront = new QCullFace(); |
33 | cullFront->setMode(QCullFace::Front); |
34 | |
35 | // Add the render state to the render pass |
36 | renderPass->addRenderState(cullFront); |
37 | \endcode |
38 | |
39 | Or by calling the addRenderState() method on a QRenderStateSet: |
40 | |
41 | \code |
42 | // using namespace Qt3DRender; |
43 | |
44 | QRenderStateSet *renderStateSet = new QRenderStateSet(); |
45 | |
46 | // Create a front face culling render state |
47 | QCullFace *cullFront = new QCullFace(); |
48 | cullFront->setMode(QCullFace::Front); |
49 | |
50 | // Add the render state to the render pass |
51 | renderStateSet->addRenderState(cullFront); |
52 | \endcode |
53 | |
54 | \sa QFrontFace |
55 | */ |
56 | |
57 | /*! |
58 | \qmltype CullFace |
59 | \brief The CullFace type specifies whether front or back face culling |
60 | is enabled. |
61 | \since 5.7 |
62 | \inqmlmodule Qt3D.Render |
63 | \instantiates Qt3DRender::QCullFace |
64 | \inherits RenderState |
65 | \ingroup renderstates |
66 | |
67 | CullFace sets whether the front or back facets are culled. |
68 | Facets include triangles, quadrilaterals, polygons and rectangles. |
69 | |
70 | It can be added to the renderStates property of a RenderPass: |
71 | |
72 | \qml |
73 | RenderPass { |
74 | shaderProgram: ShaderProgram { |
75 | // ... |
76 | } |
77 | renderStates: [ |
78 | CullFace { |
79 | mode: CullFace.Front |
80 | } |
81 | ] |
82 | } |
83 | \endqml |
84 | |
85 | Or added to the renderStates property of a RenderStateSet: |
86 | |
87 | \qml |
88 | RenderStateSet { |
89 | renderStates: [ |
90 | CullFace { |
91 | mode: CullFace.Front |
92 | } |
93 | ] |
94 | } |
95 | \endqml |
96 | |
97 | \sa FrontFace |
98 | */ |
99 | |
100 | /*! |
101 | \enum Qt3DRender::QCullFace::CullingMode |
102 | |
103 | This enumeration specifies values for the culling mode. |
104 | |
105 | \value NoCulling Culling is disabled |
106 | \value Front Culling is enabled for front facing polygons |
107 | \value Back Culling is enabled for back facing polygons |
108 | \value FrontAndBack Culling is enabled for all polygons, points and lines are drawn |
109 | */ |
110 | |
111 | /*! |
112 | \qmlproperty enumeration CullFace::mode |
113 | Holds the culling mode used by CullFace. Default is set to QCullFace.Back. |
114 | |
115 | \list |
116 | \li CullFace.NoCulling - culling is disabled |
117 | \li CullFace.Front - culling is enabled for front facing polygons |
118 | \li CullFace.Back - culling is enabled for back facing polygons |
119 | \li CullFace.FrontAndBack - culling is enabled for all polygons, but points and lines are drawn |
120 | \endlist |
121 | */ |
122 | |
123 | /*! |
124 | \property QCullFace::mode |
125 | Holds the culling mode used by QCullFace. Default is set to QCullFace.Back. |
126 | */ |
127 | |
128 | /*! |
129 | Constructs a new QCullFace::QCullFace instance with \a parent as parent. |
130 | */ |
131 | QCullFace::QCullFace(QNode *parent) |
132 | : QRenderState(*new QCullFacePrivate, parent) |
133 | { |
134 | } |
135 | |
136 | /*! \internal */ |
137 | QCullFace::~QCullFace() |
138 | { |
139 | } |
140 | |
141 | QCullFace::CullingMode QCullFace::mode() const |
142 | { |
143 | Q_D(const QCullFace); |
144 | return d->m_mode; |
145 | } |
146 | |
147 | void QCullFace::setMode(QCullFace::CullingMode mode) |
148 | { |
149 | Q_D(QCullFace); |
150 | if (d->m_mode != mode) { |
151 | d->m_mode = mode; |
152 | emit modeChanged(mode); |
153 | } |
154 | } |
155 | |
156 | } // namespace Qt3DRender |
157 | |
158 | QT_END_NAMESPACE |
159 | |
160 | #include "moc_qcullface.cpp" |
161 | |