mirror of
https://github.com/ctruLua/ctruLua.git
synced 2025-10-27 16:39:29 +00:00
Added gfx.startFrame and gfx.endFrame
This commit is contained in:
parent
0e42f25b8b
commit
2584e46816
2 changed files with 19 additions and 5 deletions
|
|
@ -14,8 +14,10 @@ while os.run() do
|
||||||
if keys.held.up then y = y - 1 end
|
if keys.held.up then y = y - 1 end
|
||||||
if keys.held.down then y = y + 1 end
|
if keys.held.down then y = y + 1 end
|
||||||
|
|
||||||
gfx.rectangle(x, y, 10, 10)
|
gfx.startFrame()
|
||||||
gfx.rectangle(240, 150, 120, 10)
|
gfx.rectangle(x, y, 10, 10)
|
||||||
|
gfx.rectangle(240, 150, 120, 10)
|
||||||
|
gfx.endFrame()
|
||||||
|
|
||||||
gfx.render()
|
gfx.render()
|
||||||
end
|
end
|
||||||
18
source/gfx.c
18
source/gfx.c
|
|
@ -5,14 +5,24 @@
|
||||||
|
|
||||||
u32 defaultColor = RGBA8(255, 255, 255, 255);
|
u32 defaultColor = RGBA8(255, 255, 255, 255);
|
||||||
|
|
||||||
static int gfx_render(lua_State *L) {
|
static int gfx_startFrame(lua_State *L) {
|
||||||
sf2d_end_frame();
|
|
||||||
sf2d_swapbuffers();
|
|
||||||
sf2d_start_frame(GFX_TOP, GFX_LEFT);
|
sf2d_start_frame(GFX_TOP, GFX_LEFT);
|
||||||
|
|
||||||
return 0;
|
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) {
|
static int gfx_rectangle(lua_State *L) {
|
||||||
int x = luaL_checkinteger(L, 1);
|
int x = luaL_checkinteger(L, 1);
|
||||||
int y = luaL_checkinteger(L, 2);
|
int y = luaL_checkinteger(L, 2);
|
||||||
|
|
@ -26,6 +36,8 @@ static int gfx_rectangle(lua_State *L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct luaL_Reg gfx_lib[] = {
|
static const struct luaL_Reg gfx_lib[] = {
|
||||||
|
{ "startFrame", gfx_startFrame},
|
||||||
|
{ "endFrame", gfx_endFrame },
|
||||||
{ "render", gfx_render },
|
{ "render", gfx_render },
|
||||||
{ "rectangle", gfx_rectangle },
|
{ "rectangle", gfx_rectangle },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue