Bugfix gpu not pushing a GPUBuffer

This commit is contained in:
Alessandro Proto 2023-03-09 21:00:23 +01:00
parent 7628d4a29e
commit f9a88f39bb

View file

@ -410,10 +410,18 @@ public class GPU : IComponent
{ {
var L = Lua.FromIntPtr(state); var L = Lua.FromIntPtr(state);
var buffer = new uint[_game.Width * _game.Height]; var buffer = new uint[_game.Width * _game.Height];
_game.Drawing.Canvas.GetData(buffer); _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); L.SetMetaTable(GPUBufferMeta.ObjectType);
return 1; return 1;
@ -434,12 +442,19 @@ public class GPU : IComponent
{ {
var L = Lua.FromIntPtr(state); var L = Lua.FromIntPtr(state);
var width = L.OptInteger(1, _game.Width); var width = (int)L.OptInteger(1, _game.Width);
var height = L.OptInteger(2, _game.Height); var height = (int)L.OptInteger(2, _game.Height);
var buffer = new uint[width * 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); L.SetMetaTable(GPUBufferMeta.ObjectType);
return 1; return 1;