Solved Qt3D: Synchronize with frame rate?
-
Hello,
is there a signal when Qt3D has finished rendering a frame or swaps the display buffers? What is the mechanism to synchronize animations with the actual frame rate?
Thanks in advance
-
To get a per-frame callback, include QFrameAction and add one as a component to a node in your scene.
#include <QFrameAction> #include <QEntity> ... Qt3DCore::QEntity *root; ... Qt3DLogic::QFrameAction *fa = new Qt3DLogic::QFrameAction; root->addComponent(fa); fa->connect( fa, SIGNAL(triggered(float)), &some_controller, SLOT(update()) );
And the root node's FrameAction component will trigger the single every frame. In practice, I think you can probably also get about the same effect by making a QTimer with zero timeout. After rendering a frame, the mainloop will be idle and trigger the idle timer. But it won't be guaranteed to be entirely in sync.
-
To get a per-frame callback, include QFrameAction and add one as a component to a node in your scene.
#include <QFrameAction> #include <QEntity> ... Qt3DCore::QEntity *root; ... Qt3DLogic::QFrameAction *fa = new Qt3DLogic::QFrameAction; root->addComponent(fa); fa->connect( fa, SIGNAL(triggered(float)), &some_controller, SLOT(update()) );
And the root node's FrameAction component will trigger the single every frame. In practice, I think you can probably also get about the same effect by making a QTimer with zero timeout. After rendering a frame, the mainloop will be idle and trigger the idle timer. But it won't be guaranteed to be entirely in sync.