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 "qalphatest.h" |
6 | #include "qalphatest_p.h" |
7 | |
8 | QT_BEGIN_NAMESPACE |
9 | |
10 | namespace Qt3DRender { |
11 | |
12 | /*! |
13 | \class Qt3DRender::QAlphaTest |
14 | \brief The QAlphaTest class specify alpha reference test. |
15 | \since 5.7 |
16 | \inmodule Qt3DRender |
17 | \ingroup renderstates |
18 | |
19 | As the OpenGL documentation explains; The alpha test discards a fragment |
20 | conditional on the outcome of a comparison between the incoming fragment's |
21 | alpha value and a constant reference value. |
22 | */ |
23 | |
24 | /*! |
25 | \qmltype AlphaTest |
26 | \brief The AlphaTest class specify alpha reference test. |
27 | \since 5.7 |
28 | \inqmlmodule Qt3D.Render |
29 | \inherits RenderState |
30 | \instantiates Qt3DRender::QAlphaTest |
31 | \ingroup renderstates |
32 | |
33 | As the OpenGL documentation explains; The alpha test discards a fragment |
34 | conditional on the outcome of a comparison between the incoming fragment's |
35 | alpha value and a constant reference value. |
36 | */ |
37 | |
38 | /*! |
39 | \enum Qt3DRender::QAlphaTest::AlphaFunction |
40 | |
41 | Enumeration for the alpha function values |
42 | \value Never Never pass alpha test |
43 | \value Always Always pass alpha test |
44 | \value Less Pass alpha test if fragment alpha is less than reference value |
45 | \value LessOrEqual Pass alpha test if fragment alpha is less than or equal to reference value |
46 | \value Equal Pass alpha test if fragment alpha is equal to reference value |
47 | \value GreaterOrEqual Pass alpha test if fragment alpha is greater than or equal to reference value |
48 | \value Greater Pass alpha test if fragment alpha is greater than reference value |
49 | \value NotEqual Pass alpha test if fragment alpha is not equal to reference value |
50 | */ |
51 | |
52 | /*! |
53 | \qmlproperty enumeration AlphaTest::alphaFunction |
54 | Holds the alpha function used by the alpha test. Default is AlphaTest.Never. |
55 | \list |
56 | \li AlphaTest.Never |
57 | \li AlphaTest.Always |
58 | \li AlphaTest.Less |
59 | \li AlphaTest.LessOrEqual |
60 | \li AlphaTest.Equal |
61 | \li AlphaTest.GreaterOrEqual |
62 | \li AlphaTest.Greater |
63 | \li AlphaTest.NotEqual |
64 | \endlist |
65 | \sa Qt3DRender::QAlphaTest::AlphaFunction |
66 | */ |
67 | |
68 | /*! |
69 | \qmlproperty real AlphaTest::referenceValue |
70 | Holds the reference value used by the alpha test. Default is 0.0. |
71 | When set, the value is clamped between 0 and 1. |
72 | */ |
73 | |
74 | /*! |
75 | \property QAlphaTest::alphaFunction |
76 | Holds the alpha function used by the alpha test. Default is Never. |
77 | */ |
78 | |
79 | /*! |
80 | \property QAlphaTest::referenceValue |
81 | Holds the reference value used by the alpha test. Default is 0.0. |
82 | When set, the value is clamped between 0 and 1. |
83 | */ |
84 | |
85 | |
86 | QAlphaTest::QAlphaTest(QNode *parent) |
87 | : QRenderState(*new QAlphaTestPrivate, parent) |
88 | { |
89 | } |
90 | |
91 | /*! \internal */ |
92 | QAlphaTest::~QAlphaTest() |
93 | { |
94 | } |
95 | |
96 | QAlphaTest::AlphaFunction QAlphaTest::alphaFunction() const |
97 | { |
98 | Q_D(const QAlphaTest); |
99 | return d->m_alphaFunction; |
100 | } |
101 | |
102 | void QAlphaTest::setAlphaFunction(QAlphaTest::AlphaFunction alphaFunction) |
103 | { |
104 | Q_D(QAlphaTest); |
105 | if (d->m_alphaFunction != alphaFunction) { |
106 | d->m_alphaFunction = alphaFunction; |
107 | emit alphaFunctionChanged(alphaFunction); |
108 | } |
109 | } |
110 | |
111 | float QAlphaTest::referenceValue() const |
112 | { |
113 | Q_D(const QAlphaTest); |
114 | return d->m_referenceValue; |
115 | } |
116 | |
117 | void QAlphaTest::setReferenceValue(float referenceValue) |
118 | { |
119 | Q_D(QAlphaTest); |
120 | if (d->m_referenceValue != referenceValue) { |
121 | d->m_referenceValue = referenceValue; |
122 | emit referenceValueChanged(referenceValue); |
123 | } |
124 | } |
125 | |
126 | } // namespace Qt3DRender |
127 | |
128 | QT_END_NAMESPACE |
129 | |
130 | #include "moc_qalphatest.cpp" |
131 | |