From d2baaaa7df87eba9566fb935eeab5bd0af80fe1b Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 19 Dec 2015 09:30:20 +0100 Subject: vo_opengl: cocoa: implement alpha window support With --vo=opengl:alpha=yes, the Cocoa backend will now render alpha video without background. --- video/out/cocoa_common.m | 6 ++++++ video/out/opengl/cocoa.c | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'video') diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m index 2cb365cc1f..b88d42ae19 100644 --- a/video/out/cocoa_common.m +++ b/video/out/cocoa_common.m @@ -591,6 +591,12 @@ int vo_cocoa_config_window(struct vo *vo) cocoa_add_fs_screen_profile_observer(vo); cocoa_set_window_title(vo); vo_set_level(vo, vo->opts->ontop); + + GLint o; + if (!CGLGetParameter(s->cgl_ctx, kCGLCPSurfaceOpacity, &o) && !o) { + [s->window setOpaque:NO]; + [s->window setBackgroundColor:[NSColor clearColor]]; + } } s->vo_ready = true; diff --git a/video/out/opengl/cocoa.c b/video/out/opengl/cocoa.c index 7d367e99b4..5e98fce8a1 100644 --- a/video/out/opengl/cocoa.c +++ b/video/out/opengl/cocoa.c @@ -99,7 +99,7 @@ error_out: return err; } -static bool create_gl_context(struct MPGLContext *ctx) +static bool create_gl_context(struct MPGLContext *ctx, int vo_flags) { struct cgl_context *p = ctx->priv; CGLError err; @@ -124,6 +124,9 @@ static bool create_gl_context(struct MPGLContext *ctx) vo_cocoa_set_opengl_ctx(ctx->vo, p->ctx); CGLSetCurrentContext(p->ctx); + if (vo_flags & VOFLAG_ALPHA) + CGLSetParameter(p->ctx, kCGLCPSurfaceOpacity, &(GLint){0}); + ctx->depth_r = ctx->depth_g = ctx->depth_b = cgl_color_size(ctx); mpgl_load_functions(ctx->gl, (void *)cocoa_glgetaddr, NULL, ctx->vo->log); @@ -143,7 +146,7 @@ static int cocoa_init(MPGLContext *ctx, int vo_flags) { vo_cocoa_init(ctx->vo); - if (!create_gl_context(ctx)) + if (!create_gl_context(ctx, vo_flags)) return -1; ctx->gl->SwapInterval = set_swap_interval; -- cgit v1.2.3