<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- qsgengine.cpp --> <title>QSGEngine Class | Qt Quick 5.12.6</title> <link rel="stylesheet" type="text/css" href="style/offline-simple.css" /> <script type="text/javascript"> document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css"); // loading style sheet breaks anchors that were jumped to before // so force jumping to anchor again setTimeout(function() { var anchor = location.hash; // need to jump to different anchor first (e.g. none) location.hash = "#"; setTimeout(function() { location.hash = anchor; }, 0); }, 0); </script> </head> <body> <div class="header" id="qtdocheader"> <div class="main"> <div class="main-rounded"> <div class="navigationbar"> <table><tr> <td >Qt 5.12</td><td ><a href="qtquick-index.html">Qt Quick</a></td><td ><a href="qtquick-module.html">C++ Classes</a></td><td >QSGEngine</td></tr></table><table class="buildversion"><tr> <td id="buildversion" width="100%" align="right"><a href="qtquick-index.html">Qt 5.12.6 Reference Documentation</a></td> </tr></table> </div> </div> <div class="content"> <div class="line"> <div class="content mainContent"> <div class="sidebar"> <div class="toc"> <h3><a name="toc">Contents</a></h3> <ul> <li class="level1"><a href="#public-types">Public Types</a></li> <li class="level1"><a href="#public-functions">Public Functions</a></li> <li class="level1"><a href="#static-public-members">Static Public Members</a></li> <li class="level1"><a href="#details">Detailed Description</a></li> </ul> </div> <div class="sidebar-content" id="sidebar-content"></div></div> <h1 class="title">QSGEngine Class</h1> <!-- $$$QSGEngine-brief --> <p>The <a href="qsgengine.html">QSGEngine</a> class allows low level rendering of a scene graph. <a href="#details">More...</a></p> <!-- @@@QSGEngine --> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include <QSGEngine></span> </td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += quick</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Since:</td><td class="memItemRight bottomAlign"> Qt 5.4</td></tr></table></div><ul> <li><a href="qsgengine-members.html">List of all members, including inherited members</a></li> </ul> <a name="public-types"></a> <h2 id="public-types">Public Types</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qsgengine.html#CreateTextureOption-enum">CreateTextureOption</a></b> { TextureHasAlphaChannel, TextureOwnsGLTexture, TextureCanUseAtlas, TextureIsOpaque }</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> flags </td><td class="memItemRight bottomAlign"><b><a href="qsgengine.html#CreateTextureOption-enum">CreateTextureOptions</a></b></td></tr> </table></div> <a name="public-functions"></a> <h2 id="public-functions">Public Functions</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qsgengine.html#QSGEngine">QSGEngine</a></b>(QObject *<i>parent</i> = nullptr)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual </td><td class="memItemRight bottomAlign"><b><a href="qsgengine.html#dtor.QSGEngine">~QSGEngine</a></b>() override</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QSGImageNode *</td><td class="memItemRight bottomAlign"><b><a href="qsgengine.html#createImageNode">createImageNode</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QSGNinePatchNode *</td><td class="memItemRight bottomAlign"><b><a href="qsgengine.html#createNinePatchNode">createNinePatchNode</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QSGRectangleNode *</td><td class="memItemRight bottomAlign"><b><a href="qsgengine.html#createRectangleNode">createRectangleNode</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QSGAbstractRenderer *</td><td class="memItemRight bottomAlign"><b><a href="qsgengine.html#createRenderer">createRenderer</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QSGTexture *</td><td class="memItemRight bottomAlign"><b><a href="qsgengine.html#createTextureFromId">createTextureFromId</a></b>(uint <i>id</i>, const QSize &<i>size</i>, QSGEngine::CreateTextureOptions <i>options</i>) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QSGTexture *</td><td class="memItemRight bottomAlign"><b><a href="qsgengine.html#createTextureFromImage">createTextureFromImage</a></b>(const QImage &<i>image</i>, QSGEngine::CreateTextureOptions <i>options</i>) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsgengine.html#initialize">initialize</a></b>(QOpenGLContext *<i>context</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsgengine.html#invalidate">invalidate</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QSGRendererInterface *</td><td class="memItemRight bottomAlign"><b><a href="qsgengine.html#rendererInterface">rendererInterface</a></b>() const</td></tr> </table></div> <a name="static-public-members"></a> <h2 id="static-public-members">Static Public Members</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> const QMetaObject </td><td class="memItemRight bottomAlign"><b><a href="qsgengine.html#staticMetaObject-var">staticMetaObject</a></b></td></tr> </table></div> <a name="details"></a> <!-- $$$QSGEngine-description --> <div class="descr"> <h2 id="details">Detailed Description</h2> <p>The <a href="qsgengine.html">QSGEngine</a> class allows low level rendering of a scene graph.</p> <p>A <a href="qsgengine.html">QSGEngine</a> can be used to render a tree of <a href="qsgnode.html">QSGNode</a> directly on a QWindow or QOpenGLFramebufferObject without any integration with QML, <a href="qquickwindow.html">QQuickWindow</a> or <a href="qquickitem.html">QQuickItem</a> and the convenience that they provide.</p> <p>This means that you must handle event propagation, animation timing, and node lifetime yourself.</p> <p><b>Note: </b>This class is for very low level access to an independent scene graph. Most of the time you will instead want to subclass <a href="qquickitem.html">QQuickItem</a> and insert your <a href="qsgnode.html">QSGNode</a> in a normal <a href="qtquick-module.html">QtQuick</a> scene by overriding <a href="qquickitem.html#updatePaintNode">QQuickItem::updatePaintNode</a>().</p></div> <p><b>See also </b><a href="qsgabstractrenderer.html">QSGAbstractRenderer</a>.</p> <!-- @@@QSGEngine --> <div class="types"> <h2>Member Type Documentation</h2> <!-- $$$CreateTextureOption$$$TextureHasAlphaChannel$$$TextureOwnsGLTexture$$$TextureCanUseAtlas$$$TextureIsOpaque --> <h3 class="flags" id="CreateTextureOption-enum"><a name="CreateTextureOption-enum"></a>enum QSGEngine::<span class="name">CreateTextureOption</span><br/>flags QSGEngine::<span class="name">CreateTextureOptions</span></h3> <p>The CreateTextureOption enums are used to customize how a texture is wrapped.</p> <div class="table"><table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr> <tr><td class="topAlign"><code>QSGEngine::TextureHasAlphaChannel</code></td><td class="topAlign tblval"><code>0x0001</code></td><td class="topAlign">The texture has an alpha channel and should be drawn using blending.</td></tr> <tr><td class="topAlign"><code>QSGEngine::TextureOwnsGLTexture</code></td><td class="topAlign tblval"><code>0x0004</code></td><td class="topAlign">The texture object owns the texture id and will delete the GL texture when the texture object is deleted.</td></tr> <tr><td class="topAlign"><code>QSGEngine::TextureCanUseAtlas</code></td><td class="topAlign tblval"><code>0x0008</code></td><td class="topAlign">The image can be uploaded into a texture atlas.</td></tr> <tr><td class="topAlign"><code>QSGEngine::TextureIsOpaque</code></td><td class="topAlign tblval"><code>0x0010</code></td><td class="topAlign">The texture object is opaque.</td></tr> </table></div> <p>The CreateTextureOptions type is a typedef for <a href="">QFlags</a><CreateTextureOption>. It stores an OR combination of CreateTextureOption values.</p> <!-- @@@CreateTextureOption --> </div> <div class="func"> <h2>Member Function Documentation</h2> <!-- $$$QSGEngine[overload1]$$$QSGEngineQObject* --> <h3 class="fn" id="QSGEngine"><a name="QSGEngine"></a>QSGEngine::<span class="name">QSGEngine</span>(<span class="type">QObject</span> *<i>parent</i> = nullptr)</h3> <p>Constructs a new <a href="qsgengine.html">QSGEngine</a> with its <i>parent</i></p> <!-- @@@QSGEngine --> <!-- $$$~QSGEngine[overload1]$$$~QSGEngine --> <h3 class="fn" id="dtor.QSGEngine"><a name="dtor.QSGEngine"></a><code>[override virtual] </code>QSGEngine::<span class="name">~QSGEngine</span>()</h3> <p>Destroys the engine</p> <!-- @@@~QSGEngine --> <!-- $$$createImageNode[overload1]$$$createImageNode --> <h3 class="fn" id="createImageNode"><a name="createImageNode"></a><span class="type"><a href="qsgimagenode.html">QSGImageNode</a></span> *QSGEngine::<span class="name">createImageNode</span>() const</h3> <p>Creates a simple image node. When the scenegraph is not initialized, the return value is null.</p> <p>This is cross-backend alternative to constructing a QSGSimpleTextureNode directly.</p> <p>This function was introduced in Qt 5.8.</p> <p><b>See also </b><a href="qsgimagenode.html">QSGImageNode</a>.</p> <!-- @@@createImageNode --> <!-- $$$createNinePatchNode[overload1]$$$createNinePatchNode --> <h3 class="fn" id="createNinePatchNode"><a name="createNinePatchNode"></a><span class="type">QSGNinePatchNode</span> *QSGEngine::<span class="name">createNinePatchNode</span>() const</h3> <p>Creates a nine patch node. When the scenegraph is not initialized, the return value is null.</p> <p>This function was introduced in Qt 5.8.</p> <!-- @@@createNinePatchNode --> <!-- $$$createRectangleNode[overload1]$$$createRectangleNode --> <h3 class="fn" id="createRectangleNode"><a name="createRectangleNode"></a><span class="type"><a href="qsgrectanglenode.html">QSGRectangleNode</a></span> *QSGEngine::<span class="name">createRectangleNode</span>() const</h3> <p>Creates a simple rectangle node. When the scenegraph is not initialized, the return value is null.</p> <p>This is cross-backend alternative to constructing a QSGSimpleRectNode directly.</p> <p>This function was introduced in Qt 5.8.</p> <p><b>See also </b><a href="qsgrectanglenode.html">QSGRectangleNode</a>.</p> <!-- @@@createRectangleNode --> <!-- $$$createRenderer[overload1]$$$createRenderer --> <h3 class="fn" id="createRenderer"><a name="createRenderer"></a><span class="type"><a href="qsgabstractrenderer.html">QSGAbstractRenderer</a></span> *QSGEngine::<span class="name">createRenderer</span>() const</h3> <p>Returns a renderer that can be used to render a <a href="qsgnode.html">QSGNode</a> tree</p> <p>You call <a href="qsgengine.html#initialize">initialize</a>() first with the QOpenGLContext that you want to use with this renderer. This will return a null renderer otherwise.</p> <!-- @@@createRenderer --> <!-- $$$createTextureFromId[overload1]$$$createTextureFromIduintconstQSize&QSGEngine::CreateTextureOptions --> <h3 class="fn" id="createTextureFromId"><a name="createTextureFromId"></a><span class="type"><a href="qsgtexture.html">QSGTexture</a></span> *QSGEngine::<span class="name">createTextureFromId</span>(<span class="type">uint</span> <i>id</i>, const <span class="type">QSize</span> &<i>size</i>, <span class="type"><a href="qsgengine.html#CreateTextureOption-enum">QSGEngine::CreateTextureOptions</a></span> <i>options</i>) const</h3> <p>Creates a texture object that wraps the GL texture <i>id</i> uploaded with <i>size</i></p> <p>Valid <i>options</i> are <a href="qsgengine.html#CreateTextureOption-enum">TextureHasAlphaChannel</a> and <a href="qsgengine.html#CreateTextureOption-enum">TextureOwnsGLTexture</a></p> <p>The caller takes ownership of the texture object and the texture should only be used with this engine.</p> <p><b>See also </b><a href="qsgengine.html#createTextureFromImage">createTextureFromImage</a>(), <a href="qsgsimpletexturenode.html#setOwnsTexture">QSGSimpleTextureNode::setOwnsTexture</a>(), and <a href="qquickwindow.html#createTextureFromId">QQuickWindow::createTextureFromId</a>().</p> <!-- @@@createTextureFromId --> <!-- $$$createTextureFromImage[overload1]$$$createTextureFromImageconstQImage&QSGEngine::CreateTextureOptions --> <h3 class="fn" id="createTextureFromImage"><a name="createTextureFromImage"></a><span class="type"><a href="qsgtexture.html">QSGTexture</a></span> *QSGEngine::<span class="name">createTextureFromImage</span>(const <span class="type">QImage</span> &<i>image</i>, <span class="type"><a href="qsgengine.html#CreateTextureOption-enum">QSGEngine::CreateTextureOptions</a></span> <i>options</i>) const</h3> <p>Creates a texture using the data of <i>image</i></p> <p>Valid <i>options</i> are <a href="qsgengine.html#CreateTextureOption-enum">TextureCanUseAtlas</a> and <a href="qsgengine.html#CreateTextureOption-enum">TextureIsOpaque</a>.</p> <p>The caller takes ownership of the texture and the texture should only be used with this engine.</p> <p><b>See also </b><a href="qsgengine.html#createTextureFromId">createTextureFromId</a>(), <a href="qsgsimpletexturenode.html#setOwnsTexture">QSGSimpleTextureNode::setOwnsTexture</a>(), and <a href="qquickwindow.html#createTextureFromImage">QQuickWindow::createTextureFromImage</a>().</p> <!-- @@@createTextureFromImage --> <!-- $$$initialize[overload1]$$$initializeQOpenGLContext* --> <h3 class="fn" id="initialize"><a name="initialize"></a><span class="type">void</span> QSGEngine::<span class="name">initialize</span>(<span class="type">QOpenGLContext</span> *<i>context</i>)</h3> <p>Initialize the engine with <i>context</i>.</p> <p><b>Warning:</b> You have to make sure that you call QOpenGLContext::makeCurrent() on <i>context</i> before calling this.</p> <!-- @@@initialize --> <!-- $$$invalidate[overload1]$$$invalidate --> <h3 class="fn" id="invalidate"><a name="invalidate"></a><span class="type">void</span> QSGEngine::<span class="name">invalidate</span>()</h3> <p>Invalidate the engine releasing its resources</p> <p>You will have to call <a href="qsgengine.html#initialize">initialize</a>() and <a href="qsgengine.html#createRenderer">createRenderer</a>() if you want to use it again.</p> <!-- @@@invalidate --> <!-- $$$rendererInterface[overload1]$$$rendererInterface --> <h3 class="fn" id="rendererInterface"><a name="rendererInterface"></a><span class="type"><a href="qsgrendererinterface.html">QSGRendererInterface</a></span> *QSGEngine::<span class="name">rendererInterface</span>() const</h3> <p>Returns the current renderer interface if there is one. Otherwise null is returned.</p> <p>This function was introduced in Qt 5.8.</p> <p><b>See also </b><a href="qsgrendernode.html">QSGRenderNode</a> and <a href="qsgrendererinterface.html">QSGRendererInterface</a>.</p> <!-- @@@rendererInterface --> </div> </div> </div> </div> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</acronym> 2019 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners.<br/> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.<br/> 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. </p> </div> </body> </html>