How to change swap intervals for QGLWidget
-
I am promoting a widet in UI to QGlWidget and in the constructor of QGLWidget i am assigning swap intervals to 0.
But that does not affect the widget it still shows the value of swap interval as 1.
How can i cahnge the swap value to 0.
GLWidget::GLWidget(QWidget *parent) : QGLWidget(parent)
{
QGLFormat format;
format.setDepthBufferSize(24);
format.setStencilBufferSize(8);
format.setSampleBuffers(true);
format.setSamples(4);
format.setSwapInterval(0);
this->setFormat(format);
makeCurrent();qDebug() << "Swap Interval +++++++++++++++++++++++++++++++++++++++ " << this->format().swapInterval();
}
I am on windows platform.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
i also tried using QOpenglWidget and still was not able to change the Swap Interval , this is the code for QSurafaceFormat.int main(int argc, char *argv[]) { QSurfaceFormat format; format.setDepthBufferSize(8); format.setStencilBufferSize(8); format.setRedBufferSize(8); format.setGreenBufferSize(8); format.setBlueBufferSize(8); format.setAlphaBufferSize(8); format.setSwapInterval(0); //Turn Vsync on (1) / off (0) format.setProfile(QSurfaceFormat::CoreProfile); QSurfaceFormat::setDefaultFormat(format); //Make sure all OpenGL contexts share resources QApplication::setAttribute(Qt::AA_UseDesktopOpenGL); QApplication::setAttribute(Qt::AA_ShareOpenGLContexts); const QSurfaceFormat& surfaceFormat = QSurfaceFormat::defaultFormat(); QApplication a(argc, argv); QtWidgetsApplication2 w; w.show(); return a.exec(); }
-
Hi,
Which version of Qt are you using ?
By the way, QGLWidget is deprecated, it is advised to migrate to QOpenGLWidget. -
@SGaist Hi i am using 5.11 version , i also tried using QOpenGLWidget and changed the QSurafaceFormat swap interval to 0 but still it prints 1 as the value of swap interval.
I have updated the code when using with QOpenGLWidget.
Swap Interval just does not change and when i print the format in InitializeGL() function.
qDebug() << this->format() << " THe format";I stillGet Swap Interval as 0.
-
Can you check with a more recent version ? 5.11 is outdated.
By the way, which platform are you on ?