feat(gui): draw windowed apps through a batched SDL2 surface
Compiled programs could only write to the terminal, so the demo editor had no real window. When CMake finds SDL2 the runtime now exposes a `gui` table and Demo/guipaint.lua builds a 960x640 editor on top of it. Frames are collected in Lua, merged into horizontal runs and sent with a single `gui.rects` call: a full scene goes from 15071 draw calls and 42.9 ms per frame to 1522 calls and 2.1 ms, and the rendered screenshot stays pixel-identical.
This commit is contained in:
11 files changed
+1840
-9
No files matched your search
@@ -5,6 +5,8 @@
|
||||
|
||||
#include <lua.hpp>
|
||||
|
||||
#include "gui.hpp"
|
||||
|
||||
#if LUA_VERSION_NUM != 504
|
||||
#error "luacpp requires Lua 5.4 (LUA_VERSION_NUM == 504)"
|
||||
#endif
|
||||
@@ -638,10 +640,14 @@ public:
|
||||
if (!L_) throw Error("cannot create a Lua state");
|
||||
own_ = true;
|
||||
luaL_openlibs(L_);
|
||||
gui::register_gui(L_);
|
||||
}
|
||||
|
||||
explicit State(lua_State* L, bool own = false) : L_(L), own_(own) {
|
||||
if (own_ && L_) luaL_openlibs(L_);
|
||||
if (own_ && L_) {
|
||||
luaL_openlibs(L_);
|
||||
gui::register_gui(L_);
|
||||
}
|
||||
}
|
||||
|
||||
~State() {
|
||||
|
||||
Reference in new issue
Block a user