Skip to content

Instantly share code, notes, and snippets.

@atduskgreg
Created January 18, 2014 23:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atduskgreg/8498097 to your computer and use it in GitHub Desktop.
Save atduskgreg/8498097 to your computer and use it in GitHub Desktop.
NSOpenGLPixelFormatAttribute attr[] =
{
NSOpenGLPFADoubleBuffer,
NSOpenGLPFAAccelerated,
NSOpenGLPFADepthSize, 24,
NSOpenGLPFAMultisample,
NSOpenGLPFASampleBuffers, 1,
NSOpenGLPFASamples, 4,
(NSOpenGLPixelFormatAttribute) 0
};
// Make our GL Pixel Format
NSOpenGLPixelFormat* pf = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr];
if(!pf)
NSLog(@"Could not create pixel format, falling back to simpler pixel format");
NSOpenGLPixelFormatAttribute simpleattr[] =
{
NSOpenGLPFADoubleBuffer,
NSOpenGLPFAAccelerated,
(NSOpenGLPixelFormatAttribute) 0
};
pf = [[NSOpenGLPixelFormat alloc] initWithAttributes:simpleattr];
if(!pf)
{
NSLog(@"Could not create pixel format, bailing");
[NSApp terminate:self];
}
self.glContext = [[NSOpenGLContext alloc] initWithFormat:pf shareContext:nil];
[self.glContext makeCurrentContext];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment