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:
parent
aa5cc61b6b
commit
9395714537
1 changed files with 6 additions and 0 deletions
|
|
@ -44,6 +44,12 @@ public:
|
||||||
|
|
||||||
TWidget::TWidget(QWidget *parent)
|
TWidget::TWidget(QWidget *parent)
|
||||||
: TWidgetHelper<QWidget>(*(new TWidgetPrivate), 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 {
|
namespace Ui {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue