Fix wasm build;

This commit is contained in:
bjorn 2018-11-15 08:21:26 -08:00
parent 1ce7e49df5
commit da92cce634
3 changed files with 16 additions and 16 deletions

View File

@ -44,11 +44,12 @@ if(EMSCRIPTEN)
"-s USE_WEBGL2=1 "
"-s GL_PREINITIALIZED_CONTEXT=1 "
"-s USE_ZLIB=1 "
"-s USE_PTHREADS=0 "
"-s FULL_ES3=1 "
"-s FORCE_FILESYSTEM=1 "
"-s ALLOW_MEMORY_GROWTH=1 "
"-s \"EXPORTED_FUNCTIONS=[ "
"'_main','_lovrRun','_lovrQuit',"
"'_main','_lovrDestroy',"
"'_mat4_identity','_mat4_invert','_mat4_multiply','_mat4_rotateQuat','_mat4_transform','_mat4_transformDirection','_mat4_translate',"
"'_quat_fromMat4','_quat_getAngleAxis'"
"]\" "
@ -63,6 +64,7 @@ if(EMSCRIPTEN)
set(LOVR_USE_OPENVR OFF)
set(LOVR_USE_OCULUS OFF)
set(LOVR_USE_SSE OFF)
set(LOVR_ENABLE_THREAD OFF)
elseif(ANDROID)
#set(LOVR_ANDROID_FLAGS "-Wno-narrowing")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LOVR_ANDROID_FLAGS}")

View File

@ -10,8 +10,8 @@ extern void webvrDestroy(void);
extern HeadsetType webvrGetType(void);
extern HeadsetOrigin webvrGetOriginType(void);
extern bool webvrIsMounted(void);
extern bool webvrIsMirrored(void);
extern void webvrSetMirrored(bool mirror);
extern void webvrIsMirrored(bool* mirror, HeadsetEye* eye);
extern void webvrSetMirrored(bool mirror, HeadsetEye eye);
extern void webvrGetDisplayDimensions(uint32_t* width, uint32_t* height);
extern void webvrGetClipDistance(float* near, float* far);
extern void webvrSetClipDistance(float near, float far);

View File

@ -1,6 +1,3 @@
#ifdef LOVR_ENABLE_EVENT
#include "event/event.h"
#endif
#include "resources/boot.lua.h"
#include "lib/glfw.h"
#include "version.h"
@ -15,6 +12,7 @@
lua_State* lovrInit(lua_State* L, int argc, char** argv);
void lovrQuit(int status);
int main(int argc, char** argv);
#ifndef LOVR_USE_OCULUS_MOBILE
@ -71,13 +69,19 @@ typedef struct {
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(L, "_lovrHeadsetRenderError"); // webvr.c renderCallback failed
bool haveRenderError = !lua_isnil(L, -1);
lua_getglobal(context->L, "_lovrHeadsetRenderError"); // webvr.c renderCallback failed
bool haveRenderError = !lua_isnil(context->L, -1);
if (!haveRenderError) {
lua_pop(L, 1);
lua_pop(context->L, 1);
}
int coroutineArgs = luax_pushLovrHeadsetRenderError(context->T);
@ -183,9 +187,3 @@ lua_State* lovrInit(lua_State* L, int argc, char** argv) {
lua_xmove(L, T, 1);
return T;
}
void lovrQuit(int status) {
#ifdef LOVR_ENABLE_EVENT
lovrEventPush((Event) { .type = EVENT_QUIT, .data.quit = { false, status } });
#endif
}