]> git.cworth.org Git - apitrace/blobdiff - glws_cocoa.mm
Move tracers to wrappers subdirectory.
[apitrace] / glws_cocoa.mm
index 2e9bbaef72bb2e68f86c8626606a1e145b4768bd..7f696fa0f36b9b0f8c48a4f822bc6df930f9f1f0 100644 (file)
@@ -171,25 +171,29 @@ cleanup(void) {
 
 
 Visual *
-createVisual(bool doubleBuffer) {
-    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
-    };
-
-    NSOpenGLPixelFormatAttribute *attribs = doubleBuffer ? double_attribs : single_attribs;
+createVisual(bool doubleBuffer, Profile profile) {
+    if (profile != PROFILE_COMPAT &&
+        profile != PROFILE_CORE) {
+        return nil;
+    }
+
+    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];
@@ -210,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;
     }