本页内容

Qt3DRender::QSharedGLTexture Class

class Qt3DRender::QSharedGLTexture

允许在Qt 3D 场景中使用来自独立OpenGL上下文的textureId 。更多内容...

标题: #include <Qt3DRender/QTexture>
CMake: find_package(Qt6 REQUIRED COMPONENTS 3drender)
target_link_libraries(mytarget PRIVATE Qt6::3drender)
qmake: QT += 3drender
在 QML 中: SharedGLTexture
继承自: Qt3DRender::QAbstractTexture
状态: 已弃用

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

属性

公共函数

int textureId() const

公共槽位

void setTextureId(int id)

信号

void textureIdChanged(int textureId)

详细说明

根据Qt 3D 使用的渲染模式,共享上下文将分别为:

  • 当让Qt 3D 控制渲染时,共享上下文为qt_gl_global_share_context。在QApplication类上设置Qt::AA_ShareOpenGLContexts 属性后,这将自动使QOpenGLWidget实例的上下文与qt_gl_global_share_context共享。
  • 来自QtQuick 场景的共享上下文。您可能需要继承QWindow 或使用 QtQuickRenderControl 来控制该共享上下文的具体值,不过截至 5.13 版本,其默认值为 qt_gl_global_share_context。

任何与Qt 3D 渲染器共享上下文的第三方引擎,现在都可以提供纹理 ID,这些 ID 将被Qt 3D 的纹理引用。

您可以省略纹理属性的指定,Qt 3D 将在运行时尝试确定这些属性。如果您已知这些属性,当然也可以提供它们,从而避免Qt 3D 进行额外的工作。

请注意,如果您使用自定义材质和着色器,则需要指定要使用的正确采样器类型。

属性文档

textureId : int

您希望 Qt3D 访问的 OpenGL 纹理 ID 值。

访问函数:

int textureId() const
void setTextureId(int id)

通知器信号:

void textureIdChanged(int textureId)

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