2016-05-19 8 views
1

Ich möchte vsync aus dem QOpenGLContext-Format deaktivieren, um die Integration eines Drittanbieter-Rendering-System zu erleichtern.Qt 5: Vsync deaktivieren

QSurfaceFormat::swapInterval scheint der einzige verwandte Parameter in Qt zu sein.

Ich habe versucht, mehrere Möglichkeiten, dies zu implementieren, aber selbst wenn ich die QSurfaceFormat::swapInterval(0) in einem frühen Stadium (vor der QMainWindow Konstruktion), dann der QOpenGLContext::create() Aufruf stellt es wieder her.

// 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 
) 

Gibt es eine Möglichkeit Vsync zu zwingen deaktiviert sein?

+0

Hinweis: Ich habe sowohl auf Mac und Windows versucht und das gleiche Verhalten erhalten. – FabienRohrer

+0

In Verbindung stehende neue Frage: http://StackOverflow.com/Questions/37239900/qt-vsync-missing-Rende-frames – FabienRohrer

+0

Ich denke, es ist nicht einmal möglich, vsync auf Mac tatsächlich zu deaktivieren? Siehe https://code.woboq.org/qt5/qtbase/src/plugins/platforms/cocoa/qcocoaglcontext.mm.html#176, was ebenfalls abwegig zu sein scheint (das Swap-Intervall wird nicht vom GL-Kontext aktualisiert) . – peppe

Antwort

2

Wie peppe in den Kommentaren der Frage andeutet, stimmt das QSurfaceFormat-Format der QOpenGLContext-Instanz nach seiner Erstellung leider nicht mit dem tatsächlich intern verwendeten Format überein.

Das bedeutet, dass der Code, den ich implementiert habe, wahrscheinlich funktioniert, aber die zweite Debug-Anweisung zeigt falsche Werte an.

+1

Bitte öffnen Sie einen Fehlerbericht, um dies zu beheben! :( – peppe