QQuick3DTextureProviderExtension Class
用于实现用户端纹理提供程序扩展的抽象类。更多内容...
| Header: | #include <QQuick3DTextureProviderExtension> |
| Since: | Qt 6.11 |
| In QML: | TextureProviderExtension |
| Inherits: | QQuick3DRenderExtension |
公共类型
| enum class | SamplerHint { Sampler2D, Sampler2DArray, Sampler3D, SamplerCube, SamplerCubeArray, SamplerBuffer } |
属性
(since 6.11)samplerHint : SamplerHint
公共函数
| QQuick3DTextureProviderExtension::SamplerHint | samplerHint() const |
| void | setSamplerHint(QQuick3DTextureProviderExtension::SamplerHint newSamplerHint) |
信号
| void | samplerHintChanged() |
(since 6.12) void | surfaceChanged() |
重新实现的受保护函数
| virtual QSSGRenderGraphObject * | updateSpatialNode(QSSGRenderGraphObject *node) override |
详细说明
这是纹理提供程序扩展的前端部分。后端部分在QSSGRenderExtension 中实现。QQuick3DTextureProviderExtension是QQuick3DRenderExtension 类的特化类,用于创建自定义纹理提供程序扩展,该扩展既能提供关于将要提供的纹理类型的附加元数据,又能自动将扩展注册到QtQuick3D 场景图中。 这意味着无需手动将该扩展添加到View3D 的扩展列表中,只需使用Texture组件的textureProvider属性,即可在必要时触发扩展代码的执行。
QQuick3DTextureProviderExtension 类是一个抽象类,应通过子类继承并向 QML 公开。子类应实现QQuick3DRenderExtension::updateSpatialNode() 函数,并返回一个包含待执行代码的QSSGRenderExtension 实例。
另请参阅 QSSGRenderExtension 。
成员类型文档
enum class QQuick3DTextureProviderExtension::SamplerHint
指定有关该扩展将提供的纹理类型的提示。
| 常量 | 值 | 描述 |
|---|---|---|
QQuick3DTextureProviderExtension::SamplerHint::Sampler2D | 0 | 一个 2D 纹理 |
QQuick3DTextureProviderExtension::SamplerHint::Sampler2DArray | 1 | 数组纹理 |
QQuick3DTextureProviderExtension::SamplerHint::Sampler3D | 2 | 一个 3D 纹理 |
QQuick3DTextureProviderExtension::SamplerHint::SamplerCube | 3 | 立方体贴图 |
QQuick3DTextureProviderExtension::SamplerHint::SamplerCubeArray | 4 | 立方体贴图数组 |
QQuick3DTextureProviderExtension::SamplerHint::SamplerBuffer | 5 | 缓冲区纹理 |
属性文档
[since 6.11] samplerHint : SamplerHint
该属性包含有关扩展将提供的纹理类型的提示。这是必要的,因为纹理数据只有在需要时才会提供,但使用“纹理”组件的材质需要知道应提供何种类型的采样器。
默认值为QQuick3DTextureProviderExtension::Sampler2D 。
注意: 仅在使用 CustomMaterials 时才会用到此 属性。
该枚举在 Qt 6.11 中引入。
访问函数:
| QQuick3DTextureProviderExtension::SamplerHint | samplerHint() const |
| void | setSamplerHint(QQuick3DTextureProviderExtension::SamplerHint newSamplerHint) |
通知信号:
| void | samplerHintChanged() |
另请参阅 SamplerHint 。
成员函数文档
[signal, since 6.12] void QQuick3DTextureProviderExtension::surfaceChanged()
当底层渲染表面发生变化且需要重新生成纹理时,会发出此信号。
该函数于 Qt 6.12 版本中引入。
[override virtual protected] QSSGRenderGraphObject *QQuick3DTextureProviderExtension::updateSpatialNode(QSSGRenderGraphObject *node)
重写自:QQuick3DRenderExtension::updateSpatialNode(QSSGRenderGraphObject *node)。
当创建项目或请求更新时(通常是由于项目属性的变化),该函数会在QtQuick3D 场景图的同步过程中被调用。该函数应返回一个QSSGRenderTextureProviderExtension 实例,其中包含应在QtQuick3D 的渲染管道执行期间运行的代码。
node 参数是该函数之前返回的QSSGRenderTextureProviderExtension 实例;若为首次调用该函数,则该参数为null。该函数可返回同一实例、不同实例或null。若函数返回null,则该扩展将从渲染管道中移除。
注意: QSSGRenderTextureProviderExtension 实例是一个 资源对象,并将由QtQuick3D 场景图拥有。如果返回的是另一个实例或 null,则渲染器会将之前的实例加入待删除队列。
© 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.