[Solved]Question about the example "Scene Graph - OpenGL Under QML"

  • How could I apply the effect on a specific component?

    //! [1]
    import QtQuick 2.0
    import OpenGLUnderQML 1.0

    Item {

    width: 320
    height: 480

    //! [1] //! [2]
    Rectangle {
    color: Qt.rgba(1, 1, 1, 0.7)
    radius: 10
    border.width: 1
    border.color: "white"
    anchors.fill: label
    anchors.margins: -10

       //apply the Squircle effect on the Rectangle rather than the root item 
       Squircle {
            SequentialAnimation on t {
                NumberAnimation { to: 1; duration: 2500; easing.type: Easing.InQuad }
                NumberAnimation { to: 0; duration: 2500; easing.type: Easing.OutQuad }
                loops: Animation.Infinite
                running: true
    Text {
        id: label
        color: "black"
        wrapMode: Text.WordWrap
        text: "The background here is a squircle rendered with raw OpenGL using the 'beforeRender()' signal in QQuickWindow. This text label and its border is rendered using QML"
        anchors.right: parent.right
        anchors.left: parent.left
        anchors.bottom: parent.bottom
        anchors.margins: 20

    //! [2]

    No matter how I try, it is always render on the background but not the Rectangle

  • As the documentation and the description states, the Squircle is not a part of the items rendered by the scene graph. It is using raw OpenGL combined with the QQuickWindow::beforeRendering() signal. It renders itself beneath the entire Qt Quick scene.

    If you want to integrate raw GL inside the item scene, have a look at the textureinsgnode example (for integrating raw OpenGL calls using and FBO and a texture) or customgeometry and simplematerial example (for how to create a custom scenegraph node and material.

  • bq. textureinsgnode example, customgeometry, simplematerial

    Can't find any example when I input those names in the example
    page of QtCreator, are you sure the names are correct?

    but I do found other interesting examples which may solve my problem
    "Scene Graph-Rendering"

Log in to reply