summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosé Fonseca <jose.r.fonseca@gmail.com>2011-12-09 19:14:20 +0000
committerJosé Fonseca <jose.r.fonseca@gmail.com>2011-12-09 19:14:20 +0000
commit1e8fb43d670be81595ce7144b81d75c9ae8f7747 (patch)
tree554ba0c2c96c9baf00c232ca51a3ea39d1516c06
parent6cba345d8d0aedcb61344ee008305fdcdc08be3d (diff)
Support creating GL 3.2 contexts on MacOSX.
-rw-r--r--glws_cocoa.mm41
1 files changed, 21 insertions, 20 deletions
diff --git a/glws_cocoa.mm b/glws_cocoa.mm
index aa96d9ca..7f696fa0 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<NSOpenGLPixelFormatAttribute> 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;
}