From ff633eb2c8e774608d117b3a8e5e7f64dfaeeffa Mon Sep 17 00:00:00 2001 From: omigamedev Date: Wed, 30 Jan 2019 23:40:15 +0100 Subject: [PATCH] add mutex to App::update, move custom app-glue to git submodule --- .gitmodules | 3 +++ android/CMakeLists.txt | 6 +++--- libs/native_app_glue | 1 + src/app.cpp | 27 +++++++++++++++++---------- src/app_cloud.cpp | 2 +- 5 files changed, 25 insertions(+), 14 deletions(-) create mode 160000 libs/native_app_glue diff --git a/.gitmodules b/.gitmodules index bf5b9e6..4449521 100644 --- a/.gitmodules +++ b/.gitmodules @@ -49,3 +49,6 @@ [submodule "libs/hash-library"] path = libs/hash-library url = https://github.com/stbrumme/hash-library +[submodule "libs/native_app_glue"] + path = libs/native_app_glue + url = https://bitbucket.org/omigamedev/native_app_glue.git diff --git a/android/CMakeLists.txt b/android/CMakeLists.txt index 930d09f..9039ce9 100644 --- a/android/CMakeLists.txt +++ b/android/CMakeLists.txt @@ -7,7 +7,7 @@ cmake_minimum_required(VERSION 3.4.1) # build native_app_glue as a static lib add_library( app-glue STATIC - ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c + ../libs/native_app_glue/android_native_app_glue.c ) # Specifies a library name, specifies whether the library is STATIC or @@ -94,7 +94,6 @@ add_library( ) target_include_directories(native-lib PRIVATE - ${ANDROID_NDK}/sources/android/native_app_glue src/main/cpp ../src ../libs/glm @@ -106,7 +105,8 @@ target_include_directories(native-lib PRIVATE ../libs/poly2tri/poly2tri ../libs/base64 ../libs/sqlite3 - ../libs/nanort + ../libs/nanort + ../libs/native_app_glue ) # add lib dependencies diff --git a/libs/native_app_glue b/libs/native_app_glue new file mode 160000 index 0000000..a8f8dba --- /dev/null +++ b/libs/native_app_glue @@ -0,0 +1 @@ +Subproject commit a8f8dba9ee702661bffae5479b6e409ac4ad8c60 diff --git a/src/app.cpp b/src/app.cpp index d7b5e7c..39ccf52 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -443,7 +443,11 @@ void App::async_end() void App::update(float dt) { + static std::mutex mutex; static float rec_timer = 0.f; + + // avoid multiple threads to update the scene + std::lock_guard lock(mutex); static std::mutex m; std::lock_guard _lock(m); @@ -511,16 +515,19 @@ void App::update(float dt) } return false; }; - /* - uirtt.bindFramebuffer(); - uirtt.clear(); - glEnable(GL_SCISSOR_TEST); - for (int i = 1; i < layout[main_id]->m_children.size(); i++) - layout[main_id]->m_children[i]->watch(observer); - //msgbox->watch(observer); - glDisable(GL_SCISSOR_TEST); - uirtt.unbindFramebuffer(); - */ + + if (vr_active) + { + uirtt.bindFramebuffer(); + uirtt.clear(); + glEnable(GL_SCISSOR_TEST); + for (int i = 1; i < layout[main_id]->m_children.size(); i++) + layout[main_id]->m_children[i]->watch(observer); + //msgbox->watch(observer); + glDisable(GL_SCISSOR_TEST); + uirtt.unbindFramebuffer(); + } + #if __IOS__ [ios_view->glview bindDrawable]; #else diff --git a/src/app_cloud.cpp b/src/app_cloud.cpp index c2a3f91..574dbd6 100644 --- a/src/app_cloud.cpp +++ b/src/app_cloud.cpp @@ -53,7 +53,7 @@ void App::cloud_upload() auto m = layout[main_id]->add_child(); m->m_title->set_text("Publish document"); - m->m_message->set_text("Would you like to upload this document to the public domain?"); + m->m_message->set_text("Would you like to upload to the public domain?"); m->btn_ok->m_text->set_text("Yes"); m->btn_cancel->m_text->set_text("No"); m->btn_ok->on_click = [this, m, upload_thread](Node*) {