From f9a88f39bbb9ab039c52115558b979a2170a3684 Mon Sep 17 00:00:00 2001 From: Alessandro Proto Date: Thu, 9 Mar 2023 21:00:23 +0100 Subject: [PATCH] Bugfix gpu not pushing a GPUBuffer --- Capy64/Runtime/Libraries/GPU.cs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/Capy64/Runtime/Libraries/GPU.cs b/Capy64/Runtime/Libraries/GPU.cs index 37de717..69198c4 100644 --- a/Capy64/Runtime/Libraries/GPU.cs +++ b/Capy64/Runtime/Libraries/GPU.cs @@ -410,10 +410,18 @@ public class GPU : IComponent { var L = Lua.FromIntPtr(state); + var buffer = new uint[_game.Width * _game.Height]; _game.Drawing.Canvas.GetData(buffer); - ObjectManager.PushObject(L, buffer); + var gpuBuffer = new GPUBufferMeta.GPUBuffer + { + Buffer = buffer, + Width = _game.Width, + Height = _game.Height, + }; + + ObjectManager.PushObject(L, gpuBuffer); L.SetMetaTable(GPUBufferMeta.ObjectType); return 1; @@ -434,12 +442,19 @@ public class GPU : IComponent { var L = Lua.FromIntPtr(state); - var width = L.OptInteger(1, _game.Width); - var height = L.OptInteger(2, _game.Height); + var width = (int)L.OptInteger(1, _game.Width); + var height = (int)L.OptInteger(2, _game.Height); var buffer = new uint[width * height]; - ObjectManager.PushObject(L, buffer); + var gpuBuffer = new GPUBufferMeta.GPUBuffer + { + Buffer = buffer, + Width = width, + Height = height, + }; + + ObjectManager.PushObject(L, gpuBuffer); L.SetMetaTable(GPUBufferMeta.ObjectType); return 1;