QSGOpaqueTextureMaterial Class
QSGOpaqueTextureMaterial 类提供了一种在场景图中渲染带纹理几何体的便捷方法。更多内容...
| 头文件: | #include <QSGOpaqueTextureMaterial> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Quick) target_link_libraries(mytarget PRIVATE Qt6::Quick) |
| qmake: | QT += quick |
| 继承自: | QSGMaterial |
| 被继承者: |
- 所有成员列表(包括继承的成员)
- QSGOpaqueTextureMaterial 属于Qt Quick 场景图材质类。
公共函数
| QSGOpaqueTextureMaterial() | |
| QSGTexture::AnisotropyLevel | anisotropyLevel() const |
| QSGTexture::Filtering | filtering() const |
| QSGTexture::WrapMode | horizontalWrapMode() const |
| QSGTexture::Filtering | mipmapFiltering() const |
| void | setAnisotropyLevel(QSGTexture::AnisotropyLevel level) |
| void | setFiltering(QSGTexture::Filtering filtering) |
| void | setHorizontalWrapMode(QSGTexture::WrapMode mode) |
| void | setMipmapFiltering(QSGTexture::Filtering filtering) |
| void | setTexture(QSGTexture *texture) |
| void | setVerticalWrapMode(QSGTexture::WrapMode mode) |
| QSGTexture * | texture() const |
| QSGTexture::WrapMode | verticalWrapMode() const |
详细描述
警告:此 实用类仅在与Qt Quick 场景图的默认后端配合运行时才有效。
不透明纹理材质将使用提供的纹理填充几何体中的每个像素。该材质不考虑QSGMaterialShader::RenderState 的不透明度,因此,在使用此材质的节点父链中的不透明度节点将不起作用。
要使用不透明纹理材质进行渲染的几何体,其顶点属性位置 0 处需包含顶点数据,属性位置 1 处需包含纹理坐标。纹理坐标是一个二维浮点数元组。QSGGeometry::defaultAttributes_TexturedPoint2D 会返回与该材质兼容的属性集。
待渲染的纹理可通过 `setTexture()` 进行设置。纹理的渲染方式可通过 `setMipmapFiltering()`、`setFiltering()`、`setHorizontalWrapMode()` 和 `setVerticalWrapMode()` 进行指定。渲染状态在纹理实例绑定之前对其进行设置。
不透明纹理材质会遵循当前的变换矩阵和纹理的Alpha通道,但会忽略场景图中累积的不透明度。
纹理材质在作为场景图中的材质使用之前,必须已设置好纹理。
成员函数文档
QSGOpaqueTextureMaterial::QSGOpaqueTextureMaterial()
创建一个新的 QSGOpaqueTextureMaterial。
默认的Mipmap过滤和过滤模式设置为QSGTexture::Nearest 。默认的贴图循环模式设置为QSGTexture::ClampToEdge 。
QSGTexture::AnisotropyLevel QSGOpaqueTextureMaterial::anisotropyLevel() const
返回该材质的各向异性级别。
另请参阅 setAnisotropyLevel()。
QSGTexture::Filtering QSGOpaqueTextureMaterial::filtering() const
返回该材质的过滤模式。
默认过滤模式为QSGTexture::Nearest 。
另请参阅 setFiltering()。
QSGTexture::WrapMode QSGOpaqueTextureMaterial::horizontalWrapMode() const
返回该材质水平换行模式。
默认的水平换行模式为QSGTexture::ClampToEdge 。
另请参阅 setHorizontalWrapMode()。
QSGTexture::Filtering QSGOpaqueTextureMaterial::mipmapFiltering() const
返回该材质的Mipmap过滤模式。
默认的Mipmap模式为QSGTexture::Nearest 。
另请参阅 setMipmapFiltering()。
void QSGOpaqueTextureMaterial::setAnisotropyLevel(QSGTexture::AnisotropyLevel level)
将该材料的各向异性级别设置为level 。
另请参阅 anisotropyLevel()。
void QSGOpaqueTextureMaterial::setFiltering(QSGTexture::Filtering filtering)
将过滤模式设置为filtering 。
在将纹理绑定用于渲染之前,会在纹理实例上设置过滤模式。
另请参阅 filtering()。
void QSGOpaqueTextureMaterial::setHorizontalWrapMode(QSGTexture::WrapMode mode)
将水平环绕模式设置为mode 。
在将纹理绑定用于渲染之前,需先在纹理实例上设置水平折行模式。
另请参阅 horizontalWrapMode()。
void QSGOpaqueTextureMaterial::setMipmapFiltering(QSGTexture::Filtering filtering)
将Mipmap模式设置为filtering 。
在将纹理绑定用于渲染之前,会在纹理实例上设置微贴图过滤模式。
如果纹理不支持米普映射,则启用米普映射不会产生任何效果。
另请参阅 mipmapFiltering()。
void QSGOpaqueTextureMaterial::setTexture(QSGTexture *texture)
将该材质的纹理设置为texture 。
该材质不会拥有该纹理的所有权。
另请参阅 texture()。
void QSGOpaqueTextureMaterial::setVerticalWrapMode(QSGTexture::WrapMode mode)
将垂直折行模式设置为mode 。
在将纹理绑定用于渲染之前,需先在纹理实例上设置垂直折行模式。
另请参阅 verticalWrapMode()。
QSGTexture *QSGOpaqueTextureMaterial::texture() const
返回该纹理材质的纹理。
另请参阅 setTexture()。
QSGTexture::WrapMode QSGOpaqueTextureMaterial::verticalWrapMode() const
返回该材质的垂直换行模式。
默认的垂直换行模式为QSGTexture::ClampToEdge 。
另请参阅 setVerticalWrapMode()。
© 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.