Skip to content

mvvvv/StereoKit-rust

Repository files navigation

This project is a rust binding of the excellent StereoKit project

Screenshot

Its purpose is to improve the previous rust project https://github.com/MalekiRe/stereokit-rs:

  • by abandoning the automatic bindgen to avoid the multiplication of data types and eliminate costly transmutes.
  • by implementing all the missing API calls and data types.
  • by getting closer to the C# object model.
  • by offering a framework based on winit/android-activity which takes up the ISTEPPERS of the C# framework.

This project is at an early stage so try it carefully. Right now, the only way to get the project is to get the source code from github.

Download the source project:

  • git clone --recursive https://github.com/mvvvv/StereoKit-rust/
  • On Linux get the following tools and dev libraries : clang cmake libx11-dev libxfixes-dev libegl-dev libgbm-dev libfontconfig-dev.
  • On Window get the following tools and dev libraries : "CMake", "Visual Studio Build Tools 2022(Developpment Desktop C++)" and "DotNet SDK v8+"
  • If you want to launch the demos then:
    • compile the shaders. From StereoKit-rust directory launch cargo run --bin cargo-compile_sks
    • for Windows only and if you don't use VSCode launchers, add to the PATH environment variable the directory ./target/debug/deps

Run the project's demo on your PC's headset :

  • Make sure you have OpenXR installed with an active runtine.
  • Launch1: cargo run --features event-loop --example main_pc

Run the project's demo on your PC using the simulator

  • Launch1: cargo run --features event-loop --example main_pc -- --test

Run the project's demo on your Android headset (from a PC running Windows, Mac or Linux):

  • Install sdkmanager (or Android Studio if you intend to use it). You'll need a Java JDK (v17 is fine).
  • Using sdkmanager, install platform-tools(v32), latest build-tools and the latest ndk.
  • Set ANDROID_HOME environment variable to its path (this path contains the build_tools directory).
  • Set the NDK path (which ends with it's version number) into ANDROID_NDK_ROOT environment variable.
  • Install Ninja
  • Check that adb ($ANDROID_HOME/platform_tools/adb) is connecting to your headset.
  • Install: cargo install cargo-apk (cargo-xbuild has not been tested yet).
  • Download the target: rustup target add aarch64-linux-android for most of the existing android headsets.
  • Launch: cargo apk run --features event-loop --example main

Use your own event manager (PC only - see gradle templates for an android build)

The demos above, are using winit as an event manager and interface with the OS. If you want to use your own loop and event manager, have a look to manual.rs. This is the shortest way to launch your first PCVR/PCMR program1: cargo run --features no-event-loop --example manual

Templates to create your own project:

There is 3 templates used to build android versions. The default choice, branch main, will use cargo-apk (like demos above). The branch gradle will let you use gradle with winit. Then the branch gradle-no-event-loop will use gradle without winit.

  • git clone -b $branch https://github.com/mvvvv/stereokit-template/
  • If you don't clone the template project in the same directory than the StereoKit-rust project, you'll have to modify the path of the Stereokit-rust dependency.

Troubleshooting

Submit bugs on the Issues tab, and ask questions in the Discussions tab!

The project https://github.com/StereoKit/StereoKit/ will give you many useful links (Discord/Twitter/Blog).

Dependencies

This project was made possible thanks to the work of many talents on the following projects:

  • StereoKit which itself is based on valuable projects.
  • rust_mobile used for the android specific code.
  • winit used for cross-platform management.
  • openxrs nice binding of OpenXR.
  • blender for gltf files, HDRI, models and demo animations
  • gimp for icons files.
  • bitflags.
  • android_logger.
  • this_error & anyerror.
  • ... many others, more discreet, without which nothing would be possible.

Footnotes

  1. If you're using VsCode you'll see a corresponding launcher in launch.json to debug the app. 2 3

About

A rust binding of the excellent StereoKit

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •