diff options
author | Morten Sorvig <morten.sorvig@nokia.com> | 2011-06-27 13:17:52 +0200 |
---|---|---|
committer | Morten Sorvig <morten.sorvig@nokia.com> | 2011-06-28 12:14:12 +0200 |
commit | 0058f00b64268f87a33466646513f7a527beeecc (patch) | |
tree | c1ca050e773431489abd945d5b54692d13cc322c /src/plugins/platforms/cocoa/qcocoaglcontext.mm | |
parent | 8e8ad987a2de2766da68d5b644a12e4363e74578 (diff) |
Factor out CGL code for reuse in wayland.
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoaglcontext.mm')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoaglcontext.mm | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm index ba8bd423a2..c3ff18f980 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm @@ -2,13 +2,14 @@ #include "qcocoawindow.h" #include <qdebug.h> #include <QtCore/private/qcore_mac_p.h> +#include <QtPlatformSupport/private/cglconvenience_p.h> #import <Cocoa/Cocoa.h> QCocoaGLContext::QCocoaGLContext(const QSurfaceFormat &format, QPlatformGLContext *share) : m_format(format) { - NSOpenGLPixelFormat *pixelFormat = createNSOpenGLPixelFormat(); + NSOpenGLPixelFormat *pixelFormat = static_cast <NSOpenGLPixelFormat *>(qcgl_createNSOpenGLPixelFormat()); NSOpenGLContext *actualShare = share ? static_cast<QCocoaGLContext *>(share)->m_context : 0; m_context = [NSOpenGLContext alloc]; @@ -67,17 +68,9 @@ void QCocoaGLContext::doneCurrent() [NSOpenGLContext clearCurrentContext]; } -void (*QCocoaGLContext::getProcAddress(const QByteArray &procName)) () +void (*QCocoaGLContext::getProcAddress(const QByteArray &procName))() { - CFURLRef url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, - CFSTR("/System/Library/Frameworks/OpenGL.framework"), kCFURLPOSIXPathStyle, false); - CFBundleRef bundle = CFBundleCreate(kCFAllocatorDefault, url); - CFStringRef procNameCF = QCFString::toCFStringRef(QString::fromAscii(procName.constData())); - void *proc = CFBundleGetFunctionPointerForName(bundle, procNameCF); - CFRelease(url); - CFRelease(bundle); - CFRelease(procNameCF); - return (void (*) ())proc; + return qcgl_getProcAddress(procName); } void QCocoaGLContext::update() @@ -87,15 +80,7 @@ void QCocoaGLContext::update() NSOpenGLPixelFormat *QCocoaGLContext::createNSOpenGLPixelFormat() { - NSOpenGLPixelFormatAttribute attrs[] = - { - NSOpenGLPFADoubleBuffer, - NSOpenGLPFADepthSize, 32, - 0 - }; - - NSOpenGLPixelFormat* pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs]; - return pixelFormat; + return static_cast<NSOpenGLPixelFormat *>(qcgl_createNSOpenGLPixelFormat()); } NSOpenGLContext *QCocoaGLContext::nsOpenGLContext() const |