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 |
状态: | 已废弃 |
属性
- textureId : int
公共功能
int | textureId() const |
公共插槽
void | setTextureId(int id) |
信号
void | textureIdChanged(int textureId) |
详细说明
根据Qt 3D 所使用的渲染模式,共享上下文要么是:
- qt_gl_global_share_context 当让Qt 3D 驱动渲染时。在 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 的额外工作。
请记住,如果使用自定义材质和着色器,则需要指定正确的采样器类型。
© 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.