@@ -42,6 +42,7 @@ static void draw_lua()
4242
4343 bool success = true ;
4444
45+ // D2D Graphics
4546 if (!lua->rctx .presenter )
4647 {
4748 // NOTE: We have to invoke the callback because we're waiting for the script to issue a d2d call
@@ -54,12 +55,20 @@ static void draw_lua()
5455 lua->rctx .presenter ->end_present ();
5556 }
5657
58+ // GDI Graphics. Ugh.
5759 success &= LuaCallbacks::invoke_callbacks_with_key (lua, LuaCallbacks::REG_ATUPDATESCREEN);
5860
5961 if (lua->rctx .has_gdi_content )
6062 {
61- BitBlt (lua->rctx .gdi_front_dc , 0 , 0 , lua->rctx .dc_size .width , lua->rctx .dc_size .height ,
62- lua->rctx .gdi_back_dc , 0 , 0 , SRCCOPY);
63+ SIZE size = {(LONG)lua->rctx .dc_size .width , (LONG)lua->rctx .dc_size .height };
64+ POINT src_pt = {0 , 0 };
65+
66+ BLENDFUNCTION bf = {};
67+ bf.BlendOp = AC_SRC_OVER;
68+ bf.SourceConstantAlpha = 255 ;
69+ bf.AlphaFormat = 0 ;
70+ UpdateLayeredWindow (lua->rctx .gdi_overlay_hwnd , nullptr , &src_pt, &size, lua->rctx .gdi_back_dc , &src_pt,
71+ LuaRenderer::LUA_GDI_COLOR_MASK, &bf, ULW_COLORKEY);
6372 }
6473
6574 lua->rctx .last_render_time = now;
@@ -168,7 +177,7 @@ static LRESULT CALLBACK overlay_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPAR
168177void LuaRenderer::init ()
169178{
170179 WNDCLASS wndclass = {0 };
171- wndclass.style = CS_GLOBALCLASS | CS_HREDRAW | CS_VREDRAW | CS_OWNDC ;
180+ wndclass.style = CS_GLOBALCLASS | CS_HREDRAW | CS_VREDRAW;
172181 wndclass.lpfnWndProc = (WNDPROC)overlay_wndproc;
173182 wndclass.hInstance = g_main_ctx.hinst ;
174183 wndclass.hCursor = LoadCursor (NULL , IDC_ARROW);
@@ -248,9 +257,6 @@ void LuaRenderer::create_renderer(t_lua_rendering_context *ctx, t_lua_environmen
248257 ctx->gdi_overlay_hwnd =
249258 CreateWindowEx (WS_EX_LAYERED | WS_EX_TRANSPARENT, OVERLAY_CLASS, L" " , WS_CHILD | WS_VISIBLE, 0 , 0 ,
250259 ctx->dc_size .width , ctx->dc_size .height , g_main_ctx.hwnd , nullptr , g_main_ctx.hinst , nullptr );
251- SetLayeredWindowAttributes (ctx->gdi_overlay_hwnd , LUA_GDI_COLOR_MASK, 0 , LWA_COLORKEY);
252-
253- ctx->gdi_front_dc = GetDC (ctx->gdi_overlay_hwnd );
254260
255261 // If we don't fill up the DC with the key first, it never becomes "transparent"
256262 FillRect (ctx->gdi_back_dc , &window_rect, g_alpha_mask_brush);
@@ -309,7 +315,6 @@ void LuaRenderer::destroy_renderer(t_lua_rendering_context *ctx)
309315
310316 if (ctx->gdi_back_dc )
311317 {
312- ReleaseDC (ctx->gdi_overlay_hwnd , ctx->gdi_front_dc );
313318 DestroyWindow (ctx->gdi_overlay_hwnd );
314319 SelectObject (ctx->gdi_back_dc , nullptr );
315320 DeleteDC (ctx->gdi_back_dc );
0 commit comments