Fix wasm build.........;

This commit is contained in:
bjorn 2018-11-16 07:36:44 -08:00
parent 6168ec243f
commit e5dd0a2c17
1 changed files with 43 additions and 43 deletions

View File

@ -15,6 +15,49 @@ int main(int argc, char** argv);
#ifndef LOVR_USE_OCULUS_MOBILE
#ifdef EMSCRIPTEN
#include <emscripten.h>
typedef struct {
lua_State* L;
lua_State* T;
int argc;
char** argv;
} lovrEmscriptenContext;
void lovrDestroy(void* arg) {
lovrEmscriptenContext* context = arg;
lua_State* L = context->L;
emscripten_cancel_main_loop();
lua_close(L);
}
static void emscriptenLoop(void* arg) {
lovrEmscriptenContext* context = arg;
lua_getglobal(context->L, "_lovrHeadsetRenderError"); // webvr.c renderCallback failed
bool haveRenderError = !lua_isnil(context->L, -1);
if (!haveRenderError) {
lua_pop(context->L, 1);
}
int coroutineArgs = luax_pushLovrHeadsetRenderError(context->T);
if (lua_resume(context->T, coroutineArgs) != LUA_YIELD) {
bool restart = lua_type(context->T, -1) == LUA_TSTRING && !strcmp(lua_tostring(context->T, -1), "restart");
int status = lua_tonumber(context->T, -1);
lua_close(context->L);
emscripten_cancel_main_loop();
if (restart) {
main(context->argc, context->argv);
} else {
lovrPlatformDestroy();
exit(status);
}
}
}
#endif
int main(int argc, char** argv) {
if (argc > 1 && (!strcmp(argv[1], "--version") || !strcmp(argv[1], "-v"))) {
lovrLog("LOVR %d.%d.%d (%s)\n", LOVR_VERSION_MAJOR, LOVR_VERSION_MINOR, LOVR_VERSION_PATCH, LOVR_VERSION_ALIAS);
@ -59,49 +102,6 @@ int main(int argc, char** argv) {
#endif
#ifdef EMSCRIPTEN
#include <emscripten.h>
typedef struct {
lua_State* L;
lua_State* T;
int argc;
char** argv;
} lovrEmscriptenContext;
void lovrDestroy(void* arg) {
lovrEmscriptenContext* context = arg;
lua_State* L = context->L;
emscripten_cancel_main_loop();
lua_close(L);
}
static void emscriptenLoop(void* arg) {
lovrEmscriptenContext* context = arg;
lua_getglobal(context->L, "_lovrHeadsetRenderError"); // webvr.c renderCallback failed
bool haveRenderError = !lua_isnil(context->L, -1);
if (!haveRenderError) {
lua_pop(context->L, 1);
}
int coroutineArgs = luax_pushLovrHeadsetRenderError(context->T);
if (lua_resume(context->T, coroutineArgs) != LUA_YIELD) {
bool restart = lua_type(context->T, -1) == LUA_TSTRING && !strcmp(lua_tostring(context->T, -1), "restart");
int status = lua_tonumber(context->T, -1);
lua_close(context->L);
emscripten_cancel_main_loop();
if (restart) {
main(context->argc, context->argv);
} else {
lovrPlatformDestroy();
exit(status);
}
}
}
#endif
typedef enum { // What flag is being searched for?
ARGFLAG_NONE, // Not processing a flag
ARGFLAG_ROOT