cocoa: handle failure on pixel format creation

This didn't make any difference on with OpenGL 2.1, but with the
introduction of OpenGL3.2 it's possible for the pixel format creation to
fail (if OpenGL3.2 is not supported).

This code handles the failure case accordingly.
This commit is contained in:
Stefano Pigozzi 2012-05-14 16:28:43 +02:00
parent 5fe14d5bf1
commit 4a2bd440dd
1 changed files with 6 additions and 0 deletions

View File

@ -257,6 +257,12 @@ int vo_cocoa_create_window(struct vo *vo, uint32_t d_width,
attr[i] = (NSOpenGLPixelFormatAttribute)0;
s->pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes:attr] autorelease];
if (!s->pixelFormat) {
mp_msg(MSGT_VO, MSGL_ERR,
"[cocoa] Invalid pixel format attribute "
"(GL3 not supported?)\n");
return -1;
}
s->glContext = [[NSOpenGLContext alloc] initWithFormat:s->pixelFormat shareContext:nil];
create_menu();