1
0
Fork 0
mirror of https://github.com/bjornbytes/lovr.git synced 2024-07-11 16:33:35 +00:00
lovr/src/api/l_lovr.c

86 lines
1.9 KiB
C
Raw Normal View History

2018-02-17 17:18:08 +00:00
#include "api.h"
2019-05-20 09:47:33 +00:00
#include "util.h"
2018-02-17 17:18:08 +00:00
#include "resources/logo.png.h"
#include "lib/lua-cjson/lua_cjson.h"
#include "lib/lua-enet/enet.h"
const luaL_Reg lovrModules[] = {
{ "lovr", luaopen_lovr },
#ifdef LOVR_ENABLE_AUDIO
{ "lovr.audio", luaopen_lovr_audio },
#endif
#ifdef LOVR_ENABLE_DATA
{ "lovr.data", luaopen_lovr_data },
#endif
#ifdef LOVR_ENABLE_EVENT
{ "lovr.event", luaopen_lovr_event },
#endif
#ifdef LOVR_ENABLE_FILESYSTEM
{ "lovr.filesystem", luaopen_lovr_filesystem },
#endif
#ifdef LOVR_ENABLE_GRAPHICS
{ "lovr.graphics", luaopen_lovr_graphics },
#endif
#ifdef LOVR_ENABLE_HEADSET
{ "lovr.headset", luaopen_lovr_headset },
#endif
#ifdef LOVR_ENABLE_MATH
{ "lovr.math", luaopen_lovr_math },
#endif
#ifdef LOVR_ENABLE_PHYSICS
{ "lovr.physics", luaopen_lovr_physics },
#endif
#ifdef LOVR_ENABLE_THREAD
{ "lovr.thread", luaopen_lovr_thread },
#endif
#ifdef LOVR_ENABLE_TIMER
{ "lovr.timer", luaopen_lovr_timer },
#endif
#ifdef LOVR_ENABLE_JSON
{ "cjson", luaopen_cjson },
#endif
#ifdef LOVR_ENABLE_ENET
{ "enet", luaopen_enet },
#endif
{ NULL, NULL }
};
2018-02-17 17:18:08 +00:00
2018-09-27 01:27:38 +00:00
static int l_lovrGetOS(lua_State* L) {
2018-09-27 04:45:45 +00:00
#ifdef _WIN32
2018-12-16 05:45:32 +00:00
lua_pushliteral(L, "Windows");
2018-09-27 04:45:45 +00:00
#elif __APPLE__
2018-12-16 05:45:32 +00:00
lua_pushliteral(L, "macOS");
2018-09-27 04:45:45 +00:00
#elif EMSCRIPTEN
2018-12-16 05:45:32 +00:00
lua_pushliteral(L, "Web");
#elif __ANDROID__
2018-12-16 05:45:32 +00:00
lua_pushliteral(L, "Android");
2018-09-27 04:45:45 +00:00
#elif __linux__
2018-12-16 05:45:32 +00:00
lua_pushliteral(L, "Linux");
2018-09-27 04:45:45 +00:00
#else
lua_pushnil(L);
#endif
2018-09-27 01:27:38 +00:00
return 1;
}
static int l_lovrGetVersion(lua_State* L) {
2018-09-27 04:45:45 +00:00
lua_pushinteger(L, LOVR_VERSION_MAJOR);
lua_pushinteger(L, LOVR_VERSION_MINOR);
lua_pushinteger(L, LOVR_VERSION_PATCH);
2018-09-27 01:27:38 +00:00
return 3;
}
static const luaL_Reg lovr[] = {
{ "_setConf", luax_setconf },
{ "getOS", l_lovrGetOS },
{ "getVersion", l_lovrGetVersion },
{ NULL, NULL }
};
int luaopen_lovr(lua_State* L) {
2018-02-17 17:18:08 +00:00
lua_newtable(L);
luaL_register(L, NULL, lovr);
lua_pushlstring(L, (const char*) logo_png, logo_png_len);
lua_setfield(L, -2, "_logo");
return 1;
}