summaryrefslogtreecommitdiffstats
path: root/video/out/opengl/context_w32.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-12-19 14:17:06 +0100
committerwm4 <wm4@nowhere>2015-12-19 14:19:08 +0100
commit575965a91c65544f10f9b5a2c9181f0bddc81f7a (patch)
treeb6b7938504f875b6fef5418b97a98846b725e146 /video/out/opengl/context_w32.c
parenta0519f1d188e3d3be8f0e78a71868d7cbf1cc11d (diff)
downloadmpv-win32-alpha.tar.bz2
mpv-win32-alpha.tar.xz
half-working alpha on windowswin32-alpha
doesn't redraw the "background" properly - compositor bug? http://stackoverflow.com/questions/4052940/how-to-make-an-opengl- rendering-context-with-transparent-background
Diffstat (limited to 'video/out/opengl/context_w32.c')
-rw-r--r--video/out/opengl/context_w32.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/video/out/opengl/context_w32.c b/video/out/opengl/context_w32.c
index 5157cd97a5..02b748db42 100644
--- a/video/out/opengl/context_w32.c
+++ b/video/out/opengl/context_w32.c
@@ -49,6 +49,22 @@ static int GLAPIENTRY w32_swap_interval(int interval)
return 0;
}
+static void enable_transparency(struct MPGLContext *ctx,
+ PIXELFORMATDESCRIPTOR *pfd)
+{
+ HWND win = vo_w32_hwnd(ctx->vo);
+ pfd->dwFlags |= PFD_SUPPORT_COMPOSITION;
+ pfd->cAlphaBits = 8;
+ pfd->cColorBits += pfd->cAlphaBits;
+
+ DWM_BLURBEHIND bb = {
+ .hRgnBlur = CreateRectRgn(0, 0, -1, -1),
+ .dwFlags = DWM_BB_ENABLE | DWM_BB_BLURREGION,
+ .fEnable = TRUE,
+ };
+ DwmEnableBlurBehindWindow(win, &bb);
+}
+
static bool create_dc(struct MPGLContext *ctx, int flags)
{
struct w32_context *w32_ctx = ctx->priv;
@@ -70,6 +86,10 @@ static bool create_dc(struct MPGLContext *ctx, int flags)
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 24;
pfd.iLayerType = PFD_MAIN_PLANE;
+
+ if (flags & VOFLAG_ALPHA)
+ enable_transparency(ctx, &pfd);
+
int pf = ChoosePixelFormat(hdc, &pfd);
if (!pf) {
@@ -221,6 +241,7 @@ static void create_ctx(void *ptr)
ctx->gl->fb_g = pfd.cGreenBits;
ctx->gl->fb_b = pfd.cBlueBits;
}
+ ctx->gl->fb_premultiplied = true;
wglMakeCurrent(w32_ctx->hdc, NULL);
}