An open API service indexing awesome lists of open source software.

https://github.com/losttech/openxr.pinvoke

Raw PInvoke bindings for OpenXR
https://github.com/losttech/openxr.pinvoke

csharp dotnet openxr pinvoke vr xr

Last synced: about 1 year ago
JSON representation

Raw PInvoke bindings for OpenXR

Awesome Lists containing this project

README

          

## Getting started on Windows

1. Create a new *.NET Core* WPF or Windows Forms project
1. Add a reference to OpenXR.PInvoke package
2. Allow unsafe code:
```xml

true

```
3. Reference OpenXR.Loader package
4. Modify `.csproj` file to have these (works on Windows only)
```xml

```
5. Add a custom native library resolver (works as is on Windows only):
```csharp
NativeLibrary.SetDllImportResolver(typeof(OpenXR.PInvoke.XR).Assembly, Resolver);

static IntPtr Resolver(string libraryname, Assembly assembly, DllImportSearchPath? searchpath) {
if (libraryname != "openxr_loader") return IntPtr.Zero;

string installDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
throw new PlatformNotSupportedException();

string bitness = IntPtr.Size switch {
4 => "Win32",
8 => "x64",
_ => throw new PlatformNotSupportedException(),
};

string path = Path.Combine(new[] {
installDir, "native", bitness, "release", "bin",
Path.ChangeExtension(libraryname, ".dll"),
});

return NativeLibrary.Load(path);
}
```