I used to cap the render framerate in GLFW using the function.
glfwSwapInterval(1);
Now i am building a Opengl project in QT using the Qt opengl features.
in the main function i set the global value.
QGLFormat format;
format.setDepthBufferSize(24);
format.setStencilBufferSize(8);
format.setSampleBuffers(true);
format.setSamples(4);
format.setSwapInterval(1);
QGLFormat::setDefaultFormat(format);
This is how the Qt opengl class header looks like.
class GLWidget : public QGLWidget
{
Q_OBJECT;
public:
explicit GLWidget(QWidget *parent = 0);
void initializeGL() override;
void paintGL() override;
void resizeGL(int w, int h) override;
QTimer timer;
};
In the constructor for the class
GLWidget::GLWidget(QWidget *parent) :QGLWidget(parent)
{
connect(&timer, &QTimer::timeout, this, [&]() {
QElapsedTimer elapsedtimer;
elapsedtimer.start();
updateGL();
qDebug() << elapsedtimer.elapsed();
});
timer.setInterval(0);
timer.start();
}
But still the render loop is not synced the Qdebug values keeps varying from 8 to 16.