Propagate swap interval from QOpenGLWidget to the tlw
Otherwise it is impossible to set a swap interval different than the one set by QSurfaceFormat::setDefaultFormat(). Both windows and xcb will pick up the updated interval from the window on the next frame. Change-Id: I55a59f83a62d3adcea687adf28639646b576ed58 Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
This commit is contained in:
parent
40d59496fb
commit
add7c0aadd
@ -587,7 +587,8 @@ void QOpenGLWidgetPrivate::initialize()
|
||||
|
||||
// Get our toplevel's context with which we will share in order to make the
|
||||
// texture usable by the underlying window's backingstore.
|
||||
QOpenGLContext *shareContext = get(q->window())->shareContext();
|
||||
QWidget *tlw = q->window();
|
||||
QOpenGLContext *shareContext = get(tlw)->shareContext();
|
||||
if (!shareContext) {
|
||||
qWarning("QOpenGLWidget: Cannot be used without a context shared with the toplevel.");
|
||||
return;
|
||||
@ -601,6 +602,19 @@ void QOpenGLWidgetPrivate::initialize()
|
||||
return;
|
||||
}
|
||||
|
||||
// Propagate settings that make sense only for the tlw.
|
||||
QSurfaceFormat tlwFormat = tlw->windowHandle()->format();
|
||||
if (requestedFormat.swapInterval() != tlwFormat.swapInterval()) {
|
||||
// Most platforms will pick up the changed swap interval on the next
|
||||
// makeCurrent or swapBuffers.
|
||||
tlwFormat.setSwapInterval(requestedFormat.swapInterval());
|
||||
tlw->windowHandle()->setFormat(tlwFormat);
|
||||
}
|
||||
if (requestedFormat.swapBehavior() != tlwFormat.swapBehavior()) {
|
||||
tlwFormat.setSwapBehavior(requestedFormat.swapBehavior());
|
||||
tlw->windowHandle()->setFormat(tlwFormat);
|
||||
}
|
||||
|
||||
// The top-level window's surface is not good enough since it causes way too
|
||||
// much trouble with regards to the QSurfaceFormat for example. So just like
|
||||
// in QQuickWidget, use a dedicated QOffscreenSurface.
|
||||
|
Loading…
Reference in New Issue
Block a user