QSGEngine Class

The QSGEngine class allows low level rendering of a scene graph. 更多...

頭: #include <QSGEngine>
qmake: QT += quick
Since: Qt 5.4
繼承: QObject

公共類型

enum CreateTextureOption { TextureHasAlphaChannel, TextureOwnsGLTexture, TextureCanUseAtlas, TextureIsOpaque }
flags CreateTextureOptions

公共函數

QSGEngine (QObject * parent = nullptr)
virtual ~QSGEngine () override
QSGImageNode * createImageNode () const
QSGNinePatchNode * createNinePatchNode () const
QSGRectangleNode * createRectangleNode () const
QSGAbstractRenderer * createRenderer () const
QSGTexture * createTextureFromId (uint id , const QSize & size , QSGEngine::CreateTextureOptions options = CreateTextureOption()) const
QSGTexture * createTextureFromImage (const QImage & image , QSGEngine::CreateTextureOptions options = CreateTextureOption()) const
void initialize (QOpenGLContext * context )
void invalidate ()
QSGRendererInterface * rendererInterface () const

靜態公共成員

const QMetaObject staticMetaObject

額外繼承成員

詳細描述

The QSGEngine class allows low level rendering of a scene graph.

A QSGEngine can be used to render a tree of QSGNode directly on a QWindow or QOpenGLFramebufferObject without any integration with QML, QQuickWindow or QQuickItem and the convenience that they provide.

This means that you must handle event propagation, animation timing, and node lifetime yourself.

注意: This class is for very low level access to an independent scene graph. Most of the time you will instead want to subclass QQuickItem and insert your QSGNode in a normal QtQuick scene by overriding QQuickItem::updatePaintNode ().

另請參閱 QSGAbstractRenderer .

成員類型文檔編製

enum QSGEngine:: CreateTextureOption
flags QSGEngine:: CreateTextureOptions

The CreateTextureOption enums are used to customize how a texture is wrapped.

常量 描述
QSGEngine::TextureHasAlphaChannel 0x0001 The texture has an alpha channel and should be drawn using blending.
QSGEngine::TextureOwnsGLTexture 0x0004 The texture object owns the texture id and will delete the GL texture when the texture object is deleted.
QSGEngine::TextureCanUseAtlas 0x0008 The image can be uploaded into a texture atlas.
QSGEngine::TextureIsOpaque 0x0010 The texture object is opaque.

CreateTextureOptions 類型是 typedef 對於 QFlags <CreateTextureOption>. It stores an OR combination of CreateTextureOption values.

成員函數文檔編製

QSGEngine:: QSGEngine ( QObject * parent = nullptr)

構造新的 QSGEngine 采用其 parent

[override virtual] QSGEngine:: ~QSGEngine ()

Destroys the engine

QSGImageNode *QSGEngine:: createImageNode () const

創建簡單圖像節點。當場景圖形未初始化時,返迴值為 null。

這是直接構造 QSGSimpleTextureNode 的跨後端替代。

該函數在 Qt 5.8 引入。

另請參閱 QSGImageNode .

QSGNinePatchNode *QSGEngine:: createNinePatchNode () const

創建 9 個補丁節點。當場景圖形未初始化時,返迴值為 null。

該函數在 Qt 5.8 引入。

QSGRectangleNode *QSGEngine:: createRectangleNode () const

創建簡單矩形節點。當場景圖形未初始化時,返迴值為 null。

這是直接構造 QSGSimpleRectNode 的跨後端替代。

該函數在 Qt 5.8 引入。

另請參閱 QSGRectangleNode .

QSGAbstractRenderer *QSGEngine:: createRenderer () const

Returns a renderer that can be used to render a QSGNode tree

You call initialize () first with the QOpenGLContext that you want to use with this renderer. This will return a null renderer otherwise.

QSGTexture *QSGEngine:: createTextureFromId ( uint id , const QSize & size , QSGEngine::CreateTextureOptions options = CreateTextureOption()) const

Creates a texture object that wraps the GL texture id uploaded with size

Valid options are TextureHasAlphaChannel and TextureOwnsGLTexture

The caller takes ownership of the texture object and the texture should only be used with this engine.

另請參閱 createTextureFromImage (), QSGSimpleTextureNode::setOwnsTexture (),和 QQuickWindow::createTextureFromId ().

QSGTexture *QSGEngine:: createTextureFromImage (const QImage & image , QSGEngine::CreateTextureOptions options = CreateTextureOption()) const

Creates a texture using the data of image

Valid options are TextureCanUseAtlas and TextureIsOpaque .

The caller takes ownership of the texture and the texture should only be used with this engine.

另請參閱 createTextureFromId (), QSGSimpleTextureNode::setOwnsTexture (),和 QQuickWindow::createTextureFromImage ().

void QSGEngine:: initialize ( QOpenGLContext * context )

Initialize the engine with context .

警告: You have to make sure that you call QOpenGLContext::makeCurrent () 在 context before calling this.

void QSGEngine:: invalidate ()

Invalidate the engine releasing its resources

You will have to call initialize () 和 createRenderer () if you want to use it again.

QSGRendererInterface *QSGEngine:: rendererInterface () const

Returns the current renderer interface if there is one. Otherwise null is returned.

該函數在 Qt 5.8 引入。

另請參閱 QSGRenderNode and QSGRendererInterface .