Fix the magicleap app to work in LuminOS 0.96

This commit is contained in:
Alan Jeffrey 2019-06-06 12:34:52 -05:00
parent 412d35ae57
commit d877ca1d3a
1 changed files with 31 additions and 18 deletions

View File

@ -126,22 +126,22 @@ graphics_context_t::~graphics_context_t() {
} }
// Callbacks // Callbacks
static void onStop(void* app) static void onStop(void* app_handle)
{ {
ML_LOG(Info, "%s: On stop called.", application_name); ML_LOG(Info, "%s: On stop called.", application_name);
} }
static void onPause(void* app) static void onPause(void* app_handle)
{ {
ML_LOG(Info, "%s: On pause called.", application_name); ML_LOG(Info, "%s: On pause called.", application_name);
} }
static void onResume(void* app) static void onResume(void* app_handle)
{ {
ML_LOG(Info, "%s: On resume called.", application_name); ML_LOG(Info, "%s: On resume called.", application_name);
} }
static void onNewInitArg(void* app) static void onNewInitArg(void* app_handle)
{ {
ML_LOG(Info, "%s: On new init arg called.", application_name); ML_LOG(Info, "%s: On new init arg called.", application_name);
@ -188,6 +188,16 @@ static void onNewInitArg(void* app)
} }
// Tell pathfinder to load the file // Tell pathfinder to load the file
if (!app_handle) {
ML_LOG(Error, "%s: Init arg set before app is initialized.", application_name);
return;
}
void* app = *((void**)app_handle);
if (!app) {
ML_LOG(Error, "%s: Init arg set before app is initialized.", application_name);
return;
}
magicleap_pathfinder_demo_load(app, file_name); magicleap_pathfinder_demo_load(app, file_name);
MLLifecycleFreeInitArgList(&arg_list); MLLifecycleFreeInitArgList(&arg_list);
} }
@ -202,6 +212,21 @@ int main() {
// set up host-specific graphics surface // set up host-specific graphics surface
graphics_context_t graphics_context; graphics_context_t graphics_context;
// the app will go here once it's initialized
void* app = nullptr;
// let system know our app has started
MLLifecycleCallbacks lifecycle_callbacks = {};
lifecycle_callbacks.on_stop = onStop;
lifecycle_callbacks.on_pause = onPause;
lifecycle_callbacks.on_resume = onResume;
lifecycle_callbacks.on_new_initarg = onNewInitArg;
if (MLResult_Ok != MLLifecycleInit(&lifecycle_callbacks, &app)) {
ML_LOG(Error, "%s: Failed to initialize lifecycle.", application_name);
return -1;
}
// Check privileges // Check privileges
if (MLResult_Ok != MLPrivilegesStartup()) { if (MLResult_Ok != MLPrivilegesStartup()) {
ML_LOG(Error, "%s: Failed to initialize privileges.", application_name); ML_LOG(Error, "%s: Failed to initialize privileges.", application_name);
@ -229,25 +254,13 @@ int main() {
// Initialize pathfinder // Initialize pathfinder
ML_LOG(Info, "%s: Initializing demo.", application_name); ML_LOG(Info, "%s: Initializing demo.", application_name);
void* app = magicleap_pathfinder_demo_init(graphics_context.egl_display, graphics_context.egl_context); app = magicleap_pathfinder_demo_init(graphics_context.egl_display, graphics_context.egl_context);
if (!app) { if (!app) {
ML_LOG(Error, "%s: Failed to initialize demo.", application_name); ML_LOG(Error, "%s: Failed to initialize demo.", application_name);
} }
// let system know our app has started
MLLifecycleCallbacks lifecycle_callbacks = {};
lifecycle_callbacks.on_stop = onStop;
lifecycle_callbacks.on_pause = onPause;
lifecycle_callbacks.on_resume = onResume;
lifecycle_callbacks.on_new_initarg = onNewInitArg;
if (MLResult_Ok != MLLifecycleInit(&lifecycle_callbacks, app)) {
ML_LOG(Error, "%s: Failed to initialize lifecycle.", application_name);
return -1;
}
// Get the initial argument if there is one. // Get the initial argument if there is one.
onNewInitArg(app); onNewInitArg(&app);
// Run the demo! // Run the demo!
ML_LOG(Info, "%s: Begin demo.", application_name); ML_LOG(Info, "%s: Begin demo.", application_name);