Cocoa: Add support for triple-buffered GL contexts
As usual, the requested format may not be available, so clients should check the actual format to confirm triple-buffering. Change-Id: Icf073cc9ddf2c912eb5c3ce0ac80d1694d1c56d7 Reviewed-by: Jake Petroules <jake.petroules@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
parent
e52fcb7dc7
commit
dcfb814498
@ -81,8 +81,11 @@ void *qcgl_createNSOpenGLPixelFormat(const QSurfaceFormat &format)
|
||||
|
||||
QVector<NSOpenGLPixelFormatAttribute> attrs;
|
||||
|
||||
if (format.swapBehavior() != QSurfaceFormat::SingleBuffer)
|
||||
if (format.swapBehavior() == QSurfaceFormat::DoubleBuffer
|
||||
|| format.swapBehavior() == QSurfaceFormat::DefaultSwapBehavior)
|
||||
attrs.append(NSOpenGLPFADoubleBuffer);
|
||||
else if (format.swapBehavior() == QSurfaceFormat::TripleBuffer)
|
||||
attrs.append(NSOpenGLPFATripleBuffer);
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
||||
if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
|
||||
|
@ -305,8 +305,16 @@ void QCocoaGLContext::updateSurfaceFormat()
|
||||
m_format.setSamples(samples);
|
||||
|
||||
int doubleBuffered = -1;
|
||||
int tripleBuffered = -1;
|
||||
[pixelFormat getValues:&doubleBuffered forAttribute:NSOpenGLPFADoubleBuffer forVirtualScreen:0];
|
||||
m_format.setSwapBehavior(doubleBuffered == 1 ? QSurfaceFormat::DoubleBuffer : QSurfaceFormat::SingleBuffer);
|
||||
[pixelFormat getValues:&tripleBuffered forAttribute:NSOpenGLPFATripleBuffer forVirtualScreen:0];
|
||||
|
||||
if (tripleBuffered == 1)
|
||||
m_format.setSwapBehavior(QSurfaceFormat::TripleBuffer);
|
||||
else if (doubleBuffered == 1)
|
||||
m_format.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
|
||||
else
|
||||
m_format.setSwapBehavior(QSurfaceFormat::SingleBuffer);
|
||||
|
||||
int steroBuffers = -1;
|
||||
[pixelFormat getValues:&steroBuffers forAttribute:NSOpenGLPFAStereo forVirtualScreen:0];
|
||||
|
Loading…
x
Reference in New Issue
Block a user