Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. vsync and QOpenGLContext
Forum Updated to NodeBB v4.3 + New Features

vsync and QOpenGLContext

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 1.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    PysCowboy
    wrote on last edited by
    #1

    I would like to disable vsync from the QOpenGLContext format in order to facilitate the integration of a third party rendering system.

    QSurfaceFormat::swapInterval seems to be the only related parameter in Qt.

    I tried several ways to implement this on Mac and Windows, but even if I set the QSurfaceFormat::swapInterval(0) at an early stage (before the QMainWindow construction), then the QOpenGLContext::create() call is restoring it.

    // at application startup, before creating the Qt windows (or in MyQWindow constructor)
    QSurfaceFormat format;
    format.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
    format.setRedBufferSize(8);
    format.setGreenBufferSize(8);
    format.setBlueBufferSize(8);
    format.setAlphaBufferSize(8);
    format.setDepthBufferSize(24);
    format.setStencilBufferSize(8);
    format.setSwapInterval(0);
    QSurfaceFormat::setDefaultFormat(format);
    
    QMainWindow *w = new QMainWindow;
    w->show();
    

    .

    // at QWindow with QOpenGLContext creation, at the first frame update (or at the constructor)
    MyQWindow::initialization() {
        WbOpenGLContext *c = new WbOpenGLContext(this);
        c->setFormat(requestedFormat());
        qDebug() << "requested format:" << c->format();
        c->create();
        qDebug() << "actual format:" << c->format();
    }
    

    .

    # output
    requested format: QSurfaceFormat(
        version 2.0,
        options QFlags(),
        depthBufferSize 24,
        redBufferSize 8,
        greenBufferSize 8,
        blueBufferSize 8,
        alphaBufferSize 8,
        stencilBufferSize 8,
        samples -1,
        swapBehavior 2,
        swapInterval 0,
        profile 0
    )
    context format: QSurfaceFormat(
        version 3.0,
        options QFlags(0x4),
        depthBufferSize 24,
        redBufferSize 8,
        greenBufferSize 8,
        blueBufferSize 8,
        alphaBufferSize 8,
        stencilBufferSize 8,
        samples 0,
        swapBehavior 2,
        swapInterval 1, # Not what I asked
        profile 0
    )
    

    Is there a way to force vsync to be disabled?

    1 Reply Last reply
    0
    • P Offline
      P Offline
      PysCowboy
      wrote on last edited by
      #2

      I asked the question on stackoverflow too:
      http://stackoverflow.com/questions/37319328/qt-5-disable-vsync/37327654?noredirect=1#comment62180852_37327654

      It seems that the second debug statement can not work because the WbOpenGLContext::format is not updated in the WbOpenGLContext::create() function.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved