Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

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

    QML and Qt Quick
    2
    4
    1670
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      stereomatching last edited by

      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

      1 Reply Last reply Reply Quote 0
      • sletta
        sletta last edited by

        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.

        1 Reply Last reply Reply Quote 0
        • S
          stereomatching last edited by

          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"

          1 Reply Last reply Reply Quote 0
          • sletta
            sletta last edited by

            Have a look in the 5.1 qtdeclarative source tree:

            http://doc-snapshot.qt-project.org/qt5-stable/qtquick/scenegraph-textureinsgnode.html
            http://doc-snapshot.qt-project.org/qt5-stable/qtquick/scenegraph-customgeometry.html
            http://doc-snapshot.qt-project.org/qt5-stable/qtquick/scenegraph-simplematerial.html

            The "textureinsgnode" example was added for 5.1 but the others have been there since 5.0

            1 Reply Last reply Reply Quote 0
            • First post
              Last post