From 4385a9e2fc228ae2c00aa973f640c2852bd17021 Mon Sep 17 00:00:00 2001 From: Alessandro Proto Date: Wed, 1 Feb 2023 08:29:23 +0100 Subject: [PATCH] Add width and height to gpu.newBuffer --- Capy64/Runtime/Libraries/GPU.cs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/Capy64/Runtime/Libraries/GPU.cs b/Capy64/Runtime/Libraries/GPU.cs index e292f0b..278d4b4 100644 --- a/Capy64/Runtime/Libraries/GPU.cs +++ b/Capy64/Runtime/Libraries/GPU.cs @@ -409,10 +409,34 @@ public class GPU : IPlugin { var L = Lua.FromIntPtr(state); - var buffer = new uint[_game.Width * _game.Height]; + var width = L.OptInteger(1, _game.Width); + var height = L.OptInteger(2, _game.Height); + + var buffer = new uint[width * height]; GPUBuffer.Push(L, buffer); return 1; } + + // WIP + private static int L_CopyBuffer(IntPtr state) + { + var L = Lua.FromIntPtr(state); + + var x = L.CheckInteger(1); + var y = L.CheckInteger(2); + + var from = L.CheckObject(3, GPUBuffer.ObjectType, false); + if (from is null) + { + L.ArgumentError(3, GPUBuffer.ObjectType + " expected, got " + L.TypeName(L.Type(3))); + } + + var origin = new uint[_game.Width * _game.Height]; + _game.Drawing.Canvas.GetData(origin); + + + return 0; + } }