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.
djk's picture

I am also interested in seeing this project updated. My kit was delivered yesterday. I can likely help with testing.

the Fiddler's picture

My DK2 has been delayed for some reason, so I won't be able to test until I get my hands on that.

A rough plan for 0.4.1:

  1. Update the source code to the latest version of libOVR
  2. Update CMakeLists to fix the build issues on Windows. (Most of my testing is on Mac OS X, so the Windows build has been broken for a while.)
  3. Add C# bindings for the new functionality (positional tracking, etc.)
  4. Write tests to exercise the bindings.
  5. Write examples to explain how to use the library.
  6. Update the nuget package.

Help will be really appreciated. I currently have my hands full with OpenTK 1.1.5, which adds OpenGL 4.5 / OpenGL ES 3.1 (90% done), and a new joystick driver for Windows & Linux (95% done).

djk's picture

I spent the last couple hours getting the rift 0.4.1 developer kit to compile. It looks like you have to install the Direct3d from June 10th to get libOVR to compile on Win8.1. I am not really sure whether I am getting OpenGL or Direct3d in the developer kit demo programs yet.

vicviper's picture

As far as I know, Oculus taking control of the render pipeline is a neccesary evil, to abstract developers from taking care of future hardware changes; In a far future, if VR succeeds and there's a range of (hopefully) different headsets to choose from, graphics cards manufacturers will hace to handle the headsets specifics at driver level. Until then, it's up to oculus to do the job, which means handling both DirectX and OpenGL.

Anyway, LibOVR is multiplatform, and both Linux and Mac miss DirectX, there should be a preprocessor directive to remove DirectX support on these platforms? I guess supporting OpenGL is unavoidable

djk's picture

Yes, I found the compiler directives and the default for ms windows is directx. I am playing around with libOVR to see if I can get it to run with OpenGl on my win8.1 laptop as a side project.

Edit: looks like some needed OpenGL functionality/changes did not make the 0.4.1 release.

vicviper's picture

Hi again... I would like to know the status of opentk.rift ... it's on hold? discontinued?

Thanks

JTalton's picture

"looks like some needed OpenGL functionality/changes did not make the 0.4.1 release"

My Oculus Rift Dev Kit 2 is arriving tomorrow. I am hoping to add Oculus Rift support to my current OpenTK project. Has anyone been able to get the Oculus Rift working with OpenTK? If so, are there any pointers to getting started? Thanks!

the Fiddler's picture

At its core, the Oculus SDK is a C++ library with a C API that can be pinvoked as usual. The 0.3.x branch of OpenTK.Rift contains a mostly complete C# wrapper around the 0.3.x API (previous versions had a custom C API).

What is still missing is:
1. update the CMake build script for the Oculus SDK. You can always use the prebuilt binary from the Oculus SDK, so this is a minor issue.
2. update the C# wrapper to cover the new 0.4.x functionality
3. test and fix any pinvoke bugs that show up

Unfortunately, the time I can dedicate to this is extremely limited at the moment. Contributions are more than welcome!