From 2584e46816330096b65c94152bb38a8a7c155ca0 Mon Sep 17 00:00:00 2001 From: Reuh Date: Tue, 18 Aug 2015 15:40:54 +0200 Subject: [PATCH] Added gfx.startFrame and gfx.endFrame --- sdcard/ctruLua/main.lua | 6 ++++-- source/gfx.c | 18 +++++++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/sdcard/ctruLua/main.lua b/sdcard/ctruLua/main.lua index f7d60b6..3655b8a 100644 --- a/sdcard/ctruLua/main.lua +++ b/sdcard/ctruLua/main.lua @@ -14,8 +14,10 @@ while os.run() do if keys.held.up then y = y - 1 end if keys.held.down then y = y + 1 end - gfx.rectangle(x, y, 10, 10) - gfx.rectangle(240, 150, 120, 10) + gfx.startFrame() + gfx.rectangle(x, y, 10, 10) + gfx.rectangle(240, 150, 120, 10) + gfx.endFrame() gfx.render() end \ No newline at end of file diff --git a/source/gfx.c b/source/gfx.c index 1ee3176..f29c4d8 100644 --- a/source/gfx.c +++ b/source/gfx.c @@ -5,14 +5,24 @@ u32 defaultColor = RGBA8(255, 255, 255, 255); -static int gfx_render(lua_State *L) { - sf2d_end_frame(); - sf2d_swapbuffers(); +static int gfx_startFrame(lua_State *L) { sf2d_start_frame(GFX_TOP, GFX_LEFT); return 0; } +static int gfx_endFrame(lua_State *L) { + sf2d_end_frame(); + + return 0; +} + +static int gfx_render(lua_State *L) { + sf2d_swapbuffers(); + + return 0; +} + static int gfx_rectangle(lua_State *L) { int x = luaL_checkinteger(L, 1); int y = luaL_checkinteger(L, 2); @@ -26,6 +36,8 @@ static int gfx_rectangle(lua_State *L) { } static const struct luaL_Reg gfx_lib[] = { + { "startFrame", gfx_startFrame}, + { "endFrame", gfx_endFrame }, { "render", gfx_render }, { "rectangle", gfx_rectangle }, { NULL, NULL }