QNativeInterface::QSGOpenGLTexture Struct

提供对 OpenGL 纹理对象的访问,并使其能被采用。更多

头文件: #include <QSGTexture>
CMake: find_package(Qt6 REQUIRED COMPONENTS Quick)
target_link_libraries(mytarget PRIVATE Qt6::Quick)
qmake: QT += quick
Qt 6.0

公共函数

virtual GLuint nativeTexture() const = 0

静态公共成员

(since 6.0) QSGTexture *fromNative(GLuint textureId, QQuickWindow *window, const QSize &size, QQuickWindow::CreateTextureOptions options = {})
(since 6.1) QSGTexture *fromNativeExternalOES(GLuint textureId, QQuickWindow *window, const QSize &size, QQuickWindow::CreateTextureOptions options = {})

详细说明

成员函数文档

[static, since 6.0] QSGTexture *QSGOpenGLTexture::fromNative(GLuint textureId, QQuickWindow *window, const QSize &size, QQuickWindow::CreateTextureOptions options = {})

window 创建一个新的QSGTexture ,封装现有的 OpenGL 纹理对象。

textureId 中指定的本地对象会被生成的QSGTexture 封装,但并不被其拥有。函数的调用者负责删除返回的QSGTexture ,但这不会破坏底层的本地对象。

该函数目前仅适用于二维 RGBA 纹理。

警告: 如果场景图尚未初始化,该函数将返回空值。

使用options 可自定义纹理属性。这里只考虑了 TextureHasAlphaChannel 和 TextureHasMipmaps。

size 指定以像素为单位的大小。

注意: 此函数必须在场景图渲染线程上调用。

此函数在 Qt 6.0 中引入。

另请参阅 QQuickWindow::sceneGraphInitialized(),QSGTexture,Scene Graph - Metal Texture Import场景图 - 金属纹理导入)和Scene Graph - Vulkan Texture Import(场景图 - Vulkan 纹理导入)。

[static, since 6.1] QSGTexture *QSGOpenGLTexture::fromNativeExternalOES(GLuint textureId, QQuickWindow *window, const QSize &size, QQuickWindow::CreateTextureOptions options = {})

window 创建一个新的QSGTexture ,封装现有的 OpenGL ES 纹理对象。

textureId 中指定的本地对象会被生成的QSGTexture 封装,但不被其拥有。函数的调用者负责删除返回的QSGTexture ,但这不会破坏底层的本地对象。

该函数仅适用于与GL_TEXTURE_EXTERNAL_OES 目标一起使用的纹理:通常是其他设备(如相机)写入数据的纹理。

警告 如果场景图尚未初始化,此函数将返回空值。

使用options 可自定义纹理属性。这里只考虑了 TextureHasAlphaChannel 和 TextureHasMipmaps。

size 指定以像素为单位的大小。

注意: 此函数必须在场景图渲染线程上调用。

此函数在 Qt 6.1 中引入。

另请参阅 fromNative()。

[pure virtual] GLuint QSGOpenGLTexture::nativeTexture() const

返回 OpenGL 纹理 ID。

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