fix quest vr threading

This commit is contained in:
2019-08-01 18:22:31 +02:00
parent 945028f171
commit 32667b709e
5 changed files with 51 additions and 43 deletions

View File

@@ -383,11 +383,21 @@ static void engine_vr_loop()
LOG("hmd renderer terminated");
}
static void engine_start_vr()
static void engine_start_vr_thread()
{
std::thread(engine_vr_loop).detach();
}
static void engine_start_vr_mode()
{
#ifdef __QUEST__
LOG("QUEST init VR");
oculus_init_vr(g_engine.display, g_engine.context, g_engine.app->window);
#elif __FOCUS__
wave_init_vr(g_engine.display, g_engine.context, g_engine.app->window);
#endif
}
/**
* Initialize an EGL context for the current display.
*/
@@ -569,14 +579,6 @@ static int engine_init_display(struct engine* engine) {
g_display = display;
g_context = context;
#ifdef __QUEST__
App::I->render_thread_id = std::this_thread::get_id();
LOG("QUEST init VR");
oculus_init_vr(display, context, engine->app->window);
#elif __FOCUS__
wave_init_vr(display, context, engine->app->window);
#endif
if (resuming_context)
{
LOG("RESUME APP");
@@ -584,6 +586,7 @@ static int engine_init_display(struct engine* engine) {
LOG("release egl context");
eglMakeCurrent(engine->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
mutex.unlock();
engine_start_vr_mode();
return 0;
}
@@ -702,12 +705,13 @@ static int engine_init_display(struct engine* engine) {
LOG("start render threads");
App::I->render_thread_start();
LOG("start ui thread");
App::I->ui_thread_start();
App::I->ui_sync();
LOG("start vr thread");
engine_start_vr();
engine_start_vr_mode();
engine_start_vr_thread();
#else
float density = get_display_density();
LOG("density %f", density);