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
- Host: GitHub
- URL: https://github.com/losttech/openxr.pinvoke
- Owner: losttech
- Created: 2020-03-02T03:29:36.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-03-02T03:43:05.000Z (about 6 years ago)
- Last Synced: 2025-04-09T20:52:44.578Z (about 1 year ago)
- Topics: csharp, dotnet, openxr, pinvoke, vr, xr
- Language: C#
- Homepage:
- Size: 14.6 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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);
}
```