Forum Discussion
guygodin
11 years agoProtege
SharpOVR 0.4.2 NuGet Update
I've released a NuGet package called SharpOVR, it's a .NET API for the Oculus Rift. It is based on SDK 0.4.x and wraps most of the functionality provided by the SDK. It only supports SDK Rendering at the moment (no Client Distortion Rendering). It has a dependency on SharpDX for the Matrix, ViewportF, Vector and Point classes.
https://www.nuget.org/packages/SharpOVR/
Here's how to use it:
It targets the "Any CPU" platform as the assembly embeds both Win32/x64 unmanaged dlls and loads the appropriate one at runtime. In other words, just add the NuGet package to your project and you're good to go.
I've created a sample SharpDX game project (shown below) that can help you get started.
SharpOVR Sample

Let me know if you have any questions/suggestions.
Guy
https://www.nuget.org/packages/SharpOVR/
Here's how to use it:
OVR.Initialize();
using (HMD hmd = OVR.HmdCreate(0))
{
// Configure rendering, configure tracking, BeginFrame, EndFrame, etc
}
OVR.Shutdown();
It targets the "Any CPU" platform as the assembly embeds both Win32/x64 unmanaged dlls and loads the appropriate one at runtime. In other words, just add the NuGet package to your project and you're good to go.
I've created a sample SharpDX game project (shown below) that can help you get started.
SharpOVR Sample

Let me know if you have any questions/suggestions.
Guy
51 Replies
- guygodinProtegeI've updated SharpOVR to use the latest SDK 0.3.2. The NuGet and library version match the SDK version so you can continue using 0.3.1 if you wish.
There are a couple of breaking changes described in the SDK release notes: https://developer.oculusvr.com/?action=hist&ver=16. - VogelvisionHonored GuestThank you very much for putting your library up on NuGet. Do you have a working example using SharpDx and DirectX 11? I've been trying to create a quick demo using it but I get an exception on the EndFrame call.
Thanks! - guygodinProtegeThat's a good idea, I don't have a bare-bones one at the moment so I'll create a simple project from the SharpDX project template and put it up here.
- VogelvisionHonored GuestThank you for posting the sample code and great work on the SharpOVR library.
- shawn75Honored GuestAmazing project.
sadly i get an Error 1 This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ..\packages\SharpDX.2.6.0\build\SharpDX.targets. C:\Users\Urban\Desktop\RiftGame.csproj 55 5 RiftGame
i insaled SharpOVR and SharpDX - PathogenDavidHonored GuestShawn, I totally forgot SharpOVR was developed with SharpDX in mind when I posted it in your thread. That might be part of your problem, I'm not familiar enough with NuGet to say for sure though.
Guy, does SharpOVR expose the OpenGL bits of the SDK, or did you never write the binding bits for it? - guygodinProtegeFollow the instructions provided in the link to install NuGet: http://docs.nuget.org/docs/start-here/installing-nuget. SharpOVR is meant to be used with DirectX. It doesn't have the bindings for OpenGL.
- spyroExpert ProtegeGreat work! Can't wait to use it! :)
- connieyHonored GuestHey,
I was trying to preview your nuget package without an OculusRift using the project below:I've created a sample SharpDX game project (shown below) that can help you get started.
http://1drv.ms/1hDMLvs
However, when I press F5, I get a PInvokeStackImbalance exception.Managed Debugging Assistant 'PInvokeStackImbalance' has detected a problem in 'C:\Users\conniey\Downloads\SharpOVR Sample\bin\Debug\RiftGame.vshost.exe'.
Additional information: A call to PInvoke function 'SharpOVR!SharpOVR.OVR::ovrHmd_Create' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
This is the line it is failing on:hmd = OVR.HmdCreate(0) ?? OVR.HmdCreateDebug(HMDType.DK1);
Do you have any pointers to get around this? Or do I need to plug in a Rift to get it to work? - connieyHonored Guest
"shawn75" wrote:
Amazing project.
sadly i get an Error 1 This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ..\packages\SharpDX.2.6.0\build\SharpDX.targets. C:\Users\Urban\Desktop\RiftGame.csproj 55 5 RiftGame
i insaled SharpOVR and SharpDX
Unfortunately, in order to enable NuGet restore, it needs to have a .sln file. Also, the paths for the packages needs to be changed.
Here are the steps:- Open RiftGame.csproj in VS.
- Press Ctrl+S to save RiftGame.sln in the same directory as RiftGame.csproj
- Right-click on "Solution 'Rift Game' (1 project)" then select "Enable Package Restore..."
- Right-click on the project, RiftGame.csproj and "Unload Project"
- Right-click on the unloaded project and select "Edit RiftGame.csproj"
- Ctrl+H and replace "..\packages" with "packages"
- Save the file.
- Right-click on RiftGame.csproj and "Reload Project"
- Build solution.
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 1 year ago
- 7 months ago
- 11 months ago
- 7 months ago
- 3 years ago