[Interest] QtQuick over Qt3D (Qt 5.15)

Paul Lemire paul.lemire at kdab.com
Sat Apr 3 11:35:38 CEST 2021


Hello Konstantin,

On 4/3/21 3:09 AM, Konstantin Shegunov wrote:
> On Thu, Apr 1, 2021 at 8:40 AM Paul Lemire <paul.lemire at kdab.com 
> <mailto:paul.lemire at kdab.com>> wrote:
>
>     Hello Paul,
>
> 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.
>
>     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
>     povides the 3D scene with the Scene2D texture. I think that would
>     be the easiest.
>
> Yes, that's what I've been using to "guide me through". And I do 
> acknowledge I can use it from QML, but there's also this thing: 
> https://bugreports.qt.io/browse/QTBUG-90411 
> <https://bugreports.qt.io/browse/QTBUG-90411>
Ok we will need to take a look at that. Shouldn't be too hard to fix but 
not sure how we can fixes to 5.15 publicly. Qt 3D from dev branch (Qt 6) 
does build with 5.15 though but I'm not sure we had ported Scene2D to Qt 
6 due to other changes in QtQuick.
>
>     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
>     <https://code.qt.io/cgit/qt/qt3d.git/tree/tests/manual/sharedtexture?h=5.15.2>
>
>     I hope that helps,
>
> Indeed, thanks! Still, it doesn't seem there's a way I can hook into 
> the frame graph and just have anything drawn directly on the screen, 
> is there? The best I could do, as far as I can tell, is to have an 
> ortographic camera looking at a quad, which I can texture with 
> whatever comes from the QtQuick scene, it appears (i.e. what Florian 
> Blume's code does here: 
> https://github.com/florianblume/Qt3D-BackgroundImage 
> <https://github.com/florianblume/Qt3D-BackgroundImage>). Is this correct?

Yes you will need to have a fullscreen quad mesh to draw the texture + 
matching FrameGraph part to draw only the quad  after the content of 
your 3D scene.

Many ways of doing the same thing: using the QPlaneMesh with a rotation 
+ camera or providing a custom plane mesh already in NDC space (-1  to 
1) in which case you don't even need to worry about having a camera.

>
> On Thu, Apr 1, 2021 at 11:15 AM Oleg Evseev <ev.mipt at gmail.com 
> <mailto:ev.mipt at gmail.com>> wrote:
>
>     By the way in Qt 5.14 there comes an option to use Scene3D as
>     underlay without FBO:
>     https://doc.qt.io/qt-5/qml-qtquick-scene3d-scene3d.html#compositingMode-prop
>     <https://doc.qt.io/qt-5/qml-qtquick-scene3d-scene3d.html#compositingMode-prop>
>
>     I did tried this, but encountered with a problem when using
>     together with OnDemand:
>     https://bugreports.qt.io/browse/QTBUG-82861
>     <https://bugreports.qt.io/browse/QTBUG-82861>
>
>
> Indeed. It does seem bugs reports've accumulated for Qt3D over time. 
> View3D also segfaults (the example) for some reason.
>
> Kind regards,
> Konstantin.
>
>
-- 
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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20210403/40a10d59/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4309 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20210403/40a10d59/attachment-0001.bin>


More information about the Interest mailing list