Closed msinamsh closed 9 months ago
I'm wondering whether this is relevant: https://doc.qt.io/qt-6/qtquick-visualcanvas-scenegraph.html#what-if-there-is-no-or-more-than-one-window-visible
When there is no renderable window, for example because our QQuickWindow is minimized (Windows) or fully obscured (macOS), we cannot present frames, thus cannot rely on the thread "working" in lockstep with the screen refresh rate. In this case, the threaded render loop automatically switches over to a system timer based approach to drive animations, i.e. temporarily switching over to the mechanism the basic loop would use.
The same is true when there are more than one QQuickWindow instances on-screen. The model presented above for advancing animations on the gui thread, enabled by its synchronization with the render thread, is not satisfactory anymore, as there are now multiple sync points with multiple render threads. (one per window.) Here falling back to the system timer based approach becomes necessary as well, because how long and often the gui thread will block is now dependent on a number of factors, including the content in the windows (are they animating? how often are they updating?) and the graphics stack behavior (how exactly does it handle two or more threads presenting with wait-for-vsync?). As we cannot guarantee being throttled to the presentation rate of the window (which window would that be, to begin with?) in a stable, cross-platform manner, advancing animations cannot be based on the rendering.
This switch of animation handling mechanisms is transparent to the applications.
Also, perhaps this? https://doc.qt.io/qt-6/qtquick-visualcanvas-scenegraph.html#driving-animations
Note: Starting from Qt 6.5, the threaded render loop offers the possibility of opting in to another animation driver, based solely on the elapsed time (QElapsedTimer). To enable this, set the QSG_USE_SIMPLE_ANIMATION_DRIVER environment variable to a non-zero value. This has the benefits of not needing any of the infrastructure for falling back to a QTimer when there are multiple windows, not needing heuristics trying determine if vsync-based throttling is missing or broken, being compatible with any kind of temporal drifts in vsync throttling, and not being tied to the primary screen's refresh rate, thus potentially working better in multi-screen setups. It also drives render thread animations (the Animator types) correctly even if vsync-based throttling is broken or disabled. On the other hand, animations may be perceived as less smooth with this approach. With compatibility in mind, it is offered as an opt-in feature at the moment.
@NielsMayer yes i think its true so what is your suggestion for this problem? and i dont use any animation i just use rendering i show you in another comment
i designed an app using scenegraph for rendering some 2d on qtquick and qml. My goal is render some 2d content on main window and another 2d content on a seprate window. I load my app from c++ with this code :
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#ifndef QNANO_USE_RHI
QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGL);
#endif
#endif
const QUrl url(u"qrc:/NoroView/Main.qml"_qs);
QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed,
&app, []() { QCoreApplication::exit(-1); },
Qt::QueuedConnection);
engine.load(url);
return app.exec();
and
QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGL);
is for set graphics api for using on scene graph and its ok. like this photo:
Everything goes fine with just one window(main window) but when i open another seprate window to render second content on it using ApplicationWindow from qml texts on the main window get unreadable and content on the second window turn into mono color(just green) and the texts will get completely unreadable as you can see in below image
and i think its because i cant use setgraphicsapi for second window that i opened from qml with ApplicationWindow
@NielsMayer please help me
This is duplicate of issue #80
hello i want to paint in 2 window in single application on qml but when i open second window painting on main window is ok but on second window dosent work i think its about QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGL); but i cant set it on second window