Qt3DRender::QTextureImage Class

class Qt3DRender::QTextureImage

封装了从图像源创建 OpenGL 纹理图像的必要信息。更多

头文件: #include <QTextureImage>
CMake: find_package(Qt6 REQUIRED COMPONENTS 3drender)
target_link_libraries(mytarget PRIVATE Qt6::3drender)
qmake: QT += 3drender
在 QML 中: TextureImage
继承: Qt3DRender::QAbstractTextureImage
状态:已废弃

公共类型

enum Status { None, Loading, Ready, Error }

属性

公共功能

QTextureImage(Qt3DCore::QNode *parent = nullptr)
bool isMirrored() const
QUrl source() const
Qt3DRender::QTextureImage::Status status() const

公共插槽

void setMirrored(bool mirrored)
void setSource(const QUrl &source)

信号

void mirroredChanged(bool mirrored)
void sourceChanged(const QUrl &source)
void statusChanged(Qt3DRender::QTextureImage::Status status)

受保护功能

void setStatus(Qt3DRender::QTextureImage::Status status)

详细说明

它包含必要的 mipmap 级别、层、立方体面和源 URL 信息,以便在适当的位置将数据加载到 OpenGL 纹理中。

成员类型文档

enum QTextureImage::Status

该枚举用于指定纹理图像加载的状态值。

常量说明
Qt3DRender::QTextureImage::None0纹理图像加载尚未开始。
Qt3DRender::QTextureImage::Loading1纹理图像加载已开始,但尚未完成。
Qt3DRender::QTextureImage::Ready2纹理图像加载已完成。
Qt3DRender::QTextureImage::Error3纹理图像加载遇到错误。

属性文档

mirrored : bool

此属性用于指定加载图像时是否应镜像图像。这是为了避免操作图像以匹配渲染 API 所用纹理坐标的原点。默认情况下,该属性设置为 true。在使用 GPU 压缩纹理格式时,此属性没有任何作用。

警告 在加载未压缩或 CPU 压缩的图像格式(如 PNG)时,此属性会导致在运行时付出性能代价。为避免这种性能代价,最好将此属性设置为 false,并加载已预先镜像的纹理资产。

注: OpenGL 从左下角指定纹理坐标的原点,而 DirectX 则使用左上角。

注: 在使用立方体贴图纹理时,您可能需要禁用镜像功能,因为立方体贴图采样器获取的是一个方向,而不是常规纹理坐标。

访问功能

bool isMirrored() const
void setMirrored(bool mirrored)

通知信号

void mirroredChanged(bool mirrored)

source : QUrl

此属性保存加载纹理图像数据的源 url。

访问功能:

QUrl source() const
void setSource(const QUrl &source)

通知信号:

void sourceChanged(const QUrl &source)

[read-only] status : const Status

此属性用于显示纹理图像的加载状态。

访问功能:

Qt3DRender::QTextureImage::Status status() const

Notifier 信号:

void statusChanged(Qt3DRender::QTextureImage::Status status)

成员函数 文档

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

构造一个新的Qt3DRender::QTextureImage 实例,parent 为父实例。

bool QTextureImage::isMirrored() const

返回镜像是否启用。

注: 属性mirrored 的获取函数。

[slot] void QTextureImage::setMirrored(bool mirrored)

将镜像设置为mirrored

注: 这会在内部触发更新数据生成器的调用。

注: 属性mirrored 的设置函数。

另请参阅 isMirrored() 。

[slot] void QTextureImage::setSource(const QUrl &source)

将纹理图片的源 url 设置为source

注: 这将在内部触发更新数据生成器的调用。

注: 属性source 的设置函数。

另请参阅 source().

[protected] void QTextureImage::setStatus(Qt3DRender::QTextureImage::Status status)

状态设置为status

另请参阅 status().

QUrl QTextureImage::source() const

返回加载纹理图像数据的源 url。

注: 属性源的获取函数。

另请参阅 setSource()。

Qt3DRender::QTextureImage::Status QTextureImage::status() const

返回当前状态。

注: 属性状态的获取函数。

另请参阅 setStatus().

© 2025 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.