QSGEngine Class
The QSGEngine class allows low level rendering of a scene graph. 更多...
头文件: | #include <QSGEngine> |
qmake: | QT += quick |
开始支持版本: | Qt 5.4 |
基类: | QObject |
公有类型
enum | CreateTextureOption { TextureHasAlphaChannel, TextureOwnsGLTexture, TextureCanUseAtlas, TextureIsOpaque } |
flags | CreateTextureOptions |
公有函数
QSGEngine(QObject *parent = Q_NULLPTR) | |
~QSGEngine() | |
QSGImageNode * | createImageNode() const |
QSGNinePatchNode * | createNinePatchNode() const |
QSGRectangleNode * | createRectangleNode() const |
QSGAbstractRenderer * | createRenderer() const |
QSGTexture * | createTextureFromId(uint id, const QSize &size, CreateTextureOptions options = CreateTextureOption()) const |
QSGTexture * | createTextureFromImage(const QImage &image, CreateTextureOptions options = CreateTextureOption()) const |
void | initialize(QOpenGLContext *context) |
void | invalidate() |
QSGRendererInterface * | rendererInterface() const |
- 32 个公有函数继承自 QObject
其他继承的成员
- 1 个属性继承自 QObject
- 1 个公有槽函数继承自 QObject
- 2 个信号继承自 QObject
- 1 个公有变量继承自 QObject
- 10 个静态公有成员继承自 QObject
- 9 个受保护的函数继承自 QObject
- 2 个受保护的变量继承自 QObject
详细描述
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().
成员类型
enum QSGEngine::CreateTextureOption
flags QSGEngine::CreateTextureOptions
The CreateTextureOption enums are used to customize how a texture is wrapped.
Constant | Value | Description |
---|---|---|
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. |
The CreateTextureOptions type is a typedef for QFlags<CreateTextureOption>. It stores an OR combination of CreateTextureOption values.
成员函数
QSGEngine::QSGEngine(QObject *parent = Q_NULLPTR)
Constructs a new QSGEngine with its parent
QSGEngine::~QSGEngine()
Destroys the engine
QSGImageNode *QSGEngine::createImageNode() const
Creates a simple image node. When the scenegraph is not initialized, the return value is null.
This is cross-backend alternative to constructing a QSGSimpleTextureNode directly.
This function was introduced in Qt 5.8.
参见 QSGImageNode.
QSGNinePatchNode *QSGEngine::createNinePatchNode() const
Creates a nine patch node. When the scenegraph is not initialized, the return value is null.
This function was introduced in Qt 5.8.
QSGRectangleNode *QSGEngine::createRectangleNode() const
Creates a simple rectangle node. When the scenegraph is not initialized, the return value is null.
This is cross-backend alternative to constructing a QSGSimpleRectNode directly.
This function was introduced in 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, 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(), and QQuickWindow::createTextureFromId().
QSGTexture *QSGEngine::createTextureFromImage(const QImage &image, 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(), 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.
QSGRendererInterface *QSGEngine::rendererInterface() const
Returns the current renderer interface if there is one. Otherwise null is returned.
This function was introduced in Qt 5.8.
参见 QSGRenderNode and QSGRendererInterface.