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

43 lines
916 B
C
Raw Normal View History

2018-02-17 17:18:08 +00:00
#include "api.h"
2018-09-27 04:45:45 +00:00
#include "version.h"
2018-02-17 17:18:08 +00:00
#include "resources/logo.png.h"
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
lua_pushstring(L, "Windows");
#elif __APPLE__
lua_pushstring(L, "macOS");
#elif EMSCRIPTEN
lua_pushstring(L, "Web");
#elif __ANDROID__
lua_pushstring(L, "Android");
2018-09-27 04:45:45 +00:00
#elif __linux__
lua_pushstring(L, "Linux");
#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;
}