title: setting OpenGL version in objective-C
body: <p>I am writing in Objective-C for OS X. OpenGL defaults to version 2.1, I am trying to find out how to set it to 3.2 or higher.</p>
  
  <p>I am not using GLFW, or QT, or SDL, or any other third-party framework, just what Apple and OpenGL provides. GLUT is OK though, but I'd prefer an Apple-ish native solution. My Mac is a brand new mini, which is theoretically capable of 4.1.</p>
  
  <p>I am using a NSOpenGLView, and I just want my vertices in arrays, like modern OpenGL! I do not want to use SceneKit, but I am open to GLKitBaseEffect if it gives a solution, which I doubt.</p>
  
  <p>One solution that comes up in searches is this:</p>
  
  <pre><code>NSOpenGLPixelFormatAttribute attrs[] =
  {
    NSOpenGLPFADoubleBuffer,
    NSOpenGLPFADepthSize, 24,
    NSOpenGLPFAOpenGLProfile,
    NSOpenGLProfileVersion3_2Core,
    0
  };
  
  NSOpenGLPixelFormat* pf = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs];
  
  NSOpenGLContext* oglc = [[NSOpenGLContext alloc] initWithFormat:pf shareContext:nil];
  [self setOpenGLContext:oglc];
  [oglc makeCurrentContext];
  </code></pre>
  
  <p>It does not work- it will not even create the view. I can only create the view with [NSOpenGLPixelFormat defaultPixelFormat], and I can find no way to start with the defaults and alter one of it's parameters before creating the view.</p>
  
  <p>This "Works":</p>
  
  <pre><code>NSOpenGLPixelFormat* pf=[SculptView defaultPixelFormat];
   view=[[SculptView alloc] initWithFrame:(NSRect){0,0,768,1024} pixelFormat:pf];
  </code></pre>
  
  <p>but I'm stuck with OpenGL 2.1, with a bunch of glBegins and glEnds, and no arrays.</p>