QQuickFramebufferObject Class

The QQuickFramebufferObject class is a convenience class for integrating OpenGL rendering using a framebuffer object (FBO) with Qt Quick. 更多...

頭: #include <QQuickFramebufferObject>
qmake: QT += quick
Since: Qt 5.2
繼承: QQuickItem

公共類型

class Renderer

特性

公共函數

QQuickFramebufferObject (QQuickItem * parent = Q_NULLPTR)
virtual Renderer * createRenderer () const = 0
bool mirrorVertically () const
void setMirrorVertically (bool enable )
void setTextureFollowsItemSize (bool follows )
bool textureFollowsItemSize () const

重實現公共函數

virtual bool isTextureProvider () const
virtual void releaseResources ()
virtual QSGTextureProvider * textureProvider () const

信號

void mirrorVerticallyChanged ( bool )
void textureFollowsItemSizeChanged ( bool )

額外繼承成員

詳細描述

The QQuickFramebufferObject class is a convenience class for integrating OpenGL rendering using a framebuffer object (FBO) with Qt Quick.

On most platforms, the rendering will occur on a dedicated thread . For this reason, the QQuickFramebufferObject class enforces a strict separation between the item implementation and the FBO rendering. All item logic, such as properties and UI-related helper functions needed by QML should be located in a QQuickFramebufferObject class subclass. Everything that relates to rendering must be located in the QQuickFramebufferObject::Renderer 類。

To avoid race conditions and read/write issues from two threads it is important that the renderer and the item never read or write shared variables. Communication between the item and the renderer should primarily happen via the QQuickFramebufferObject::Renderer::synchronize () function. This function will be called on the render thread while the GUI thread is blocked.

Using queued connections or events for communication between item and renderer is also possible.

Both the Renderer and the FBO are memory managed internally.

To render into the FBO, the user should subclass the Renderer class and reimplement its Renderer::render () function. The Renderer subclass is returned from createRenderer ().

The size of the FBO will by default adapt to the size of the item. If a fixed size is preferred, set textureFollowsItemSize to false and return a texture of your choosing from QQuickFramebufferObject::Renderer::createFramebufferObject ().

Starting Qt 5.4, the QQuickFramebufferObject 類是 紋理提供程序 and can be used directly in ShaderEffects and other classes that consume texture providers.

另請參閱 場景圖形 - 渲染 FBO (幀緩衝對象) and 場景圖形和渲染 .

特性文檔編製

mirrorVertically : bool

This property controls if the size of the FBO's contents should be mirrored vertically when drawing. This allows easy integration of third-party rendering code that does not follow the standard expectations.

默認值為 false .

該特性在 Qt 5.6 引入。

訪問函數:

bool mirrorVertically () const
void setMirrorVertically (bool enable )

通知程序信號:

void mirrorVerticallyChanged ( bool )

textureFollowsItemSize : bool

This property controls if the size of the FBO's texture should follow the dimensions of the QQuickFramebufferObject item. When this property is false, the FBO will be created once the first time it is displayed. If it is set to true, the FBO will be recreated every time the dimensions of the item change.

默認值為 true .

訪問函數:

bool textureFollowsItemSize () const
void setTextureFollowsItemSize (bool follows )

通知程序信號:

void textureFollowsItemSizeChanged ( bool )

成員函數文檔編製

QQuickFramebufferObject:: QQuickFramebufferObject ( QQuickItem * parent = Q_NULLPTR)

構造新的 QQuickFramebufferObject 采用父級 parent .

[pure virtual] Renderer *QQuickFramebufferObject:: createRenderer () const

Reimplement this function to create a renderer used to render into the FBO.

This function will be called on the rendering thread while the GUI thread is blocked.

[虛擬] bool QQuickFramebufferObject:: isTextureProvider () const

重實現自 QQuickItem::isTextureProvider ().

[虛擬] void QQuickFramebufferObject:: releaseResources ()

重實現自 QQuickItem::releaseResources ().

[虛擬] QSGTextureProvider *QQuickFramebufferObject:: textureProvider () const

重實現自 QQuickItem::textureProvider ().