Avoid event loop being throttled by OpenGL

By default, Qt uses swap interval of 1 what causes the (egl|wgl|glx)SwapBuffers call to wait for vblank. Using swap interval of 0 makes the call to return immediately.
This commit is contained in:
Ilya Fedin 2023-04-08 09:54:15 +04:00 committed by John Preston
parent aa5cc61b6b
commit 9395714537

View file

@ -44,6 +44,12 @@ public:
TWidget::TWidget(QWidget *parent)
: TWidgetHelper<QWidget>(*(new TWidgetPrivate), parent, {}) {
[[maybe_unused]] static const auto Once = [] {
auto format = QSurfaceFormat::defaultFormat();
format.setSwapInterval(0);
QSurfaceFormat::setDefaultFormat(format);
return true;
}();
}
namespace Ui {