QQuickFramebufferObject Class
QQuickFramebufferObjectクラスは、フレームバッファオブジェクト(FBO)を使用したOpenGLレンダリングをQt Quick に統合するための便利なクラスです。詳細...
ヘッダー | #include <QQuickFramebufferObject> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Quick) target_link_libraries(mytarget PRIVATE Qt6::Quick) |
qmake: | QT += quick |
継承: | QQuickItem |
パブリックな型
class | Renderer |
プロパティ
- mirrorVertically : bool
- textureFollowsItemSize : bool
パブリック関数
QQuickFramebufferObject(QQuickItem *parent = nullptr) | |
virtual QQuickFramebufferObject::Renderer * | createRenderer() const = 0 |
bool | mirrorVertically() const |
void | setMirrorVertically(bool enable) |
void | setTextureFollowsItemSize(bool follows) |
bool | textureFollowsItemSize() const |
再実装パブリック関数
virtual bool | isTextureProvider() const override |
virtual void | releaseResources() override |
virtual QSGTextureProvider * | textureProvider() const override |
シグナル
void | mirrorVerticallyChanged(bool) |
void | textureFollowsItemSizeChanged(bool) |
詳細説明
警告 このクラスは、Qt Quick が OpenGL 経由でレンダリングしているときのみ機能します。VulkanやMetalのような他のグラフィックスAPIとは互換性がありません。このクラスは、Qt 5 アプリケーションが OpenGL と連携している限り、ソースの互換性を壊すことなく機能させるために存在するレガシークラスとして扱われるべきです。
ほとんどのプラットフォームでは、レンダリングは専用のスレッドで行われます。このため、QQuickFramebufferObject クラスでは、アイテムの実装と FBO のレンダリングを厳密に分離しています。QMLが必要とするプロパティやUI関連ヘルパー関数などのアイテムロジックは、すべてQQuickFramebufferObjectクラスのサブクラスに置く必要があります。レンダリングに関連するものはすべて、QQuickFramebufferObject::Renderer クラスに配置する必要があります。
レースコンディションや2つのスレッドからの読み書きの問題を避けるために、レンダラーとアイテムは決して共有変数を読み書きしないことが重要です。アイテムとレンダラー間の通信は、主にQQuickFramebufferObject::Renderer::synchronize() 関数を介して行われる必要があります。この関数は、GUI スレッドがブロックされている間にレンダリング スレッドで呼び出されます。
アイテムとレンダラー間の通信にキュー接続またはイベントを使用することも可能です。
レンダラーと FBO は両方とも内部でメモリ管理されます。
FBO にレンダリングするには、ユーザーは Renderer クラスをサブクラス化し、そのRenderer::render() 関数を再実装する必要があります。Rendererのサブクラスは、createRenderer ()から返されます。
FBOのサイズは、デフォルトではアイテムのサイズに適応します。サイズを固定したい場合は、textureFollowsItemSize をfalse
に設定し、QQuickFramebufferObject::Renderer::createFramebufferObject() から任意のテクスチャを返します。
Qt 5.4から、QQuickFramebufferObjectクラスはtexture provider 、ShaderEffects 、テクスチャ・プロバイダを消費する他のクラスで直接使用できます。
シーングラフとレンダリングも参照してください 。
プロパティ・ドキュメント
mirrorVertically : bool
このプロパティは、描画時にFBOのコンテンツのサイズを垂直方向にミラーリングするかどうかを制御する。これにより、標準の期待値に従わないサードパーティのレンダリングコードを簡単に統合することができます。
デフォルト値はfalse
です。
アクセス関数:
bool | mirrorVertically() const |
void | setMirrorVertically(bool enable) |
通知シグナル:
void | mirrorVerticallyChanged(bool) |
textureFollowsItemSize : bool
このプロパティは、FBO のテクスチャのサイズをQQuickFramebufferObject アイテムの寸法に合わせるかどうかを制御します。このプロパティを false に設定すると、FBO は最初に表示されるときに 1 回だけ作成されます。このプロパティを true に設定すると、アイテムの寸法が変更されるたびに FBO が再作成されます。
デフォルト値はtrue
です。
アクセス機能:
bool | textureFollowsItemSize() const |
void | setTextureFollowsItemSize(bool follows) |
Notifier シグナル:
void | textureFollowsItemSizeChanged(bool) |
メンバ関数ドキュメント
QQuickFramebufferObject::QQuickFramebufferObject(QQuickItem *parent = nullptr)
親を持つ新しい QQuickFramebufferObject をparent で構築します。
[pure virtual]
QQuickFramebufferObject::Renderer *QQuickFramebufferObject::createRenderer() const
この関数を再実装して、FBOへのレンダリングに使用するレンダラーを作成します。
この関数は、GUIスレッドがブロックされている間にレンダリングスレッドで呼び出されます。
[override virtual]
bool QQuickFramebufferObject::isTextureProvider() const
再実装:QQuickItem::isTextureProvider() const.
[override virtual]
void QQuickFramebufferObject::releaseResources()
再インプリメント:QQuickItem::releaseResources().
[override virtual]
QSGTextureProvider *QQuickFramebufferObject::textureProvider() const
再実装:QQuickItem::textureProvider() const.
© 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.