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 "qstenciltest.h" |
6 | #include "qstenciltest_p.h" |
7 | #include "qstenciltestarguments.h" |
8 | |
9 | QT_BEGIN_NAMESPACE |
10 | |
11 | namespace Qt3DRender { |
12 | |
13 | /*! |
14 | \class Qt3DRender::QStencilTest |
15 | \since 5.7 |
16 | \ingroup renderstates |
17 | \inmodule Qt3DRender |
18 | \brief The QStencilTest class specifies arguments for the stecil test. |
19 | |
20 | A Qt3DRender::QStencilTest class specifies argument for the stencil test. |
21 | The stencil test comprises of three arguments: stencil test function, |
22 | stencil test mask and stencil reference value. QStencilTest allows these |
23 | arguments to be set for both front- and back-facing polygons separately. |
24 | |
25 | \sa Qt3DRender::QStencilMask, Qt3DRender::QStencilOperation |
26 | */ |
27 | |
28 | /*! |
29 | \qmltype StencilTest |
30 | \since 5.7 |
31 | \ingroup renderstates |
32 | \inqmlmodule Qt3D.Render |
33 | \brief The StencilTest type specifies arguments for the stecil test. |
34 | \inherits RenderState |
35 | \instantiates Qt3DRender::QStencilTest |
36 | |
37 | A StencilTest type specifies argument for the stencil test. |
38 | The stencil test comprises of three arguments: stencil test function, |
39 | stencil test mask and stencil reference value. StencilTest allows these |
40 | arguments to be set for both front- and back-facing polygons separately. |
41 | |
42 | \sa StencilMask, StencilOperation |
43 | */ |
44 | |
45 | /*! |
46 | \qmlproperty StencilTestArguments StencilTest::front |
47 | Holds the stencil test arguments for front-facing polygons. |
48 | */ |
49 | |
50 | /*! |
51 | \qmlproperty StencilTestArguments StencilTest::back |
52 | Holds the stencil test arguments for back-facing polygons. |
53 | */ |
54 | |
55 | /*! |
56 | \property QStencilTest::front |
57 | Holds the stencil test arguments for front-facing polygons. |
58 | */ |
59 | |
60 | /*! |
61 | \property QStencilTest::back |
62 | Holds the stencil test arguments for back-facing polygons. |
63 | */ |
64 | |
65 | /*! |
66 | The constructor creates a new QStencilTest::QStencilTest instance with |
67 | the specified \a parent. |
68 | */ |
69 | QStencilTest::QStencilTest(QNode *parent) |
70 | : QRenderState(*new QStencilTestPrivate, parent) |
71 | { |
72 | Q_D(QStencilTest); |
73 | |
74 | const auto resend = [d]() { d->update(); }; |
75 | |
76 | (void) connect(sender: d->m_front, signal: &QStencilTestArguments::comparisonMaskChanged, slot: resend); |
77 | (void) connect(sender: d->m_front, signal: &QStencilTestArguments::faceModeChanged, slot: resend); |
78 | (void) connect(sender: d->m_front, signal: &QStencilTestArguments::referenceValueChanged, slot: resend); |
79 | (void) connect(sender: d->m_front, signal: &QStencilTestArguments::stencilFunctionChanged, slot: resend); |
80 | |
81 | (void) connect(sender: d->m_back, signal: &QStencilTestArguments::comparisonMaskChanged, slot: resend); |
82 | (void) connect(sender: d->m_back, signal: &QStencilTestArguments::faceModeChanged, slot: resend); |
83 | (void) connect(sender: d->m_back, signal: &QStencilTestArguments::referenceValueChanged, slot: resend); |
84 | (void) connect(sender: d->m_back, signal: &QStencilTestArguments::stencilFunctionChanged, slot: resend); |
85 | } |
86 | |
87 | /*! \internal */ |
88 | QStencilTest::~QStencilTest() |
89 | { |
90 | } |
91 | |
92 | /*! \internal */ |
93 | void QStencilTestPrivate::fillData(QStencilTestData &data) const |
94 | { |
95 | data.front.face = m_front->faceMode(); |
96 | data.front.comparisonMask = m_front->comparisonMask(); |
97 | data.front.referenceValue = m_front->referenceValue(); |
98 | data.front.stencilFunction = m_front->stencilFunction(); |
99 | data.back.face = m_back->faceMode(); |
100 | data.back.comparisonMask = m_back->comparisonMask(); |
101 | data.back.referenceValue = m_back->referenceValue(); |
102 | data.back.stencilFunction = m_back->stencilFunction(); |
103 | } |
104 | |
105 | QStencilTestArguments *QStencilTest::front() const |
106 | { |
107 | Q_D(const QStencilTest); |
108 | return d->m_front; |
109 | } |
110 | |
111 | QStencilTestArguments *QStencilTest::back() const |
112 | { |
113 | Q_D(const QStencilTest); |
114 | return d->m_back; |
115 | } |
116 | |
117 | } // namespace Qt3DRender |
118 | |
119 | QT_END_NAMESPACE |
120 | |
121 | #include "moc_qstenciltest.cpp" |
122 | |