diff options
author | cracyc <cracyc@users.noreply.github.com> | 2018-11-04 18:44:27 -0600 |
---|---|---|
committer | cracyc <cracyc@users.noreply.github.com> | 2018-11-04 18:44:27 -0600 |
commit | 781bbdf1dc0b6146cb62ae25bee780b2f81132c8 (patch) | |
tree | 23caec2193ce5ffe4e6eff68703a29cf68bd5b1f | |
parent | 637112742387bbca3af46d844ebe23a77a9f4471 (diff) |
luaengine: add pixels (nw)
-rwxr-xr-x[-rw-r--r--] | src/frontend/mame/luaengine.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/frontend/mame/luaengine.cpp b/src/frontend/mame/luaengine.cpp index eaee5a5b901..f6978f2b22e 100644..100755 --- a/src/frontend/mame/luaengine.cpp +++ b/src/frontend/mame/luaengine.cpp @@ -1743,6 +1743,7 @@ void lua_engine::initialize() * screen:xscale() - screen x scale factor * screen:yscale() - screen y scale factor * screen:pixel(x, y) - get pixel at (x, y) as packed RGB in a u32 + * screen:pixels() - get whole screen bitmap as string */ sol().registry().new_usertype<screen_device>("screen_dev", "new", sol::no_constructor, @@ -1858,6 +1859,16 @@ void lua_engine::initialize() "yscale", &screen_device::yscale, "pixel", [](screen_device &sdev, float x, float y) { return sdev.pixel((s32)x, (s32)y); + }, + "pixels", [this](screen_device &sdev, sol::this_state s) { + lua_State *L = s; + const rectangle &visarea = sdev.visible_area(); + luaL_Buffer buff; + int size = visarea.height() * visarea.width() * 4; + u32 *ptr = (u32 *)luaL_buffinitsize(L, &buff, size); + sdev.pixels(ptr); + luaL_pushresultsize(&buff, size); + return sol::make_reference(L, sol::stack_reference(L, -1)); } ); |