'Enablin vsync in qt
I'm making an application in c++ and Qt. I'd like to know if the settings below are enough to have vsync enabled automatically by Windows for qt application.
evel1::Level1()
{
this->setSceneRect(sceneRect);
m_view = new QGraphicsView();
QOpenGLWidget *gl = new QOpenGLWidget();
QSurfaceFormat format;
format.setProfile(QSurfaceFormat::CompatibilityProfile);
format.setOptions(QSurfaceFormat::DeprecatedFunctions);
format.setDepthBufferSize(24);
format.setStencilBufferSize(8);
format.setVersion(3, 2);
format.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
format.setSwapInterval(1);
gl->setFormat(format);
QSurfaceFormat::setDefaultFormat(format);
m_view->setViewport(gl);
m_view->setScene(this);
m_view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_view->setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "game"));
m_view->resize(800, 600);
m_view->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
m_view->setViewportUpdateMode(QGraphicsView::NoViewportUpdate );
m_view->setCacheMode(QGraphicsView::CacheBackground);
m_view->updateGeometry();
painter = new QPainter();
m_view->setSceneRect(0,0,10000000,10000000);
m_view->setBackgroundBrush(Qt::black);
m_view->show();
m_view->showFullScreen();
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|