QSGEngine Class

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

Header: #include <QSGEngine>
qmake: QT += quick
Since: Qt 5.4
Inherits: QObject.

Public Types

enum CreateTextureOption { TextureHasAlphaChannel, TextureOwnsGLTexture, TextureCanUseAtlas }
flags CreateTextureOptions

Public Functions

QSGEngine(QObject * parent = 0)
~QSGEngine()
QSGAbstractRenderer * createRenderer() const
QSGTexture * createTextureFromId(uint id, const QSize & size, CreateTextureOptions options = CreateTextureOption( 0 )) const
QSGTexture * createTextureFromImage(const QImage & image, CreateTextureOptions options = CreateTextureOption( 0 )) const
void initialize(QOpenGLContext * context)
void invalidate()
  • 31 public functions inherited from QObject

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public slot inherited from QObject
  • 2 signals inherited from QObject
  • 11 static public members inherited from QObject
  • 9 protected functions inherited from QObject

Detailed Description

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.

Note: 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().

See also QSGAbstractRenderer.

Member Type Documentation

enum QSGEngine::​CreateTextureOption
flags QSGEngine::​CreateTextureOptions

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

ConstantValueDescription
QSGEngine::TextureHasAlphaChannel0x0001The texture has an alpha channel and should be drawn using blending.
QSGEngine::TextureOwnsGLTexture0x0004The texture object owns the texture id and will delete the GL texture when the texture object is deleted.
QSGEngine::TextureCanUseAtlas0x0008The image can be uploaded into a texture atlas.

The CreateTextureOptions type is a typedef for QFlags<CreateTextureOption>. It stores an OR combination of CreateTextureOption values.

Member Function Documentation

QSGEngine::​QSGEngine(QObject * parent = 0)

Constructs a new QSGEngine with its parent

QSGEngine::​~QSGEngine()

Destroys the engine

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, CreateTextureOptions options = CreateTextureOption( 0 )) 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.

See also createTextureFromImage(), QSGSimpleTextureNode::setOwnsTexture(), and QQuickWindow::createTextureFromId().

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

Creates a texture using the data of image

Valid options are TextureCanUseAtlas

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

See also createTextureFromId(), QSGSimpleTextureNode::setOwnsTexture(), and QQuickWindow::createTextureFromImage().

void QSGEngine::​initialize(QOpenGLContext * context)

Initialize the engine with context.

Warning: You have to make sure that you call QOpenGLContext::makeCurrent() on context before calling this.

void QSGEngine::​invalidate()

Invalidate the engine releasing its resources

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

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