From 7e5750101699a408356439126649e8f49010d1df Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Wed, 20 Feb 2013 14:00:52 +0100 Subject: 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 --- src/plugins/platforms/cocoa/qcocoaglcontext.mm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/plugins/platforms/cocoa/qcocoaglcontext.mm') 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 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 (qcgl_createNSOpenGLPixelFormat(format)); + NSOpenGLPixelFormat *pixelFormat = static_cast (qcgl_createNSOpenGLPixelFormat(m_format)); m_shareContext = share ? static_cast(share)->nsOpenGLContext() : nil; m_context = [NSOpenGLContext alloc]; -- cgit v1.2.3