diff options
Diffstat (limited to 'libvo/cocoa_common.m')
-rw-r--r-- | libvo/cocoa_common.m | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/libvo/cocoa_common.m b/libvo/cocoa_common.m index f5ad7a0943..e8ef278b1e 100644 --- a/libvo/cocoa_common.m +++ b/libvo/cocoa_common.m @@ -20,7 +20,7 @@ #import <Cocoa/Cocoa.h> #import <OpenGL/OpenGL.h> #import <QuartzCore/QuartzCore.h> -#import <CoreServices/CoreServices.h> // for CGDisplayHideCursor +#import <CoreServices/CoreServices.h> // for CGDisplayHideCursor and Gestalt #include "cocoa_common.h" #include "options.h" @@ -35,6 +35,18 @@ #include "osx_common.h" #include "mp_msg.h" +#ifndef NSOpenGLPFAOpenGLProfile +#define NSOpenGLPFAOpenGLProfile 99 +#endif + +#ifndef NSOpenGLProfileVersionLegacy +#define NSOpenGLProfileVersionLegacy 0x1000 +#endif + +#ifndef NSOpenGLProfileVersion3_2Core +#define NSOpenGLProfileVersion3_2Core 0x3200 +#endif + #define NSLeftAlternateKeyMask (0x000020 | NSAlternateKeyMask) #define NSRightAlternateKeyMask (0x000040 | NSAlternateKeyMask) @@ -94,6 +106,8 @@ void resize_window(struct vo *vo); void vo_cocoa_display_cursor(int requested_state); void create_menu(void); +bool is_lion_or_better(void); + struct vo_cocoa_state *vo_cocoa_init_state(void) { struct vo_cocoa_state *s = talloc_ptrtype(NULL, s); @@ -192,7 +206,8 @@ void vo_cocoa_ontop(struct vo *vo) } int vo_cocoa_create_window(struct vo *vo, uint32_t d_width, - uint32_t d_height, uint32_t flags) + uint32_t d_height, uint32_t flags, + int gl3profile) { struct MPOpts *opts = vo->opts; if (s->current_video_size.width > 0 || s->current_video_size.height > 0) @@ -206,13 +221,18 @@ int vo_cocoa_create_window(struct vo *vo, uint32_t d_width, GLMPlayerOpenGLView *glView = [[GLMPlayerOpenGLView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)]; - NSOpenGLPixelFormatAttribute attrs[] = { - NSOpenGLPFADoubleBuffer, // double buffered - NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute)16, // 16 bit depth buffer - (NSOpenGLPixelFormatAttribute)0 - }; + int i = 0; + NSOpenGLPixelFormatAttribute attr[32]; + if (is_lion_or_better()) { + attr[i++] = NSOpenGLPFAOpenGLProfile; + attr[i++] = (gl3profile ? NSOpenGLProfileVersion3_2Core : NSOpenGLProfileVersionLegacy); + } + attr[i++] = NSOpenGLPFADoubleBuffer; // double buffered + attr[i++] = NSOpenGLPFADepthSize; + attr[i++] = (NSOpenGLPixelFormatAttribute)16; // 16 bit depth buffer + attr[i] = (NSOpenGLPixelFormatAttribute)0; - NSOpenGLPixelFormat *pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs]; + NSOpenGLPixelFormat *pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr]; s->glContext = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:nil]; create_menu(); @@ -368,6 +388,17 @@ void create_menu() [menuItem release]; } +bool is_lion_or_better(void) +{ + SInt32 major, minor; + Gestalt(gestaltSystemVersionMajor, &major); + Gestalt(gestaltSystemVersionMinor, &minor); + if(major >= 10 && minor >= 7) + return YES; + else + return NO; +} + @implementation GLMPlayerWindow - (void) windowDidResize:(NSNotification *) notification |