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 "qdepthtest.h" |
6 | #include "qdepthtest_p.h" |
7 | |
8 | QT_BEGIN_NAMESPACE |
9 | |
10 | namespace Qt3DRender { |
11 | |
12 | /*! |
13 | \class Qt3DRender::QDepthTest |
14 | \brief The QDepthTest class tests the fragment shader's depth value against |
15 | the depth of a sample being written to. |
16 | \since 5.7 |
17 | \inmodule Qt3DRender |
18 | \ingroup renderstates |
19 | |
20 | A QDepthTest class is used to enable depth testing with a given depth test function. |
21 | The depth test enables writing fragment color values when the depth test passes, and |
22 | reject fragments which fail the test. The depth test uses the depth function to |
23 | test the fragments depth value to the value against z-buffer. If the underlying surface |
24 | does not have z-buffer, then QDepthTest does nothing. |
25 | |
26 | \sa QAlphaTest, QStencilTest |
27 | */ |
28 | |
29 | /*! |
30 | \qmltype DepthTest |
31 | \brief The DepthTest type tests the fragment shader's depth value against |
32 | the depth of a sample being written to. |
33 | \since 5.7 |
34 | \inqmlmodule Qt3D.Render |
35 | \inherits RenderState |
36 | \instantiates Qt3DRender::QDepthTest |
37 | \ingroup renderstates |
38 | |
39 | A DepthTest type is used to enable depth testing with a given depth test function. |
40 | The depth test enables writing fragment color values when the depth test passes, and |
41 | reject fragments which fail the test. The depth test uses the depth function to |
42 | test the fragments depth value to the value against z-buffer. If the underlying surface |
43 | does not have z-buffer, the DepthTest does nothing. |
44 | |
45 | \sa AlphaTest, StencilTest |
46 | */ |
47 | |
48 | /*! |
49 | \enum Qt3DRender::QDepthTest::DepthFunction |
50 | |
51 | Enumeration for the depth function values |
52 | \value Never Never pass depth test |
53 | \value Always Always pass depth test |
54 | \value Less Pass depth test if fragment depth is less than z-buffer value |
55 | \value LessOrEqual Pass depth test if fragment depth is less than or equal to z-buffer value |
56 | \value Equal Pass depth test if fragment depth is equal to z-buffer value |
57 | \value GreaterOrEqual Pass depth test if fragment depth is greater than or equal to z-buffer value |
58 | \value Greater Pass depth test if fragment depth is greater than z-buffer value |
59 | \value NotEqual Pass depth test if fragment depth is not equal to z-buffer value |
60 | */ |
61 | |
62 | /*! |
63 | \qmlproperty enumeration DepthTest::depthFunction |
64 | Holds the current function used by depth test. The default is DepthTest.Never. |
65 | \list |
66 | \li DepthTest.Never |
67 | \li DepthTest.Always |
68 | \li DepthTest.Less |
69 | \li DepthTest.LessOrEqual |
70 | \li DepthTest.Equal |
71 | \li DepthTest.GreaterOrEqual |
72 | \li DepthTest.Greater |
73 | \li DepthTest.NotEqual |
74 | \endlist |
75 | \sa Qt3DRender::QDepthTest::DepthFunction |
76 | */ |
77 | |
78 | /*! |
79 | \property QDepthTest::depthFunction |
80 | Holds the current function used by depth test. The default is Never. |
81 | */ |
82 | |
83 | |
84 | /*! |
85 | The constructor creates a new QDepthTest::QDepthTest instance with the specified \a parent. |
86 | */ |
87 | QDepthTest::QDepthTest(QNode *parent) |
88 | : QRenderState(*new QDepthTestPrivate, parent) |
89 | { |
90 | } |
91 | |
92 | /*! \internal */ |
93 | QDepthTest::~QDepthTest() |
94 | { |
95 | } |
96 | |
97 | QDepthTest::DepthFunction QDepthTest::depthFunction() const |
98 | { |
99 | Q_D(const QDepthTest); |
100 | return d->m_depthFunction; |
101 | } |
102 | |
103 | void QDepthTest::setDepthFunction(QDepthTest::DepthFunction depthFunction) |
104 | { |
105 | Q_D(QDepthTest); |
106 | if (d->m_depthFunction != depthFunction) { |
107 | d->m_depthFunction = depthFunction; |
108 | emit depthFunctionChanged(depthFunction); |
109 | } |
110 | } |
111 | |
112 | } // namespace Qt3DRender |
113 | |
114 | QT_END_NAMESPACE |
115 | |
116 | #include "moc_qdepthtest.cpp" |
117 | |