From 1e8fb43d670be81595ce7144b81d75c9ae8f7747 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Fri, 9 Dec 2011 19:14:20 +0000 Subject: [PATCH] Support creating GL 3.2 contexts on MacOSX. --- glws_cocoa.mm | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/glws_cocoa.mm b/glws_cocoa.mm index aa96d9c..7f696fa 100644 --- a/glws_cocoa.mm +++ b/glws_cocoa.mm @@ -172,28 +172,28 @@ cleanup(void) { Visual * createVisual(bool doubleBuffer, Profile profile) { - NSOpenGLPixelFormatAttribute single_attribs[] = { - NSOpenGLPFAAlphaSize, (NSOpenGLPixelFormatAttribute)1, - NSOpenGLPFAColorSize, (NSOpenGLPixelFormatAttribute)24, - NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute)1, - NSOpenGLPFAStencilSize, (NSOpenGLPixelFormatAttribute)1, - (NSOpenGLPixelFormatAttribute)0 - }; - - NSOpenGLPixelFormatAttribute double_attribs[] = { - NSOpenGLPFAAlphaSize, (NSOpenGLPixelFormatAttribute)1, - NSOpenGLPFAColorSize, (NSOpenGLPixelFormatAttribute)24, - NSOpenGLPFADoubleBuffer, - NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute)1, - NSOpenGLPFAStencilSize, (NSOpenGLPixelFormatAttribute)1, - (NSOpenGLPixelFormatAttribute)0 - }; - - if (profile != PROFILE_COMPAT) { + if (profile != PROFILE_COMPAT && + profile != PROFILE_CORE) { return nil; } - NSOpenGLPixelFormatAttribute *attribs = doubleBuffer ? double_attribs : single_attribs; + Attributes attribs; + + attribs.add(NSOpenGLPFAAlphaSize, (NSOpenGLPixelFormatAttribute)1); + attribs.add(NSOpenGLPFAColorSize, (NSOpenGLPixelFormatAttribute)24); + if (doubleBuffer) { + attribs.add(NSOpenGLPFADoubleBuffer); + } + attribs.add(NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute)1); + attribs.add(NSOpenGLPFAStencilSize, (NSOpenGLPixelFormatAttribute)1); + if (profile == PROFILE_CORE) { +#if CGL_VERSION_1_3 + attribs.add(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core); +#else + return NULL; +#endif + } + attribs.end(); NSOpenGLPixelFormat *pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs]; @@ -214,7 +214,8 @@ createContext(const Visual *visual, Context *shareContext, Profile profile) NSOpenGLContext *share_context = nil; NSOpenGLContext *context; - if (profile != PROFILE_COMPAT) { + if (profile != PROFILE_COMPAT && + profile != PROFILE_CORE) { return nil; } -- 2.7.4