diff options
author | Morten Sorvig <morten.sorvig@nokia.com> | 2011-05-18 12:09:17 +0200 |
---|---|---|
committer | Morten Sorvig <morten.sorvig@nokia.com> | 2011-05-18 12:09:17 +0200 |
commit | 864815ef2efbc3b5dca2a645c1b63f9bb67285d0 (patch) | |
tree | ae2c208919d2f0ff5c9fadadce009170bee46ad5 /src/plugins/platforms/cocoa/qcocoaglcontext.mm | |
parent | 516f4e283ba4626d7239630397ef867ab0366071 (diff) |
Port Qt 5 to Mac.
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoaglcontext.mm')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoaglcontext.mm | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm new file mode 100644 index 0000000000..505be4a9de --- /dev/null +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm @@ -0,0 +1,78 @@ +#include "qcocoaglcontext.h" +#include <qdebug.h> +#include <QtCore/private/qcore_mac_p.h> + +#import <Cocoa/Cocoa.h> + +QCocoaGLContext::QCocoaGLContext(NSOpenGLView *glView) +:m_glView(glView) +{ + +} + +void QCocoaGLContext::makeCurrent() +{ + [[m_glView openGLContext] makeCurrentContext]; +} +void QCocoaGLContext::doneCurrent() +{ + [NSOpenGLContext clearCurrentContext]; +} + +void QCocoaGLContext::swapBuffers() +{ + [[m_glView openGLContext] flushBuffer]; +} + +void* QCocoaGLContext::getProcAddress(const QString& procName) +{ + CFURLRef url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, + CFSTR("/System/Library/Frameworks/OpenGL.framework"), kCFURLPOSIXPathStyle, false); + CFBundleRef bundle = CFBundleCreate(kCFAllocatorDefault, url); + CFStringRef procNameCF = QCFString::toCFStringRef(procName); + void *proc = CFBundleGetFunctionPointerForName(bundle, procNameCF); + CFRelease(url); + CFRelease(bundle); + CFRelease(procNameCF); + return proc; +} + +// Match up with createNSOpenGLPixelFormat below! +QWindowFormat QCocoaGLContext::windowFormat() const +{ + QWindowFormat format; + format.setRedBufferSize(8); + format.setGreenBufferSize(8); + format.setBlueBufferSize(8); + format.setAlphaBufferSize(8); + +/* + format.setDepthBufferSize(24); + format.setAccumBufferSize(0); + format.setStencilBufferSize(8); + format.setSampleBuffers(false); + format.setSamples(1); + format.setDepth(true); + format.setRgba(true); + format.setAlpha(true); + format.setAccum(false); + format.setStencil(true); + format.setStereo(false); + format.setDirectRendering(false); +*/ + return format; +} + +NSOpenGLPixelFormat *QCocoaGLContext::createNSOpenGLPixelFormat() +{ + NSOpenGLPixelFormatAttribute attrs[] = + { + NSOpenGLPFADoubleBuffer, + NSOpenGLPFADepthSize, 32, + 0 + }; + + NSOpenGLPixelFormat* pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs]; + return pixelFormat; +} + |