From c5d72846c471f1e8b417a1e9fe75b77b30ea86e0 Mon Sep 17 00:00:00 2001 From: Ron Tseytlin Date: Sat, 31 Dec 2022 02:32:54 +0200 Subject: [PATCH] Allow Canvas:renderTo to accept varargs The varargs will be forwarded to the function. --- src/modules/graphics/wrap_Canvas.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/modules/graphics/wrap_Canvas.cpp b/src/modules/graphics/wrap_Canvas.cpp index fa020f485..3fb085097 100644 --- a/src/modules/graphics/wrap_Canvas.cpp +++ b/src/modules/graphics/wrap_Canvas.cpp @@ -42,6 +42,8 @@ int w_Canvas_renderTo(lua_State *L) { Graphics::RenderTarget rt(luax_checkcanvas(L, 1)); + int args = lua_gettop(L); + int startidx = 2; if (rt.canvas->getTextureType() != TEXTURE_2D) @@ -67,8 +69,7 @@ int w_Canvas_renderTo(lua_State *L) luax_catchexcept(L, [&](){ graphics->setCanvas(rt, false); }); - lua_settop(L, 2); // make sure the function is on top of the stack - int status = lua_pcall(L, 0, 0, 0); + int status = lua_pcall(L, args - startidx, 0, 0); graphics->setCanvas(oldtargets);