Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. OpenGL Under QML using with other element turn out with some strange behavior
Forum Update on Monday, May 27th 2025

OpenGL Under QML using with other element turn out with some strange behavior

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 223 Views
  • 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.
  • W Offline
    W Offline
    Waisting
    wrote on 3 Dec 2023, 04:13 last edited by
    #1

    I am using the OpenGL under QML example to develop a 3D viewer element mixing OpenSceneGraph rendering. There are some strange behaviors the example Squircle element turns out.

    1. when I embed the Squircle into a Rectangle element (or any other element) it will not act as the child element but like a background root element.
      code:
      Rectangle{
      width: 400
      height: parent.height
      color: "green"

           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
               }
           }
       }
      

    d1c-da53-4963-b585-c776f4f50248-image.png](https://ddgobkiprc33d.cloudfront.net/85b76dac-d3f6-48f0-a1fa-dff085923fbc.png)
    2. when I mixed the openscenegraph frame() function into the SquircleRenderer::paint on the signal of QuickWindow::beforeRenderPassRecording the new element will cover the original Text element which is a child of the elemnet.
    code:
    void SquircleRenderer::paint()
    {
    m_window->beginExternalCommands();
    m_osgViewer->frame();
    m_window->endExternalCommands();
    }
    out:
    b5774657-ac11-4304-a80a-db417b318b82-image.png

    J 1 Reply Last reply 3 Dec 2023, 08:41
    0
    • W Waisting
      3 Dec 2023, 04:13

      I am using the OpenGL under QML example to develop a 3D viewer element mixing OpenSceneGraph rendering. There are some strange behaviors the example Squircle element turns out.

      1. when I embed the Squircle into a Rectangle element (or any other element) it will not act as the child element but like a background root element.
        code:
        Rectangle{
        width: 400
        height: parent.height
        color: "green"

             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
                 }
             }
         }
        

      d1c-da53-4963-b585-c776f4f50248-image.png](https://ddgobkiprc33d.cloudfront.net/85b76dac-d3f6-48f0-a1fa-dff085923fbc.png)
      2. when I mixed the openscenegraph frame() function into the SquircleRenderer::paint on the signal of QuickWindow::beforeRenderPassRecording the new element will cover the original Text element which is a child of the elemnet.
      code:
      void SquircleRenderer::paint()
      {
      m_window->beginExternalCommands();
      m_osgViewer->frame();
      m_window->endExternalCommands();
      }
      out:
      b5774657-ac11-4304-a80a-db417b318b82-image.png

      J Offline
      J Offline
      jeremy_k
      wrote on 3 Dec 2023, 08:41 last edited by jeremy_k 12 Mar 2023, 08:42
      #2

      @Waisting said in OpenGL Under QML using with other element turn out with some strange behavior:

      I am using the OpenGL under QML example to develop a 3D viewer element mixing OpenSceneGraph rendering. There are some strange behaviors the example Squircle element turns out.

      Is this the example?

      1. when I embed the Squircle into a Rectangle element (or any other element) it will not act as the child element but like a background root element.

      That sounds like the expected behavior. From the link above:
      The OpenGL under QML example shows how an application can make use of the QQuickWindow::beforeRendering() signal to draw custom OpenGL content under a Qt Quick scene. This signal is emitted at the start of every frame, before the scene graph starts its rendering, thus any OpenGL draw calls that are made as a response to this signal, will stack under the Qt Quick items.

      If the goal is something that renders over the scene, look at the QQuickWindow::afterRender* signals instead of beforeRender*.

      While not mentioned in the text, the code for Squircle::sync() and SquircleRenderer::paint() demonstrate using the window rather than the QObject or QQuickItem parent to size the Squircle. This can be changed by altering the calls to SquircleRenderer::setViewportSize() and glViewport().

      1. when I mixed the openscenegraph frame() function into the SquircleRenderer::paint on the signal of QuickWindow::beforeRenderPassRecording the new element will cover the original Text element which is a child of the elemnet.

      I don't understand how the new element, original Text, and child are oriented. QML code would make it easier to follow.

      With no familiarity of OpenSceneGraph, I won't speculate other than to say that the image looks like a failure to save or restore state.

      Asking a question about code? http://eel.is/iso-c++/testcase/

      1 Reply Last reply
      0

      1/2

      3 Dec 2023, 04:13

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved