Selection of a Java wrapper for Oculus SDK
The first step towards writing a java library of Oculus for Processing was selecting/making a java wrapper which exposes the entire Oculus API. There are two timelines i would want to share which have changed this decision considerably.
The first timeline is for Oculus SDK version < 0.3 (Pre April,2014)
At this time the Oculus SDK offered only a cpp API to the developers. The Java wrappers that came around this time were all based on JNI. JNI is powerful but developing in it is tough and maintaining the wrapper for each SDK update is even more difficult. The 3 wrappers at that time which were providing this functionality were:
1) JRift – used by JMonkeyEngine (a java game-engine) and had the most complete implementation as a wrapper (at that time)
2) Jocular – initial attempt by Jherico to make a C api and then port it to Java, has been upgraded since then
3) Jift – another early attempt at making a JNI wrapper for Oculus
The second timeline if after Oculus SDK version > 0.3 (Post April, 2014)
This SDK added initial support for DK2 and has lot of upgrades over 0.2.*. (you can look at the CHANGE-LOG here, login required). Of the many changes, the one that was particularly important for porting Oculus to other languages: “Reorganized all HMD and sensor interfaces to be exposed through a simplified C API. The new API makes it easy to use LibOVR from other languages.”
This change has helped developer’s make wrappers for a variety of languages easily: python, node, java. Jherico used a tool called JNAerator to provide a JNA wrapper for oculus that exposes the entire C Api of Oculus. He has a detailed blog post on how he created the wrapper (nice resource!). JNA offers a lot more flexibility in the long run and is easier as you only write in Java, no cpp code is required.
Jherico went ahead and created a maven project (including tests) for JOVR wrapper (Jocular successor) which is really cool. He also created dynamic libraries of libovr with his improvements for all the three platforms!
So the decision was made and i chose Jocular as it wraps the latest API and will be easier to maintain. JMonkeyEngine has also shifted to Jocular for their wrapper.
Compiling and running Jocular is easy (the parameters can be modified per user requirements):
mvn install -DskipTests=true -Dgpg.skip=true dependency:copy-dependencies
@Mac users would want to copy the libovr.dylib from darwin-x86/ to darwin/ in resources/ as JNA looks in darwin/ for the native library before running maven.
using the wrapper is easy, take a look at his tests, or my proof of concept code here.
*Jocular and JOVR are same.
Next step is rendering!