1

Qt5 allows to use QSurfaceFormat::setSwapInterval which lets the application to decide whether to enable VSync or not. However, this can only be done when the application is started, e.g. to disable VSync it's sufficient to call the following before the application object is created:

QSurfaceFormat format;
format.setSwapInterval(0);
QSurfaceFormat::setDefaultFormat(format);

The code above will disable VSync in a Qt Quick application by setting the swap interval to zero in the Opengl context used by the Qt Scenegraph. However, what I would like is the possibility to disable and enable VSync at runtime whenever required (not just before the start of the QML engine), something like this:

void toggleVSync(){...}

Looking around I didn't really find anything, so I was wondering if there was a way to achieve this.

reckless
  • 741
  • 12
  • 53

1 Answers1

0

Grab the functions to the platform dependent swap control extension functions yourself, call to your taste:

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
datenwolf
  • 159,371
  • 13
  • 185
  • 298
  • Ok so I gave this a go (see code [here](https://controlc.com/cd70c022)) on Linux X11, but the it seems `GLX_SWAP_INTERVAL_EXT` always seems to return 0 when queried. I am calling my code inside a `QQuickFramebufferObject`. – reckless Aug 18 '20 at 18:37