[Interest] QtQuick over Qt3D (Qt 5.15)

Oleg Evseev ev.mipt at gmail.com
Thu Apr 1 10:12:17 CEST 2021

By the way in Qt 5.14 there comes an option to use Scene3D as underlay
without FBO:

I did tried this, but encountered with a problem when using together with

чт, 1 апр. 2021 г. в 08:42, Paul Lemire via Interest <
interest at qt-project.org>:

> Hello,
> It sounds to me like Scene2D is what you want as it renders a QtQuick
> scene into an offscreen texture which can then be applied to a Qt 3D mesh.
> Unfortunately it can only be used from QML.
> https://code.qt.io/cgit/qt/qt3d.git/tree/examples/qt3d/scene2d
> That being said, nothing is stopping you from having 90% of the Qt3D code
> in C++ and just having a small part in QML that essentially only
> instantiates your 3D Scene and the Scene2D and provides the 3D scene with
> the Scene2D texture. I think that would be the easiest.
> If you want to do it purely in C++, another approach (but more complex to
> set up and that would have to be tested) is to use a QSharedGLTexture to
> tell Qt3D about an existing OpenGL texture by textureId. This means using
> the Qt shared OpenGL context, and manually rolling your own
> QQuickRenderControl to render QtQuick into a QOpenGLTexture, and then
> providing the QOpenGLTexture's id to the QSharedGLTexture. You'll also need
> to ensure proper synching using fences (QWaitFence/QSetFence) to ensure
> that Qt3D is not trying to render while the the shared texture is being
> updated. This would be more or less similar to one of the manual test we
> have in Qt3D
> https://code.qt.io/cgit/qt/qt3d.git/tree/tests/manual/sharedtexture?h=5.15.2
> I hope that helps,
> Paul
> On 3/29/21 12:28 PM, Konstantin Shegunov wrote:
> Hello,
> I want to overlay a QtQuick UI over a Qt3D scene I'm having, however (here
> comes the "but") I want to do it from C++. I don't want to get into
> instantiating Scene3D at all, I want to drive the Quick scene from Qt3D,
> not vice versa (i.e. I don't want to render the 3D content to an FBO, and I
> don't intend to depend on the QML engine to setup the Qt3D parts).
> Sound(ed) like a simple-enough task at first, but I'm having the worst time
> figuring it out.
> To start, I've set the Qt3D things up and I can show my mesh. For the
> second part, I read a lot of the sources around Scene3D, Scene2D and Qt3D
> examples but it doesn't appear this "obvious" thing to do is covered
> anywhere, notwithstanding half the Qt3D examples being broken (either
> segfaulting or not building at all).
> I was initially intending to get some ideas from Scene3D, but it appears
> it works directly with the private classes for one, and for two it forces
> synchronous rendering that's driven from the quick scene ... and as a
> typical QtQuick item it doesn't expose a public C++ class ...
> If I missed something there, please feel welcome to correct me.
> So after the next batch of sifting through Qt3D's own internals, the
> renderer plugin and such, I am relatively convinced the only reasonable way
> to do this is to render the UI offscreen to a texture and to just slap that
> texture on the screen on each Qt3D frame. Is this correct? If that's so,
> let's say I can render the quick scene to a texture, how do I go about
> putting it on the screen after the framegraph's been executed? I couldn't
> see a framegraph node that'd do that for me. Am I to write my own? Is it
> the case that I need to create a "fake" quad (i.e. a billboard) that I must
> reorient together with the camera? I saw in one of Florian Blume's
> repositories that he uses a second camera and another branch in the
> framegraph to put a background image in. Is this the way to do it, or is
> there some better way?
> Additional question(s):
> Do I spin my thread (which I sync manually) for rendering the quick scene?
> Thanks for any and all pointers.
> Kind regards,
> Konstantin.
> _______________________________________________
> Interest mailing listInterest at qt-project.orghttps://lists.qt-project.org/listinfo/interest
> --
> Paul Lemire | paul.lemire at kdab.com | Senior Software Engineer
> KDAB (France) S.A.S., a KDAB Group company
> Tel: France +33 (0)4 90 84 08 53, http://www.kdab.fr
> KDAB - The Qt, C++ and OpenGL Experts
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> https://lists.qt-project.org/listinfo/interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20210401/abb7c4ec/attachment.html>

More information about the Interest mailing list