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.
-
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:
-
-
@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?
- 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().
- 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
, andchild
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.