summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2013-02-20 14:00:52 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-02-23 01:34:06 +0100
commit7e5750101699a408356439126649e8f49010d1df (patch)
treefdf33055383a5b2e967bfe5b55c0ee8843fecdba /src/plugins/platforms/cocoa
parent3b5600f6ee9f2982c5a93250e577f87a34fe32d1 (diff)
Enforce OpenGL context creation under Cocoa
We don't support other context types, so fail in those cases. Also, return OpenGL as the rendereable type of our surface. Change-Id: I3d5632eb8555d73ed14837b662c7450589a8681f Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
Diffstat (limited to 'src/plugins/platforms/cocoa')
-rw-r--r--src/plugins/platforms/cocoa/qcocoaglcontext.mm12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
index d0f5a58e22..6c2fdf5470 100644
--- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm
+++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
@@ -49,11 +49,19 @@
#import <Cocoa/Cocoa.h>
QCocoaGLContext::QCocoaGLContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share)
- : m_format(format)
+ : m_context(nil),
+ m_shareContext(nil),
+ m_format(format)
{
+ // we only support OpenGL contexts under Cocoa
+ if (m_format.renderableType() == QSurfaceFormat::DefaultRenderableType)
+ m_format.setRenderableType(QSurfaceFormat::OpenGL);
+ if (m_format.renderableType() != QSurfaceFormat::OpenGL)
+ return;
+
QCocoaAutoReleasePool pool; // For the SG Canvas render thread
- NSOpenGLPixelFormat *pixelFormat = static_cast <NSOpenGLPixelFormat *>(qcgl_createNSOpenGLPixelFormat(format));
+ NSOpenGLPixelFormat *pixelFormat = static_cast <NSOpenGLPixelFormat *>(qcgl_createNSOpenGLPixelFormat(m_format));
m_shareContext = share ? static_cast<QCocoaGLContext *>(share)->nsOpenGLContext() : nil;
m_context = [NSOpenGLContext alloc];