Small fixes;

This commit is contained in:
bjorn 2017-04-22 17:02:41 -07:00
parent 95fb96ec2c
commit c9be126b6b
3 changed files with 12 additions and 12 deletions

View File

@ -78,7 +78,8 @@ add_executable(lovr ${LOVR_SRC} ${LOVR_HEADSET})
if(EMSCRIPTEN)
set(CMAKE_EXECUTABLE_SUFFIX ".html")
add_definitions(-s USE_ZLIB=1 -s ASSERTIONS=2 -s FULL_ES2=1 -O3 -s AGGRESSIVE_VARIABLE_ELIMINATION=1 -s OUTLINING_LIMIT=15000 -s NO_EXIT_RUNTIME=1)
add_definitions(-s USE_ZLIB=1 -s ASSERTIONS=2 -s FULL_ES2=1 -O3 -s AGGRESSIVE_VARIABLE_ELIMINATION=1 -s NO_EXIT_RUNTIME=1)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s TOTAL_MEMORY=134217728")
set(ZLIB_FOUND 1)
set(ZLIB_LIBRARIES "-s USE_ZLIB=1")
set(ZLIB_INCLUDE_DIR .)

View File

@ -79,6 +79,7 @@ int lovrFilesystemGetAppdataDirectory(char* dest, unsigned int size) {
CoTaskMemFree(appData);
return 0;
#elif EMSCRIPTEN
strncpy(dest, "/home/web_user", size);
return 0;
#else
#error "This platform is missing an implementation for lovrFilesystemGetAppdataDirectory"

View File

@ -108,20 +108,13 @@ void lovrDestroy(int exitCode) {
#ifdef EMSCRIPTEN
#include <emscripten.h>
static int stepRef = 0;
static void emscriptenLoop(void* arg) {
lua_State* L = arg;
// lovr.step
lua_getglobal(L, "lovr");
if (lua_isnil(L, -1)) {
return;
}
lua_getfield(L, -1, "step");
if (lua_isnil(L, -1)) {
return;
}
lua_rawgeti(L, LUA_REGISTRYINDEX, stepRef);
lua_call(L, 0, 0);
}
@ -133,7 +126,12 @@ void lovrRun(lua_State* L) {
lua_getfield(L, -1, "load");
if (!lua_isnil(L, -1)) {
lua_call(L, 0, 0);
} else {
lua_pop(L, 1);
}
lua_getfield(L, -1, "step");
stepRef = luaL_ref(L, LUA_REGISTRYINDEX);
}
emscripten_set_main_loop_arg(emscriptenLoop, (void*) L, 0, 1);