add ovr platform sdk and test photo sharing

This commit is contained in:
2019-06-02 23:28:27 +02:00
parent d8a1a99d04
commit 2d43b74956
10 changed files with 59 additions and 22 deletions

3
.gitmodules vendored
View File

@@ -52,3 +52,6 @@
[submodule "libs/ovr_mobile"] [submodule "libs/ovr_mobile"]
path = libs/ovr_mobile path = libs/ovr_mobile
url = https://bitbucket.org/omigamedev/ovr_mobile.git url = https://bitbucket.org/omigamedev/ovr_mobile.git
[submodule "libs/ovr_platform"]
path = libs/ovr_platform
url = https://bitbucket.org/omigamedev/ovr_platform.git

View File

@@ -17,6 +17,13 @@ set_target_properties(
${CMAKE_SOURCE_DIR}/../../libs/ovr_mobile/lib/${ANDROID_ABI}/libvrapi.so ${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 # Specifies a library name, specifies whether the library is STATIC or
# SHARED, and provides relative paths to the source code. You can # SHARED, and provides relative paths to the source code. You can
@@ -121,6 +128,7 @@ add_library(
target_include_directories(native-lib PRIVATE target_include_directories(native-lib PRIVATE
../../libs/ovr_mobile/include ../../libs/ovr_mobile/include
../../libs/ovr_platform/Include
src/main/cpp src/main/cpp
../src/cpp ../src/cpp
../../src ../../src
@@ -143,6 +151,7 @@ target_include_directories(native-lib PRIVATE
target_link_libraries( target_link_libraries(
native-lib native-lib
vrapi vrapi
ovrplatformloader
android android
app-glue app-glue
${CMAKE_SOURCE_DIR}/../../libs/curl-android-ios/android/${ANDROID_ABI}/libcurl.a ${CMAKE_SOURCE_DIR}/../../libs/curl-android-ios/android/${ANDROID_ABI}/libcurl.a

View File

@@ -69,7 +69,7 @@ android {
defaultConfig { defaultConfig {
applicationId = 'com.omixlab.panopainter' applicationId = 'com.omixlab.panopainter'
minSdkVersion 19 minSdkVersion 21
targetSdkVersion 26 targetSdkVersion 26
versionCode ver_count versionCode ver_count
versionName "${ver_tag}.${ver_count}" versionName "${ver_tag}.${ver_count}"
@@ -139,7 +139,7 @@ android {
main { main {
manifest.srcFile 'src/main/AndroidManifest.xml' manifest.srcFile 'src/main/AndroidManifest.xml'
java.srcDirs = ['../src/java', 'src/main/java'] 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'] res.srcDirs = ['../src/res']
//assets.srcDirs = ['../../assets'] //assets.srcDirs = ['../../assets']
} }

View File

@@ -1,28 +1,32 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.omixlab.panopainter"> package="com.omixlab.panopainter"
android:installLocation="auto">
<!-- Tell the system this app requires OpenGL ES 3.1. --> <!-- Tell the system this app requires OpenGL ES 3.1. -->
<uses-feature android:glEsVersion="0x00030001" android:required="true"/> <uses-feature android:glEsVersion="0x00030001" android:required="true"/>
<uses-feature android:name="android.hardware.vr.headtracking"
android:version="1" android:required="false"/>
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application android:label="@string/app_name" <application android:label="@string/app_name"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:allowBackup="false" android:allowBackup="false">
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"> <meta-data android:name="com.samsung.android.vr.application.mode"
<meta-data android:name="com.samsung.android.vr.application.mode" android:value="vr_only"/> android:value="vr_only"/>
<activity android:name=".MainActivity" <activity android:name=".MainActivity"
android:label="@string/app_name" android:label="@string/app_name"
android:launchMode="singleTask" android:launchMode="singleTask"
android:configChanges="screenSize|screenLayout|orientation|keyboardHidden|keyboard|navigation|uiMode" android:configChanges="screenSize|screenLayout|orientation|keyboardHidden|keyboard|navigation|uiMode"
android:screenOrientation="landscape"> android:excludeFromRecents="true"
android:screenOrientation="landscape">
<meta-data android:name="android.app.lib_name" <meta-data android:name="android.app.lib_name"
android:value="native-lib" /> android:value="native-lib" />
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.INFO" />
</intent-filter> </intent-filter>
</activity> </activity>
</application> </application>

View File

@@ -91,6 +91,8 @@ void oculus_init(JavaVM* vm, JNIEnv* jni, jobject activity_class)
// If intialization failed, vrapi_* function calls will not be available. // If intialization failed, vrapi_* function calls will not be available.
exit( 0 ); 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) 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++) for (int i = 0; i < swap_chain_count; i++)
{ {
auto texid = vrapi_GetTextureSwapChainHandle(swap_chain[eye], 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].bindTexture();
ovr_eyes[i][eye].clear({1, 0, 1, 1}); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
ovr_eyes[i][eye].unbindFramebuffer(); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
LOG("FAILED create fb for eye %d", eye); ovr_eyes[i][eye].unbindTexture();
LOG("create eye %d", eye);
} }
else else
{ {
LOG("create eye %d", eye); LOG("FAILED create fb for eye %d", eye);
} }
} }
} }

View File

@@ -6,6 +6,11 @@
#include <VrApi_SystemUtils.h> #include <VrApi_SystemUtils.h>
#include <VrApi_Input.h> #include <VrApi_Input.h>
#include <OVR_Platform.h>
#include <OVR_PlatformInitialize.h>
#include <OVR_Requests_Media.h>
#include <OVR_Requests_Livestreaming.h>
#include <EGL/egl.h> #include <EGL/egl.h>
#include <EGL/eglext.h> #include <EGL/eglext.h>
#include <android/window.h> #include <android/window.h>

View File

@@ -1,5 +1,5 @@
package com.omixlab.panopainter; package com.omixlab.panopainter;
public class Platform { public class Platform {
public static final String[] Libs = new String[]{"vrapi"}; public static final String[] Libs = new String[]{"vrapi", "ovrplatformloader"};
} }

1
libs/ovr_platform Submodule

Submodule libs/ovr_platform added at 8ef1425ee2

View File

@@ -9,6 +9,10 @@
#include "node_changelog.h" #include "node_changelog.h"
#include "node_usermanual.h" #include "node_usermanual.h"
#ifdef __QUEST__
#include "oculus_vr.h"
#endif
std::shared_ptr<NodeProgressBar> App::show_progress(const std::string& title) std::shared_ptr<NodeProgressBar> App::show_progress(const std::string& title)
{ {
auto pb = std::make_shared<NodeProgressBar>(); auto pb = std::make_shared<NodeProgressBar>();
@@ -426,13 +430,16 @@ void App::dialog_export(std::string ext)
if (canvas) if (canvas)
{ {
// TODO: use picker // 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__) #if defined(__IOS__)
message_box("Export Equirectangular", "Image exported to Photos"); message_box("Export Equirectangular", "Image exported to Photos");
#elif defined(__OSX__) #elif defined(__OSX__)
message_box("Export Equirectangular", "Image exported to Pictures/PanoPainter folder"); message_box("Export Equirectangular", "Image exported to Pictures/PanoPainter folder");
#elif defined(_WIN32) #elif defined(_WIN32)
message_box("Export Equirectangular", "Image exported to " + work_path); 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 #endif
}); });
} }

View File

@@ -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) 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) 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(); m_face_plane.draw_stroke();
} }
glDisable(GL_DEPTH_TEST);
// draw the brush // draw the brush
/*
auto mode = dynamic_cast<CanvasModePen*>(canvas->m_canvas->modes[(int)canvas->m_canvas->m_current_mode][0]); auto mode = dynamic_cast<CanvasModePen*>(canvas->m_canvas->modes[(int)canvas->m_canvas->m_current_mode][0]);
if (ui_visible && ui_inside && mode) 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(); m_face_plane.draw_fill();
tex.unbind(); tex.unbind();
} }
*/
// draw the 2D UI // draw the 2D UI
if (ui_visible) 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); glm::mat4 ortho_proj(1);
/*
for (auto& mode : *canvas->m_canvas->m_mode) for (auto& mode : *canvas->m_canvas->m_mode)
mode->on_Draw(ortho_proj, proj, camera); 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) if (canvas->m_canvas->m_current_mode != kCanvasMode::Grid)
for (auto& mode : Canvas::modes[(int)kCanvasMode::Grid]) for (auto& mode : Canvas::modes[(int)kCanvasMode::Grid])
mode->on_Draw(ortho_proj, proj, camera); mode->on_Draw(ortho_proj, proj, camera);
*/
blend ? glEnable(GL_BLEND) : glDisable(GL_BLEND); blend ? glEnable(GL_BLEND) : glDisable(GL_BLEND);
depth ? glEnable(GL_DEPTH_TEST) : glDisable(GL_DEPTH_TEST); depth ? glEnable(GL_DEPTH_TEST) : glDisable(GL_DEPTH_TEST);