mirror of
https://github.com/ctruLua/ctruLua.git
synced 2025-10-27 16:39:29 +00:00
Added some values in the gfx lib
This commit is contained in:
parent
8a05ba5bff
commit
0c2f641c74
2 changed files with 21 additions and 3 deletions
|
|
@ -38,4 +38,4 @@ while os.run() do
|
||||||
if angle > 2*math.pi then angle = angle - 2*math.pi end
|
if angle > 2*math.pi then angle = angle - 2*math.pi end
|
||||||
|
|
||||||
gfx.render()
|
gfx.render()
|
||||||
end
|
end
|
||||||
|
|
|
||||||
22
source/gfx.c
22
source/gfx.c
|
|
@ -89,6 +89,19 @@ static const struct luaL_Reg gfx_lib[] = {
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// constants
|
||||||
|
struct { char *name; int value; } gfx_constants[] = {
|
||||||
|
{ "GFX_TOP", 0 },
|
||||||
|
{ "GFX_BOTTOM", 1 },
|
||||||
|
{ "GFX_LEFT", 0 },
|
||||||
|
{ "GFX_RIGHT", 1 },
|
||||||
|
{ "TOP_HEIGHT", 240 },
|
||||||
|
{ "TOP_WIDTH", 400 },
|
||||||
|
{ "BOTTOM_HEIGHT", 240 },
|
||||||
|
{ "BOTTOM_WIDTH", 320 },
|
||||||
|
{ NULL, 0 }
|
||||||
|
};
|
||||||
|
|
||||||
struct { char *name; int (*load)(lua_State *L); } gfx_libs[] = {
|
struct { char *name; int (*load)(lua_State *L); } gfx_libs[] = {
|
||||||
{ "color", load_color_lib },
|
{ "color", load_color_lib },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
|
|
@ -96,7 +109,12 @@ struct { char *name; int (*load)(lua_State *L); } gfx_libs[] = {
|
||||||
|
|
||||||
int luaopen_gfx_lib(lua_State *L) {
|
int luaopen_gfx_lib(lua_State *L) {
|
||||||
luaL_newlib(L, gfx_lib);
|
luaL_newlib(L, gfx_lib);
|
||||||
|
|
||||||
|
for (int i = 0; gfx_constants[i].name; i++) {
|
||||||
|
lua_pushinteger(L, gfx_constants[i].value);
|
||||||
|
lua_setfield(L, -2, gfx_constants[i].name);
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; gfx_libs[i].name; i++) {
|
for (int i = 0; gfx_libs[i].name; i++) {
|
||||||
gfx_libs[i].load(L);
|
gfx_libs[i].load(L);
|
||||||
lua_setfield(L, -2, gfx_libs[i].name);
|
lua_setfield(L, -2, gfx_libs[i].name);
|
||||||
|
|
@ -107,4 +125,4 @@ int luaopen_gfx_lib(lua_State *L) {
|
||||||
|
|
||||||
void load_gfx_lib(lua_State *L) {
|
void load_gfx_lib(lua_State *L) {
|
||||||
luaL_requiref(L, "ctr.gfx", luaopen_gfx_lib, 0);
|
luaL_requiref(L, "ctr.gfx", luaopen_gfx_lib, 0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue