quest, not finished
This commit is contained in:
@@ -3,4 +3,10 @@
|
|||||||
An in-progress crate for adding openxr support to Bevy without forking.
|
An in-progress crate for adding openxr support to Bevy without forking.
|
||||||

|

|
||||||
|
|
||||||
To see it in action run the example in `examples` with `cargo run --example xr`
|
To see it in action run the example in `examples` with `cargo run --example xr`.
|
||||||
|
|
||||||
|
## Quest
|
||||||
|
Running on quest can be done with https://github.com/rust-mobile/cargo-apk and requires disabling default features.
|
||||||
|
```sh
|
||||||
|
cargo apk run --example xr --release --no-default-features
|
||||||
|
```
|
||||||
|
|||||||
89
examples/android/Cargo.toml
Normal file
89
examples/android/Cargo.toml
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
# [package]
|
||||||
|
name = "bevy_openxr_android"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
description = "Example for building an Android OpenXR app with Bevy"
|
||||||
|
publish = false
|
||||||
|
license = "MIT OR Apache-2.0"
|
||||||
|
|
||||||
|
# [lib]
|
||||||
|
# name = "bevy_mobile_example"
|
||||||
|
# crate-type = ["staticlib", "cdylib"]
|
||||||
|
|
||||||
|
# [dependencies]
|
||||||
|
# bevy = { path = "../../" }
|
||||||
|
|
||||||
|
# [package.metadata.android]
|
||||||
|
# package = "org.bevyengine.example"
|
||||||
|
# apk_name = "bevyexample"
|
||||||
|
# assets = "../../assets"
|
||||||
|
# resources = "../../assets/android-res"
|
||||||
|
# # This strips debug symbols from the shared libraries, drastically reducing APK size. If you need them, remove the option.
|
||||||
|
# strip = "strip"
|
||||||
|
# build_targets = ["aarch64-linux-android", "armv7-linux-androideabi"]
|
||||||
|
|
||||||
|
[package.metadata.android]
|
||||||
|
package = "com.github.alexichepura.bevyopenxr"
|
||||||
|
build_targets = ["aarch64-linux-android"]
|
||||||
|
runtime_libs = "examples/libs"
|
||||||
|
apk_name = "bevyopenxr"
|
||||||
|
assets = "assets"
|
||||||
|
res = "assets/android-res"
|
||||||
|
icon = "@mipmap/ic_launcher"
|
||||||
|
label = "Bevy Openxr"
|
||||||
|
|
||||||
|
[package.metadata.android.sdk]
|
||||||
|
target_sdk_version = 32
|
||||||
|
|
||||||
|
# [package.metadata.android.application]
|
||||||
|
# icon = "@mipmap/ic_launcher"
|
||||||
|
# label = "Bevy Example"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
anyhow = "1.0.75"
|
||||||
|
# ash = "0.37.3"
|
||||||
|
# ash = { version = "0.37", default-features = false, features = ["loaded"] }
|
||||||
|
bevy = { git = "https://github.com/bevyengine/bevy.git" }
|
||||||
|
openxr = { git = "https://github.com/Ralith/openxrs", features = ["mint"] }
|
||||||
|
mint = "0.5.9"
|
||||||
|
|
||||||
|
wgpu = "0.17.1"
|
||||||
|
wgpu-core = { version = "0.17.1", features = ["vulkan"] }
|
||||||
|
wgpu-hal = "0.17.2"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
color-eyre = "0.6.2"
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
lto = "fat"
|
||||||
|
codegen-units = 1
|
||||||
|
panic = "abort"
|
||||||
|
#debug = true
|
||||||
|
|
||||||
|
[package.metadata.android]
|
||||||
|
build_targets = ["aarch64-linux-android"]
|
||||||
|
runtime_libs = "examples/libs"
|
||||||
|
package = "com.github.alexichepura.bevyopenxr"
|
||||||
|
apk_name = "bevyopenxr"
|
||||||
|
assets = "assets"
|
||||||
|
res = "assets/android-res"
|
||||||
|
icon = "@mipmap/ic_launcher"
|
||||||
|
label = "Bevy Openxr"
|
||||||
|
|
||||||
|
[package.metadata.android.application.activity]
|
||||||
|
theme = "@android:style/Theme.Black.NoTitleBar.Fullscreen"
|
||||||
|
config_changes = "density|keyboard|keyboardHidden|navigation|orientation|screenLayout|screenSize|uiMode"
|
||||||
|
launch_mode = "singleTask"
|
||||||
|
orientation = "landscape"
|
||||||
|
resizeable_activity = false
|
||||||
|
|
||||||
|
[[package.metadata.android.application.activity.intent_filter]]
|
||||||
|
actions = ["android.intent.action.MAIN"]
|
||||||
|
categories = [
|
||||||
|
"com.oculus.intent.category.VR",
|
||||||
|
"android.intent.category.LAUNCHER",
|
||||||
|
]
|
||||||
|
|
||||||
|
[package.metadata.android.signing.release]
|
||||||
|
path = "./hotham_examples.keystore"
|
||||||
|
keystore_password = "chomsky-vigilant-spa"
|
||||||
@@ -42,6 +42,9 @@ pub fn initialize_xr_graphics(
|
|||||||
|
|
||||||
let xr_entry = super::xr_entry();
|
let xr_entry = super::xr_entry();
|
||||||
|
|
||||||
|
#[cfg(target_os = "android")]
|
||||||
|
xr_entry.initialize_android_loader().unwrap();
|
||||||
|
|
||||||
let available_extensions = xr_entry.enumerate_extensions()?;
|
let available_extensions = xr_entry.enumerate_extensions()?;
|
||||||
assert!(available_extensions.khr_vulkan_enable2);
|
assert!(available_extensions.khr_vulkan_enable2);
|
||||||
info!("available xr exts: {:#?}", available_extensions);
|
info!("available xr exts: {:#?}", available_extensions);
|
||||||
@@ -102,6 +105,8 @@ pub fn initialize_xr_graphics(
|
|||||||
let device_extensions = vec![
|
let device_extensions = vec![
|
||||||
ash::extensions::khr::Swapchain::name(),
|
ash::extensions::khr::Swapchain::name(),
|
||||||
ash::extensions::khr::DrawIndirectCount::name(),
|
ash::extensions::khr::DrawIndirectCount::name(),
|
||||||
|
#[cfg(target_os = "android")]
|
||||||
|
ash::extensions::khr::TimelineSemaphore::name(),
|
||||||
];
|
];
|
||||||
info!(
|
info!(
|
||||||
"creating vulkan instance with these extensions: {:#?}",
|
"creating vulkan instance with these extensions: {:#?}",
|
||||||
|
|||||||
@@ -201,10 +201,17 @@ impl PluginGroup for DefaultXrPlugins {
|
|||||||
.add_before::<RenderPlugin, _>(OpenXrPlugin)
|
.add_before::<RenderPlugin, _>(OpenXrPlugin)
|
||||||
.add_after::<OpenXrPlugin, _>(OpenXrInput::new(XrControllerType::OculusTouch))
|
.add_after::<OpenXrPlugin, _>(OpenXrInput::new(XrControllerType::OculusTouch))
|
||||||
.set(WindowPlugin {
|
.set(WindowPlugin {
|
||||||
|
#[cfg(not(target_os = "android"))]
|
||||||
primary_window: Some(Window {
|
primary_window: Some(Window {
|
||||||
present_mode: PresentMode::AutoNoVsync,
|
present_mode: PresentMode::AutoNoVsync,
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
|
#[cfg(target_os = "android")]
|
||||||
|
primary_window: None,
|
||||||
|
#[cfg(target_os = "android")]
|
||||||
|
exit_condition: bevy::window::ExitCondition::DontExit,
|
||||||
|
#[cfg(target_os = "android")]
|
||||||
|
close_when_requested: true,
|
||||||
..default()
|
..default()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user