qt next | 30 Dec 17:48 2010
Picon

QML on top of QT3D View

Hi,


I have an application using opengl/Qt3D. I wants to add a user interface on top (accessible with mouse) made in QML. It seems that it's possible (seems quite similar to graphicsView example) but I am a little bit lost :
When I watch graphicsView example it seems that the main windows is a qgraphicsView :

1)- Is there no easy way to simply to paint a qdeclarativeItem in an opengl fbo, the simply draw a textured quad ?

2)- My 3D View need to display with maximum performance (smooth) the 3D View, If I need to use instead of the QGlView does it implies overhead and performance penalty : at least it's ok to haver performance penalty when displaying OSD overlay interface but when I hide the interface I need to have maximum perfomance (in particular I plan to port the application to a low end ARM powerXR board) 


_______________________________________________
Qt-3d mailing list
Qt-3d@...
http://lists.qt.nokia.com/mailman/listinfo/qt-3d
rhys.weatherley | 30 Dec 21:25 2010
Picon

Re: QML on top of QT3D View

2D and 3D can be mixed if both are QML - see stereo.qml for an example.  If your 3D parts are written in C++, then
you can create a custom item that inherits from QDeclarativeItem3D and override the draw() method to do
whatever you'd like (the Sphere item does this - you can use it as a template).  Then use qmlviewer to run the
application, or embed a QDeclarativeView with a QGLWidget viewport.  Performance-wise the main
overhead is when switching from 2D drawing to 3D and back again - everything in the 3D "Viewport" is drawn as
a single block.  We're working on the performance of QML, replacing QGraphicsView with a different
approach in the future.  This should be mostly invisible if you build your application in QML and keep
custom C++ elements to a minimum.

Cheers,

Rhys.
________________________________________
From: qt-3d-bounces+rhys.weatherley=nokia.com@...
[qt-3d-bounces+rhys.weatherley=nokia.com@...] On Behalf
Of ext qt next [qtnext@...]
Sent: Friday, December 31, 2010 2:48 AM
To: Qt-3d@...
Subject: [Qt-3d] QML on top of QT3D View

Hi,

I have an application using opengl/Qt3D. I wants to add a user interface on top (accessible with mouse) made
in QML. It seems that it's possible (seems quite similar to graphicsView example) but I am a little bit lost :
When I watch graphicsView example it seems that the main windows is a qgraphicsView :

1)- Is there no easy way to simply to paint a qdeclarativeItem in an opengl fbo, the simply draw a textured
quad ?

2)- My 3D View need to display with maximum performance (smooth) the 3D View, If I need to use instead of the
QGlView does it implies overhead and performance penalty : at least it's ok to haver performance penalty
when displaying OSD overlay interface but when I hide the interface I need to have maximum perfomance (in
particular I plan to port the application to a low end ARM powerXR board)
qt next | 30 Dec 21:44 2010
Picon

Re: QML on top of QT3D View

Hi,


thanks for your answer. In fact I have I have no qt3D qml I have a full opengl Qt3D C++ application and It wants to add as overlay when needs (for the setup only) a qml interface.

-  I don't understand why there is overhead when switching from 2D drawing to 3D : If  I have an opengl view to render qml, I was thinking there was no overhead to switch from 2D to 3D, just rendering the 2D qml in an fbo then just draw the texture ?

- for me the approach you propose seems at the reverse of logic : The main application is the 3D View with C++ opengl, and I need to have a QDeclarativeView as main container for all the application, and I need to embed the 3D in the Declarative View : it's not possible to do the reverse, so when I hide the QML interface I have no overhead at all ?

 

2010/12/30 <rhys.weatherley-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
2D and 3D can be mixed if both are QML - see stereo.qml for an example.  If your 3D parts are written in C++, then you can create a custom item that inherits from QDeclarativeItem3D and override the draw() method to do whatever you'd like (the Sphere item does this - you can use it as a template).  Then use qmlviewer to run the application, or embed a QDeclarativeView with a QGLWidget viewport.  Performance-wise the main overhead is when switching from 2D drawing to 3D and back again - everything in the 3D "Viewport" is drawn as a single block.  We're working on the performance of QML, replacing QGraphicsView with a different approach in the future.  This should be mostly invisible if you build your application in QML and keep custom C++ elements to a minimum.

Cheers,

Rhys.
________________________________________
From: qt-3d-bounces+rhys.weatherley=nokia.com <at> qt.nokia.com [qt-3d-bounces+rhys.weatherley=nokia.com <at> qt.nokia.com] On Behalf Of ext qt next [qtnext-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org]
Sent: Friday, December 31, 2010 2:48 AM
To: Qt-3d-j2+ES3AKPrdWk0Htik3J/w@public.gmane.org
Subject: [Qt-3d] QML on top of QT3D View

Hi,

I have an application using opengl/Qt3D. I wants to add a user interface on top (accessible with mouse) made in QML. It seems that it's possible (seems quite similar to graphicsView example) but I am a little bit lost :
When I watch graphicsView example it seems that the main windows is a qgraphicsView :

1)- Is there no easy way to simply to paint a qdeclarativeItem in an opengl fbo, the simply draw a textured quad ?

2)- My 3D View need to display with maximum performance (smooth) the 3D View, If I need to use instead of the QGlView does it implies overhead and performance penalty : at least it's ok to haver performance penalty when displaying OSD overlay interface but when I hide the interface I need to have maximum perfomance (in particular I plan to port the application to a low end ARM powerXR board)



_______________________________________________
Qt-3d mailing list
Qt-3d@...
http://lists.qt.nokia.com/mailman/listinfo/qt-3d
rhys.weatherley | 30 Dec 23:11 2010
Picon

Re: QML on top of QT3D View

>thanks for your answer. In fact I have I have no qt3D qml I have a full opengl Qt3D C++ application and It wants
to add as overlay when needs (for the setup only) a qml interface.
>
>-  I don't understand why there is overhead when switching from 2D drawing to 3D : If  I have an opengl view to
render qml, I was thinking there was no overhead to switch from 2D to 3D, just rendering the 2D qml in an fbo
then just draw the texture ?

Switching to an fbo for rendering has an overhead, and the GL state in the QGLContext needs to be switched
from the requirements for 3D to 2D and back again.  That's a lot of state changes.  Have a look at the
beginNativePainting() function in the GL2 paint engine for an example of what happens during the switch.

>- for me the approach you propose seems at the reverse of logic : The main application is the 3D View with C++
opengl, and I need to have a QDeclarativeView as main container for all the application, and I need to embed
the 3D in the Declarative View : it's not possible to do the reverse, so when I hide the QML interface I have no
overhead at all ?

The main application shell (menus, toolbars, whatever) can be in C++, with a QDeclarativeView embedded
where you want the QML and 3D elements to appear.  I suppose you could switch out the QDeclarativeView with a
regular QGLView/QGLWidget when you hide the QML interface.  But the resultant screen flashing to repaint
that area when the widget is switched probably won't be very good.

Rendering QML into an fbo isn't impossible - we ourselves are working on it for putting QML/2D scenes on the
side of QML/3D objects.  I don't have a firm ETA for when that will happen.  But it isn't just an issue of
drawing into an fbo.  You also need to arrange for mouse and keyboard events to be delivered properly to the
embedded scene so that the QML controls will work.  This is not trivial, which is partly why it is taking us so
long in QML/3D.  There is a huge legacy of inflexible design in QGraphicsView to work around.  It really only
works if you go "all QML" or "all C++" at the moment.  Sorry.

Cheers,

Rhys.

Gmane