本页内容

Qt3DRender::QDepthTest Class

class Qt3DRender::QDepthTest

QDepthTest 类用于将片段着色器的深度值与正在写入的采样点的深度进行比较。更多内容...

头文件: #include <qdepthtest.h>
CMake: find_package(Qt6 REQUIRED COMPONENTS 3drender)
target_link_libraries(mytarget PRIVATE Qt6::3drender)
qmake: QT += 3drender
在 QML 中: DepthTest
继承自: Qt3DRender::QRenderState
状态: 已弃用

该类已弃用。我们强烈建议不要在新的代码中使用它。

公共类型

enum DepthFunction { Never, Always, Less, LessOrEqual, Equal, …, NotEqual }

属性

公共函数

QDepthTest(Qt3DCore::QNode *parent = nullptr)
Qt3DRender::QDepthTest::DepthFunction depthFunction() const

公共槽位

void setDepthFunction(Qt3DRender::QDepthTest::DepthFunction depthFunction)

信号

void depthFunctionChanged(Qt3DRender::QDepthTest::DepthFunction depthFunction)

详细说明

QDepthTest 类用于通过给定的深度测试函数启用深度测试。深度测试允许在通过深度测试时写入片段颜色值,并拒绝未通过测试的片段。 深度测试使用深度函数,将片段的深度值与 z-buffer 中的值进行比较。如果底层表面没有 z-buffer,则 QDepthTest 不执行任何操作。

另请参阅 QAlphaTest 和QStencilTest 。

成员类型文档

enum QDepthTest::DepthFunction

深度函数值的枚举

常量值描述
Qt3DRender::QDepthTest::Never0x0200永远不通过深度测试
Qt3DRender::QDepthTest::Always0x0207始终通过深度测试
Qt3DRender::QDepthTest::Less0x0201若片段深度小于 z 缓冲区值,则通过深度测试
Qt3DRender::QDepthTest::LessOrEqual0x0203若片段深度小于或等于 z 缓冲区值,则通过深度测试
Qt3DRender::QDepthTest::Equal0x0202如果片段深度等于 z 缓冲区值,则通过深度测试
Qt3DRender::QDepthTest::GreaterOrEqual0x0206如果片段深度大于或等于 z 缓冲区值,则通过深度测试
Qt3DRender::QDepthTest::Greater0x0204如果片元深度大于 z 缓冲区值,则通过深度测试
Qt3DRender::QDepthTest::NotEqual0x0205如果片元深度不等于 z-缓冲区值,则通过深度测试

属性文档

depthFunction : DepthFunction

保存深度测试当前使用的函数。默认值为 Never。

访问函数:

Qt3DRender::QDepthTest::DepthFunction depthFunction() const
void setDepthFunction(Qt3DRender::QDepthTest::DepthFunction depthFunction)

通知器信号:

void depthFunctionChanged(Qt3DRender::QDepthTest::DepthFunction depthFunction)

成员函数文档

[explicit] QDepthTest::QDepthTest(Qt3DCore::QNode *parent = nullptr)

该构造函数会使用指定的parent 创建一个新的QDepthTest::QDepthTest 实例。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.