I’m writing a 3d model viewer, so basically I want to pass my glview
to QML to use it as an element and add the rest of the UI with QML…
My current problem is that only the element which represents my glview
(a custom QDeclarativeItem with reimplemented paint() with OpenGLES
2.0 calls) is shown, the rest (2 toolbars and some more) is all black.
But when I hit the buttons on the (black) toolbar (or scroll a
listview) those elements are shown, flickering with black, as if they
were trying to get the top view but the black layer was trying to
cover them again.
I have tried changing the setViewportUpdateMode, and that doesn’t help
(I have tried all values)…unless I set it to FullViewportUpdate, in
which case the UI is always repainted and FPS goes from 36 (with the
3D model viewer and all the rest under the black layer) to 22!!
So what I’d like to accomplish is: get what is inside my custom QML
element (QDeclarativeItem) repainted (i.e. the 3D Model), without
repainting the rest of the elements of the UI (toolbars, etc) because
that is useless and eats a lot of FPS…but without painting black over
all the UI elements (as it currently does)!
can you guys help me out? :)
Here’s the setup of my app
QApplication::setGraphicsSystem("opengl");
Q_INIT_RESOURCE(common);
qmlRegisterType<modelviewer>("Test", 1, 0, "Viewer");
QScopedPointer<QApplication> app(createApplication(argc, argv));
QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create());
viewer->setResizeMode(QDeclarativeView::SizeRootObjectToView);
QGLWidget* renderer = new QGLWidget();
//if setAutoFillBackground is true I get the 3D model painted, and
the rest is all WHITE, if it is false, the 3D Model is painted, and
the rest is all BLACK
renderer->setAutoFillBackground(false);
viewer->setViewport(renderer);
viewer->setAttribute(Qt::WA_OpaquePaintEvent);
viewer->setAttribute(Qt::WA_NoSystemBackground);
viewer->viewport()->setAttribute(Qt::WA_OpaquePaintEvent);
viewer->viewport()->setAttribute(Qt::WA_NoSystemBackground);
viewer->setMainQmlFile(QLatin1String("qml/main2.qml"));
Thanks in advance to anyone who will try to help me :)
_______________________________________________
Qt-qml mailing list
Qt-...@qt.nokia.com
http://lists.qt.nokia.com/mailman/listinfo/qt-qml
I don't know much about mixing opengl rendering with graphics view rendering,
but I do know it has already been done by one project.
QtQuick3D provides QML elements that can render your 3D model without even
having to use C++! See http://doc.qt.nokia.com/qt-quick3d-snapshot/qml-
mesh.html
If QtQuick3D still doesn't do what you want, its docs will probably help you
anyway. Implementing a custom QtQuick3D Item that paints in OpenGL should be a
lot better documented than doing the same with a 2D QtQuick Item. They've
probably even considered the repainting aspects, since they also have a scene
tree like GraphicsView does.
Source (For Qt4.x, For Qt5.x see codereview.qt-project.org):
http://qt.gitorious.org/qt-labs/qt3d
The Qt3D mailing list:
http://lists.trolltech.com/mailman/listinfo/qt-3d
--
Alan Alpert
Senior Engineer
Nokia, Qt Development Frameworks
I have tried changing the setViewportUpdateMode, and that doesn’t help
(I have tried all values)…unless I set it to FullViewportUpdate, in
which case the UI is always repainted and FPS goes from 36 (with the
3D model viewer and all the rest under the black layer) to 22!!