Skip to content

Commit 9a3fec1

Browse files
committed
Android/Monado example
1 parent 38616e2 commit 9a3fec1

File tree

10 files changed

+214
-217
lines changed

10 files changed

+214
-217
lines changed

examples/android-monado/README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,37 @@ Build Requirements:
66
* Android Studio
77
* Android SDK API Level 24
88
* Android NDK 25
9-
* TODO: Monado setup details
9+
* Android device with Monado OpenXR runtime installed
10+
11+
Quirks / Issues:
12+
* If ANDROID_STL=C++_static the OpenXR runtime will not load correctly. The runtime could be rebuilt with a static STL, but the simpler option is to use c++_shared in the vsgvr application
13+
* Monado on Android is currently targetted at cardboard-like HMDs - Configuring as a single-screen handheld display is not currently possible
14+
* When starting the application, ensure phone is held horizontally - Tracking is relative to the starting position
15+
* Performance will likely be quite low
16+
17+
Project / Gradle requirements
18+
* C++ settings for vsgvr
19+
* `implementation 'org.khronos.openxr:openxr_loader_for_android:1.0.23'`
20+
21+
## Installing Monado
22+
23+
Firstly, build and install the monado runtime from https://gitlab.freedesktop.org/monado/monado
24+
* Clone the repo
25+
* Open the repo in Android Studio
26+
* Build and install the runtime APK
27+
28+
Also build and install the monado broker application from https://gitlab.freedesktop.org/monado/utilities/openxr-android-broker
29+
* Clone the repo
30+
* Open the repo in Android Studio
31+
* Build and install the APK for `installable_runtime_broker`
32+
33+
On the phone, configure the runtime
34+
* Open the app `OpenXR Runtime Broker`
35+
* Ensure the Monado runtime is selected
36+
37+
The device should now have an OpenXR runtime, and vsgvr applications built with the following settings should function:
38+
* VSGVR_XR_PLATFORM=OPENXR_GENERIC
39+
* ANDROID_STL=c++_shared
1040

1141
## Build Configuration
1242

examples/android-monado/app/AndroidManifest.xml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,23 @@
2020
android:label="@string/app_name"
2121
android:hasCode="false">
2222

23-
<meta-data android:name="com.oculus.intent.category.VR" android:value="vr_only"/>
24-
<meta-data android:name="com.oculus.supportedDevices" android:value="quest|quest2|cambria"/>
25-
2623
<!-- Our activity is the built-in NativeActivity framework class.
2724
This will take care of integrating with our NDK code. -->
2825
<activity android:name="android.app.NativeActivity"
2926
android:label="@string/app_name"
3027
android:launchMode="singleTask"
3128
android:resizeableActivity="false"
32-
android:screenOrientation="portrait"
29+
android:screenOrientation="landscape"
3330
android:configChanges="density|keyboard|keyboardHidden|navigation|orientation|screenLayout|screenSize|uiMode"
34-
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
31+
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
32+
android:exported="true">
3533
<!-- Tell NativeActivity the name of our .so -->
36-
<meta-data android:name="android.app.lib_name" android:value="vsgvrquestnative" />
34+
<meta-data android:name="android.app.lib_name" android:value="vsgvrnative" />
3735
<intent-filter>
3836
<action android:name="android.intent.action.MAIN" />
39-
<category android:name="com.oculus.intent.category.VR" />
4037
<category android:name="android.intent.category.LAUNCHER" />
4138
</intent-filter>
4239
</activity>
4340
</application>
44-
45-
<uses-feature android:name="android.hardware.vr.headtracking" android:required="true" android:version="1" />
4641
</manifest>
4742
<!-- END_INCLUDE(manifest) -->

examples/android-monado/app/build.gradle

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ android {
66
defaultConfig {
77
applicationId = 'com.vsgvr.vsgvrandroidmonado'
88
minSdkVersion 27
9-
targetSdkVersion 27
9+
targetSdkVersion 31
1010
externalNativeBuild {
1111
cmake {
1212
arguments '-DANDROID_STL=c++_shared', '-DVSGVR_XR_PLATFORM=OPENXR_GENERIC'
@@ -47,6 +47,7 @@ android {
4747

4848
dependencies {
4949
implementation fileTree(dir: 'libs', include: ['*.jar'])
50-
implementation 'com.android.support:appcompat-v7:28.0.0'
51-
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
50+
implementation 'androidx.appcompat:appcompat:1.0.0'
51+
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
52+
implementation 'org.khronos.openxr:openxr_loader_for_android:1.0.23'
5253
}

examples/android-monado/app/cpp/CMakeLists.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.13.0)
22

3-
project(vsgvrquestnative)
3+
project(vsgvrnative)
44

55
# build native_app_glue as a static lib
66
set(${CMAKE_C_FLAGS}, "${CMAKE_C_FLAGS}")
@@ -11,8 +11,9 @@ add_library(native_app_glue STATIC
1111
set(CMAKE_CXX_STANDARD 17)
1212
set(CMAKE_CXX_VISIBILITY_PRESET default)
1313

14-
# To prevent errors when loading the native activity, ensure library name is the same in debug builds
14+
# To prevent errors when loading the native activity, ensure library name is the same in all builds
1515
set(CMAKE_DEBUG_POSTFIX "")
16+
set(CMAKE_RELWITHDEBINFO_POSTFIX "")
1617

1718
# find vsg
1819
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../../../../../VulkanSceneGraph" vsg)
@@ -24,16 +25,16 @@ set(CMAKE_SHARED_LINKER_FLAGS
2425
"${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate")
2526

2627
# add vsgnative target
27-
add_library(vsgvrquestnative SHARED main.cpp)
28+
add_library(vsgvrnative SHARED main.cpp)
2829

2930
# add the app glue include directory
30-
target_include_directories(vsgvrquestnative PRIVATE
31+
target_include_directories(vsgvrnative PRIVATE
3132
${ANDROID_NDK}/sources/android/native_app_glue
3233
${CMAKE_CURRENT_SOURCE_DIR}/../../vsgvr/include
3334
)
3435

3536
# add lib dependencies
36-
target_link_libraries(vsgvrquestnative
37+
target_link_libraries(vsgvrnative
3738
vsg::vsg vsgvr
3839
android
3940
native_app_glue

0 commit comments

Comments
 (0)