vsync
をQOpenGLContext形式から無効にして、サードパーティレンダリングシステムの統合を容易にしたいとします。Qt 5:vsyncを無効にする
QSurfaceFormat::swapInterval
はQtの唯一の関連するパラメータのようです。
私はこれを実装するためにいくつかの方法を試しましたが、QSurfaceFormat::swapInterval(0)
を初期段階(QMainWindow
の構築前)に設定しても、QOpenGLContext::create()
コールがそれを復元しています。
// 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
)
VSYNCを強制する方法はあり を無効にするには?
注:MacとWindowsの両方で試してみましたが、同じ動作になります。 – FabienRohrer
関連する最近の質問:http://stackoverflow.com/questions/37239900/qt-vsync-missing-rendered-frames – FabienRohrer
私は実際にはMacでvsyncを無効にすることはできないと思いますか? https://code.woboq.org/qt5/qtbase/src/plugins/platforms/cocoa/qcocoaglcontext.mm.html#176を参照してください。これは盗聴されている可能性もあります(取得されたGLコンテキストからのスワップ間隔は更新されません) 。 – peppe