the Fiddler's picture

Introducing OpenTK.Rift: Oculus Rift bindings for OpenTK

It is my pleasure to introduce OpenTK.Rift, the first cross-platform C# wrapper for the Oculus Rift. The Oculus Rift is a next-generation virtual reality headset designed for immersive gaming.

Install via NuGet

OpenTK.Rift provides an intuitive C# API to read the properties of the device (orientation, acceleration, size, resolution) and control its parameters. Like OpenTK, you can use OpenTK.Rift with all .Net languages (C#, F#, VB.Net, ...) and on all desktop operating systems (Windows, Linux, Mac OS X.) Usage is extremely simple:

using System;
using OpenTK;
 
class Test
{
    public static void Main()
    {
        using (var oculus = new OculusRift())
        {
             Console.Writeline(oculus.Orientation);
        }
    }
}

You are welcome to join its development at https://github.com/opentk/rift!

Current status:

  • (done) Linux support
  • (done) Mac OS X support
  • (done) Console test
  • (done) OpenGL 1.x test
  • (done) Windows support
  • (done) Nuget support
  • (in progress) OpenGL 2.x test
  • (not started) OpenGL 3.x test

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
winterhell's picture

Couple of questions:
Is it possible to develop for it without a real headset?
Can the same application support 2 independent rifts?

vicviper's picture

I think it is possible to develop without a real headset. The demos that require a headset can run without it, but they're essentially unplayable, like trying to play a game that requires a gamepad... without a gamepad.

About the 2nd question, I don't think so: at the very least you would need a graphics card for each headset, and handling both would probably introduce unreasonable lag. As of today, you need a really powerful machine to deliver a good VR experience on just a single headset.

the Fiddler's picture

Each device is presented as a monitor, which means you can connect multiple devices without an issue. The only limitation is your GPU hardware - it needs to have enough output ports and processing capacity to accommodate the displays at 60Hz.

Programming without a device is certainly possible - I implemented OpenTK.Rift before the device arrived. However, note that VR has special design considerations that are not apparent on a regular monitor. The documentation on the oculus website is are excellent overview.

the Fiddler's picture

Each device is presented as a monitor, which means you can connect multiple devices without an issue. The only limitation is your GPU hardware - it needs to have enough output ports and processing capacity to accommodate the displays at 60Hz.

Programming without a device is certainly possible - I implemented OpenTK.Rift before the device arrived. However, note that VR has special design considerations that are not apparent on a regular monitor. The documentation on the oculus website is are excellent overview.

murrdpirate's picture

Thanks very much for putting this together. I just have one question: how is the radial distortion applied? I see that the OculusRift class loads the distortion parameters from the rift, but I don't see how this is used. I'm looking closely at the Test.GL1 example.

the Fiddler's picture

Distortion requires a shader, so Test.GL1 does not apply the distortion at all. Test.GL2 would have applied the distortion, but this was interrupted by the release of Oculus SDK 0.3.x which uses a different approach.

In 0.3.x, the distortion can be applied either automatically by the Oculus SDK (recommended) or manually via a distortion mesh. Refer to the Oculus documentation for more information.

murrdpirate's picture

Ah, thanks, I didn't even notice you already had the wrapper for Oculus SDK 0.3.x. I'm having some trouble building it in windows though. I had to change the EOL format on the src files to Windows format, which was easy enough, but now I'm getting unresolved external symbol errors (public: static class OVR::CAPI::DistortionRenderer) and complaints about OculusCamera.cs missing.

If you or anyone can help me get this working, I'd really appreciate it. The wrapper for 0.2.x has been extremely useful for me.

the Fiddler's picture

The 0.3.x bindings are not 100% baked yet, which why I haven't released them to the wild yet. I have not tested 0.3.x on Windows yet, so some breakage is to be expected - as always, help with testing and bugfixing is very welcome.

Can you please make a bug report at https://github.com/opentk/rift/issues?

murrdpirate's picture

I definitely understand. It would be great if I could get this wrapper working with 0.3.x, but I'm still just really happy that the 0.2.x version works so well. Has made my life quite a bit easier.

I filed a bug report on github. I'm definitely willing and able to help with testing, but I'm not sure I can help much with bug fixing as I'm still a bit new to programming. But I would like to help in any way I can.

wrathrowe's picture

Hello, are there any plans to support 0.4.0?