@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, 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.