mirror of
https://github.com/ctruLua/ctruLua.git
synced 2025-10-27 16:39:29 +00:00
Added some code
This commit is contained in:
parent
5f22a4008a
commit
03baa21c10
80 changed files with 36025 additions and 0 deletions
41
source/gfx.c
Normal file
41
source/gfx.c
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
#include <sf2d.h>
|
||||
|
||||
#include <lua.h>
|
||||
#include <lauxlib.h>
|
||||
|
||||
u32 defaultColor = RGBA8(255, 255, 255, 255);
|
||||
|
||||
static int gfx_render(lua_State *L) {
|
||||
sf2d_end_frame();
|
||||
sf2d_swapbuffers();
|
||||
sf2d_start_frame(GFX_TOP, GFX_LEFT);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gfx_rectangle(lua_State *L) {
|
||||
int x = luaL_checkinteger(L, 1);
|
||||
int y = luaL_checkinteger(L, 2);
|
||||
int width = luaL_checkinteger(L, 3);
|
||||
int height = luaL_checkinteger(L, 4);
|
||||
u32 color = luaL_optinteger(L, 5, defaultColor);
|
||||
|
||||
sf2d_draw_rectangle(x, y, width, height, color);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct luaL_Reg gfx_lib[] = {
|
||||
{ "render", gfx_render },
|
||||
{ "rectangle", gfx_rectangle },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
int luaopen_gfx_lib(lua_State *L) {
|
||||
luaL_newlib(L, gfx_lib);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void load_gfx_lib(lua_State *L) {
|
||||
luaL_requiref(L, "ctr.gfx", luaopen_gfx_lib, 0);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue