opengl/context_win: make --alpha runtime changeable

Same as d3d11, but since SetPixelFormat can be only called once,
cAlphaBits in PIXELFORMATDESCRIPTOR must be set to make this work.
This commit is contained in:
nanahi 2024-02-16 01:08:43 -05:00 committed by Dudemanguy
parent 8de67a4af5
commit 095038b1bc
1 changed files with 13 additions and 8 deletions

View File

@ -96,8 +96,7 @@ static bool create_dc(struct ra_ctx *ctx)
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 24;
if (ctx->opts.want_alpha)
pfd.cAlphaBits = 8;
pfd.cAlphaBits = 8;
pfd.iLayerType = PFD_MAIN_PLANE;
int pf = ChoosePixelFormat(hdc, &pfd);
@ -373,11 +372,17 @@ static int wgl_control(struct ra_ctx *ctx, int *events, int request, void *arg)
return ret;
}
static void wgl_update_render_opts(struct ra_ctx *ctx)
{
vo_w32_set_transparency(ctx->vo, ctx->opts.want_alpha);
}
const struct ra_ctx_fns ra_ctx_wgl = {
.type = "opengl",
.name = "win",
.init = wgl_init,
.reconfig = wgl_reconfig,
.control = wgl_control,
.uninit = wgl_uninit,
.type = "opengl",
.name = "win",
.init = wgl_init,
.reconfig = wgl_reconfig,
.control = wgl_control,
.update_render_opts = wgl_update_render_opts,
.uninit = wgl_uninit,
};