Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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