From e662e77fa5c16936d603fc62a4862eafedbc0071 Mon Sep 17 00:00:00 2001 From: Alessandro Proto Date: Sun, 19 Feb 2023 21:38:11 +0100 Subject: [PATCH] Add gpu.clear --- Capy64/Runtime/Libraries/GPU.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Capy64/Runtime/Libraries/GPU.cs b/Capy64/Runtime/Libraries/GPU.cs index ddf6241..2130342 100644 --- a/Capy64/Runtime/Libraries/GPU.cs +++ b/Capy64/Runtime/Libraries/GPU.cs @@ -134,6 +134,11 @@ public class GPU : IComponent name = "loadImage", function = L_LoadImage, }, + new() + { + name = "clear", + function = L_Clear, + }, new(), // NULL }; @@ -517,4 +522,16 @@ public class GPU : IComponent return 3; } + + private static int L_Clear(IntPtr state) + { + var L = Lua.FromIntPtr(state); + + var c = L.OptInteger(1, 0x000000); + + Utils.UnpackRGB((uint)c, out var r, out var g, out var b); + _game.Drawing.Clear(new Color(r, g, b)); + + return 0; + } }