diff --git a/.gitmodules b/.gitmodules index c389aad..6d14617 100644 --- a/.gitmodules +++ b/.gitmodules @@ -52,3 +52,6 @@ [submodule "libs/ovr_mobile"] path = libs/ovr_mobile url = https://bitbucket.org/omigamedev/ovr_mobile.git +[submodule "libs/ovr_platform"] + path = libs/ovr_platform + url = https://bitbucket.org/omigamedev/ovr_platform.git diff --git a/android/quest/CMakeLists.txt b/android/quest/CMakeLists.txt index e6ee6ab..4507ee7 100644 --- a/android/quest/CMakeLists.txt +++ b/android/quest/CMakeLists.txt @@ -17,6 +17,13 @@ set_target_properties( ${CMAKE_SOURCE_DIR}/../../libs/ovr_mobile/lib/${ANDROID_ABI}/libvrapi.so ) +add_library(ovrplatformloader SHARED IMPORTED) +set_target_properties( + ovrplatformloader + PROPERTIES IMPORTED_LOCATION + ${CMAKE_SOURCE_DIR}/../../libs/ovr_platform/Android/libs/${ANDROID_ABI}/libovrplatformloader.so +) + # Specifies a library name, specifies whether the library is STATIC or # SHARED, and provides relative paths to the source code. You can @@ -121,6 +128,7 @@ add_library( target_include_directories(native-lib PRIVATE ../../libs/ovr_mobile/include + ../../libs/ovr_platform/Include src/main/cpp ../src/cpp ../../src @@ -143,6 +151,7 @@ target_include_directories(native-lib PRIVATE target_link_libraries( native-lib vrapi + ovrplatformloader android app-glue ${CMAKE_SOURCE_DIR}/../../libs/curl-android-ios/android/${ANDROID_ABI}/libcurl.a diff --git a/android/quest/build.gradle b/android/quest/build.gradle index 64e9cf8..5f3d9bc 100644 --- a/android/quest/build.gradle +++ b/android/quest/build.gradle @@ -69,7 +69,7 @@ android { defaultConfig { applicationId = 'com.omixlab.panopainter' - minSdkVersion 19 + minSdkVersion 21 targetSdkVersion 26 versionCode ver_count versionName "${ver_tag}.${ver_count}" @@ -139,7 +139,7 @@ android { main { manifest.srcFile 'src/main/AndroidManifest.xml' java.srcDirs = ['../src/java', 'src/main/java'] - jniLibs.srcDirs = ['../../libs/ovr_mobile/lib'] + jniLibs.srcDirs = ['../../libs/ovr_mobile/lib', '../../libs/ovr_platform/Android/libs'] res.srcDirs = ['../src/res'] //assets.srcDirs = ['../../assets'] } diff --git a/android/quest/src/main/AndroidManifest.xml b/android/quest/src/main/AndroidManifest.xml index ab712d5..7f57ae9 100644 --- a/android/quest/src/main/AndroidManifest.xml +++ b/android/quest/src/main/AndroidManifest.xml @@ -1,28 +1,32 @@ + package="com.omixlab.panopainter" + android:installLocation="auto"> + - + android:icon="@mipmap/ic_launcher" + android:allowBackup="false"> + + android:label="@string/app_name" + android:launchMode="singleTask" + android:configChanges="screenSize|screenLayout|orientation|keyboardHidden|keyboard|navigation|uiMode" + android:excludeFromRecents="true" + android:screenOrientation="landscape"> + android:value="native-lib" /> - + diff --git a/android/quest/src/main/cpp/oculus_vr.cpp b/android/quest/src/main/cpp/oculus_vr.cpp index c236b1c..1456f7f 100644 --- a/android/quest/src/main/cpp/oculus_vr.cpp +++ b/android/quest/src/main/cpp/oculus_vr.cpp @@ -91,6 +91,8 @@ void oculus_init(JavaVM* vm, JNIEnv* jni, jobject activity_class) // If intialization failed, vrapi_* function calls will not be available. exit( 0 ); } + auto result = ovr_PlatformInitializeAndroid("1687982804637910", activity_class, jni); + LOG("ovr_PlatformInitializeAndroid result %d", result); } void oculus_init_vr(EGLDisplay display, EGLContext context, ANativeWindow* surface) @@ -106,16 +108,17 @@ void oculus_init_vr(EGLDisplay display, EGLContext context, ANativeWindow* surfa for (int i = 0; i < swap_chain_count; i++) { auto texid = vrapi_GetTextureSwapChainHandle(swap_chain[eye], i); - if (!ovr_eyes[i][eye].create(rtt_w, rtt_h, texid, GL_RGBA8, true)) + if (ovr_eyes[i][eye].create(rtt_w, rtt_h, texid, GL_RGBA8, true)) { - ovr_eyes[i][eye].bindFramebuffer(); - ovr_eyes[i][eye].clear({1, 0, 1, 1}); - ovr_eyes[i][eye].unbindFramebuffer(); - LOG("FAILED create fb for eye %d", eye); + ovr_eyes[i][eye].bindTexture(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + ovr_eyes[i][eye].unbindTexture(); + LOG("create eye %d", eye); } else { - LOG("create eye %d", eye); + LOG("FAILED create fb for eye %d", eye); } } } diff --git a/android/quest/src/main/cpp/oculus_vr.h b/android/quest/src/main/cpp/oculus_vr.h index a22f979..6f6ab84 100644 --- a/android/quest/src/main/cpp/oculus_vr.h +++ b/android/quest/src/main/cpp/oculus_vr.h @@ -6,6 +6,11 @@ #include #include +#include +#include +#include +#include + #include #include #include diff --git a/android/quest/src/main/java/com/omixlab/panopainter/Platform.java b/android/quest/src/main/java/com/omixlab/panopainter/Platform.java index 8b69b47..5b82f21 100644 --- a/android/quest/src/main/java/com/omixlab/panopainter/Platform.java +++ b/android/quest/src/main/java/com/omixlab/panopainter/Platform.java @@ -1,5 +1,5 @@ package com.omixlab.panopainter; public class Platform { - public static final String[] Libs = new String[]{"vrapi"}; + public static final String[] Libs = new String[]{"vrapi", "ovrplatformloader"}; } diff --git a/libs/ovr_platform b/libs/ovr_platform new file mode 160000 index 0000000..8ef1425 --- /dev/null +++ b/libs/ovr_platform @@ -0,0 +1 @@ +Subproject commit 8ef1425ee27ea7c668dd851f46f3092ab37a9fb1 diff --git a/src/app_dialogs.cpp b/src/app_dialogs.cpp index 953561d..365d350 100644 --- a/src/app_dialogs.cpp +++ b/src/app_dialogs.cpp @@ -9,6 +9,10 @@ #include "node_changelog.h" #include "node_usermanual.h" +#ifdef __QUEST__ +#include "oculus_vr.h" +#endif + std::shared_ptr App::show_progress(const std::string& title) { auto pb = std::make_shared(); @@ -426,13 +430,16 @@ void App::dialog_export(std::string ext) if (canvas) { // TODO: use picker - canvas->m_canvas->export_equirectangular(work_path + "/" + doc_name + ext, [this]{ + auto path = work_path + "/" + doc_name + ext; + canvas->m_canvas->export_equirectangular(path, [this, path]{ #if defined(__IOS__) message_box("Export Equirectangular", "Image exported to Photos"); #elif defined(__OSX__) message_box("Export Equirectangular", "Image exported to Pictures/PanoPainter folder"); #elif defined(_WIN32) message_box("Export Equirectangular", "Image exported to " + work_path); +#elif defined(__QUEST__) + //auto result = ovr_Media_ShareToFacebook("Sharing from PanoPainter on Oculus Quest", path.c_str(), ovrMediaContentType_Photo); #endif }); } diff --git a/src/app_vr.cpp b/src/app_vr.cpp index 7c85858..2bb60d9 100644 --- a/src/app_vr.cpp +++ b/src/app_vr.cpp @@ -139,7 +139,7 @@ void App::vr_analog(const VRController& c, VRController::kButton b, VRController void App::vr_digital(const VRController& c, VRController::kButton b, VRController::kAction a, glm::vec2 axis) { - if (b == VRController::kButton::Pad && a == VRController::kAction::Press) + if (b == VRController::kButton::A && a == VRController::kAction::Press) { if (glm::length(axis) < 0.5f) { @@ -326,7 +326,9 @@ void App::vr_draw(const glm::mat4& proj, const glm::mat4& camera, const glm::mat m_face_plane.draw_stroke(); } + glDisable(GL_DEPTH_TEST); // draw the brush + /* auto mode = dynamic_cast(canvas->m_canvas->modes[(int)canvas->m_canvas->m_current_mode][0]); if (ui_visible && ui_inside && mode) { @@ -357,6 +359,7 @@ void App::vr_draw(const glm::mat4& proj, const glm::mat4& camera, const glm::mat m_face_plane.draw_fill(); tex.unbind(); } + */ // draw the 2D UI if (ui_visible) @@ -431,6 +434,7 @@ void App::vr_draw(const glm::mat4& proj, const glm::mat4& camera, const glm::mat glm::mat4 ortho_proj(1); +/* for (auto& mode : *canvas->m_canvas->m_mode) mode->on_Draw(ortho_proj, proj, camera); @@ -445,6 +449,7 @@ void App::vr_draw(const glm::mat4& proj, const glm::mat4& camera, const glm::mat if (canvas->m_canvas->m_current_mode != kCanvasMode::Grid) for (auto& mode : Canvas::modes[(int)kCanvasMode::Grid]) mode->on_Draw(ortho_proj, proj, camera); +*/ blend ? glEnable(GL_BLEND) : glDisable(GL_BLEND); depth ? glEnable(GL_DEPTH_TEST) : glDisable(GL_DEPTH_TEST);