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 android-activity which takes up the ISTEPPERS of the C# framework.
This project is at an early stage so try it carefully. To start using it see the documentation.
The following instructions are to get the source code from github if you want to contribute or launch the demos.
| Target: | Windows x86_64 | Linux x86_64 | Meta Quest | Linux AArch64 | macOS AArch64 |
|---|---|---|---|---|---|
| Windows x86_64 | X | with Steam Proton | X | ||
| Linux x86_64 | X | X | X | X | |
| Linux AArch64 | ? | ? | ? | X | |
| macOS | X | X |
Let us know if you have launched the demos on an architecture not tested here.
git clone --recursive https://github.com/mvvvv/StereoKit-rust/- On Linux get the following tools and dev libraries : git cmake clang llvm lld ninja-build pkg-config libx11-dev libxfixes-dev libxrandr-dev libxcursor-dev libxi-dev libfontconfig-dev libwayland-dev libxkbcommon-dev libdecor-0-dev libfontconfig1-dev.
- On macOS get the following tools and dev libraries : brew install cmake ninja molten-vk vulkan-headers.
To run or test, set
DYLD_LIBRARY_PATHso the dynamic linker finds MoltenVK:export DYLD_LIBRARY_PATH=$(brew --prefix molten-vk)/lib${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}export VK_ICD_FILENAMES=$(brew --prefix molten-vk)/share/vulkan/icd.d/MoltenVK_icd.json
- On Windows1 get the following tools and dev libraries : "Git", "CMake", "Visual Studio Build Tools 2022(Development Desktop C++)" and "DotNet SDK v8+"
- Install the project's tools from the project directory
cargo install --path . - If you want to launch the demos then:
- If you do not have them as symbolic links under shaders_src, copy from
./StereoKit/Examples/Assets/Shaders/the following files:basic_shadow.hlslbasic_shadow_caster.hlslcompute_reaction.hlslandtexture3d.hlsl - compile the shaders. From StereoKit-rust directory launch
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
- If you do not have them as symbolic links under shaders_src, copy from
- Make sure you have OpenXR installed with an active runtine.
- Launch2:
cargo run --example main_pc
Run the project's demo on your PC using the simulator
- Launch2:
cargo run --example main_pc -- --test
cargo build_sk_rs --example main_pc <the path of your exportable repository>
On Linux, you may have to set RUSTFLAGS="-Clinker-plugin-lto" if you encounter any "undefined reference".
-
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_toolsdirectory). -
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. -
Download the target:
rustup target add aarch64-linux-androidfor most of the existing android headsets. -
Create project sk_demos:
cargo new_sk_rs_project sk_demos --with-gradle
cd sk_demos
#- modify Cargo.toml:
cp ~/dvlt/StereoKit-rust/src/template/Cargo.toml_for_AndroidDemo.txt Cargo.toml
#- replace src/ assets/ res/ app/ by these links
ln -s ~/dvlt/StereoKit-rust/examples/main.rs src/lib.rs
ln -s ~/dvlt/StereoKit-rust/examples/main_pc.rs src/main.rs
ln -s ~/dvlt/StereoKit-rust/examples/demos/ src/demos
ln -s ~/dvlt/StereoKit-rust/assets/ .
ln -s ~/dvlt/StereoKit-rust/res/ .
#--if you want to tweak/PR the project you should link the files to the originals located under `~/dvlt/StereoKit-rust/src/templates/gradle/`.
clear; ./gradlew run --warning-mode all && sh logcat.cmdThe demos above are using an event loop based framework. 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 PC VR/MR program2: cargo run --features no-event-loop --example manual
Use the commande cargo new_sk_rs_project to create your project see the documentation.
-
Install mingw64-w64 (MSYS2 on windows)
-
Add the rust target gnu for windows:
rustup target add x86_64-pc-windows-gnu -
On
non Windows OSwe use and need wine to compile the shaders- Add i386 architecture (i.e.
sudo dpkg --add-architecture i386on Ubuntu). - Install wine.
- Add i386 architecture (i.e.
-
Create a directory where necessary libs will be stored (i.e. ../x64-mingw-libs/) then add a link to the DLLs or static libs(*.a) the build will need after or during its creation. Example on Ubuntu 24.XX:
ln -s /usr/lib/gcc/x86_64-w64-mingw32/13-win32/libgcc_s_seh-1.dll ../x64-mingw-libs/ && ln -s /usr/lib/gcc/x86_64-w64-mingw32/13-win32/libstdc++-6.dll ../x64-mingw-libs/- or
ln -s /usr/lib/gcc/x86_64-w64-mingw32/13-win32/libgcc_eh.a ../x64-mingw-libs/ && ln -s /usr/lib/gcc/x86_64-w64-mingw32/13-win32/libstdc++.a ../x64-mingw-libs/
-
Launch:
cargo build_sk_rs --x64-win-gnu ../x64-mingw-libs/ --example main_pc <the path of your exportable repository> -
To run main_pc.exe on Linux:
- Add a non-steam game to your library then launch it when WiVRn or SteamVR are started.
- If you only need the simulator:
wine main_pc.exe --test
-
Install g++-aarch64-linux-gnu
-
Get the libraries gcc-aarch64-linux-gnu g++-aarch64-linux-gnu lld:arm64 libx11-dev:arm64 libxfixes-dev:arm64 libxrandr-dev:arm64 libxcursor-dev:arm64 libxi-dev:arm64 libfontconfig-dev:arm64 libwayland-dev:arm64 libxkbcommon-dev:arm64 libdecor-0-dev:arm64 libfontconfig1-dev:arm64. On Ubuntu 24:XX this can be done by adding a foreign architecture
dpkg --add-architecture arm64with depothttp://ports.ubuntu.com/ubuntu-ports. To avoid errors duringapt updateyou'll have to specify the architectures of all depots in/etc/apt/sources.list.d/ubuntu.sources -
Add the rust target aarch64 for linux:
rustup target add aarch64-unknown-linux-gnu -
Add a section
[target.aarch64-unknown-linux-gnu]in your config.toml for settinglinker = "aarch64-linux-gnu-gcc" -
Launch
cargo build_sk_rs --example main_pc --aarch64-linux <the path of your exportable repository>
-
The logic should be the same as previous one.
-
Launch
cargo build_sk_rs --example main_pc --x64-linux <the path of your exportable repository>.
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).
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.
- 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
-
If you're using VsCode you can choose to use LLDB instead of GDB when testing with MSVC. For that add to your workspace settings.json:
"lldb.script": { "lang.rust.toolchain": "stable-x86_64-pc-windows-gnu" }↩ -
If you're using VsCode you'll see a corresponding launcher in launch.json to debug the app. If you're using linux, with Wayland, you'll have to add
DISPLAY=before the command. ↩ ↩2 ↩3
