QT - How to properly handle Vsync and multiple QGLWidgets

opengl, qglwidget, qt, vsync

Solution

It seems that its currently the bug from Qt 5.0 - https://bugreports.qt.io/browse/QTBUG-29073

Turning the Vsync off will solve the problem with dividing update rate between QGLWidgets, your graphics card will render to screen as fast as you tell it to or as fast as it can. But you must disable the VSync in graphics card settings. Just setting fmt.setSwapInterval(0) will do nothing.

Unfortunately another problem raises, if you are painting video that contains horizontal moves, tearing will appear.

Hopefully the Qt 5.3 shall fix this bug.

Problem

I'm using three different QGLWidgets in the same main thread, preferably rendered at 60fps but I cannot achieve more than 20fps. It seems that this is caused by Vsync as each widget probably tries to synchronize with the refresh rate independently and therefore they lock somehow. If I only use two widgets I achieve 30fps. Or if I fix the update rate of one widget to, let's say 10fps, I reach 25fps on the others (10+25+25=60). `swapInterval()` always returns 0, independent of the value I set with `setSwapInterval(int)`. Any ideas? Can I disable Vsync? Or might the problem be caused by something different?

Original source