Skip to main content
Inspiring
July 28, 2014

JOVR 0.4.2.0: Java/Maven bindings for 0.4.2 (Updated 09-05)

I've updated my Java bindings for SDK 0.4.2. The source code can be found on Github here. Example code can be found here.

Developers using Maven (or a Maven compatible tool like Gradle) can declare a dependency on the following artifact:


<dependency>
<groupId>org.saintandreas</groupId>
<artifactId>jovr</artifactId>
<version>0.4.2.0</version>
</dependency>


Update 2014-09-05: Release of 0.4.2.0
Changes since 0.4.2.0

  • Updated binaries to SDK 0.4.2

  • Added new HQ distortion flag (currently non-functional in OpenGL)


Update 2014-09-03: Release of 0.4.1.2
Changes since 0.4.1.1

  • Added function to enable/disable HSW rendering by the SDK

Update 2014-08-15: Release of 0.4.1.1
Changes since 0.4.1.0

  • The windows binaries were being built in release mode, but had some debug preprocessor macros enabled, so any asserts you hit would crash the application.


Known issues are unchanged.

Update 2014-08-13: Release of 0.4.1.0

Changes since 0.4.0.1

  • Added ovr_InitializeRenderingShim method to the OvrLibrary type.

  • Updated windows binaries to 0.4.1 SDK

  • Added Mac binaries


Known issues

  • Health and safety warning doesn't display properly for me on OSX

  • Continued issues with OpenGL and Direct HMD mode. I recommend using extended mode for the time being if you're having issues.

  • Judder issues are prominent in OpenGL in all my tests. I recommend running your headset @60Hz until Oculus or the video card manufacturers do whatever is required to resolve the problem.


Update 2014-08-11: Release of 0.4.0.1

Changes since 0.4.0.0

  • Renamed the HmdDesc type to Hmd to more closely match the SDK naming

  • Added some missing functions to Hmd required for client side distortion

  • Added some missing function to Hmd for health and safety warning management

  • Added some missing override annotations


Known issues

  • Unfortunately, like the current SDK release, they are windows only. I've built both the 64 bit and 32 bit DLL versions and they're embedded in the jar file.

  • I've been unable to get OpenGL to work properly with Direct HMD mode. I recommend using extended mode for the time being if you're having issues.

    52 replies

    Up and Coming
    August 11, 2014
    "jherico" wrote:
    "elect" wrote:
    Ps: what about ovrHmd_GetRenderScaleAndOffset?


    Looks like some of the client side distortion items were missed in the Hmd class. I'll fix that in the next revision. In the meantime you can still access it directly through the OvrLibrary interface.


    How?
    jhericoAuthor
    Inspiring
    August 11, 2014
    If you look at the source for the Hmd class (called HmdDesc in JOVR 0.4.0.0, Hmd in 0.4.0.1) you'll see that it's full of methods that call methods on OvrLibrary.INSTANCE, passing itself as the first member.

    Like so:


    public FrameTiming beginFrame(int frameIndex) {
    return OvrLibrary.INSTANCE.ovrHmd_BeginFrame(this, frameIndex);
    }


    All of the C API functions are exposed as method on OvrLibrary, whether or not they're in the Hmd/HmdDesc helper class. So you could directly call


    OvrLibrary.INSTANCE.ovrHmd_GetRenderScaleAndOffset(hmd, ...)



    However, I've updated the module over the weekend to add the missing functions, so if you update to 0.4.0.1 you should be able to call getRenderScaleAndOffset(...) directly on the Hmd class.
    Brad Davis - Developer for High Fidelity Co-author of Oculus Rift in Action
    Up and Coming
    August 11, 2014
    Nice, I'll give it a try tomorrow

    thanks for your work, jherico
    Up and Coming
    August 12, 2014
    I cant see it in the jvr 0.4.0.1

    Anyway I tried

                OvrLibrary.INSTANCE.ovrHmd_GetRenderScaleAndOffset((FovPort.ByValue) eyeFov[eyeNum], (OvrSizei.ByValue) frameBuffer.getSize(),
    (OvrRecti.ByValue) eyeRenderViewport[eyeNum], uvScaleOffset[eyeNum]);


    Exception in thread "main-AWTAnimator" java.lang.ClassCastException: com.oculusvr.capi.FovPort cannot be cast to com.oculusvr.capi.FovPort$ByValue


    If I dont try the casting I get error directly in the ide
    jhericoAuthor
    Inspiring
    August 12, 2014
    "elect" wrote:
    I cant see it in the jvr 0.4.0.1


    Odd, I can definately see it in my copy. I just deleted it from my repository to force it to redownload and it's still there:


    public static OvrVector2f[] com.oculusvr.capi.Hmd.getRenderScaleAndOffset(FovPort, OvrSizei, OvrRecti);


    "elect" wrote:

    Anyway I tried

                OvrLibrary.INSTANCE.ovrHmd_GetRenderScaleAndOffset((FovPort.ByValue) eyeFov[eyeNum], (OvrSizei.ByValue) frameBuffer.getSize(),
    (OvrRecti.ByValue) eyeRenderViewport[eyeNum], uvScaleOffset[eyeNum]);


    Exception in thread "main-AWTAnimator" java.lang.ClassCastException: com.oculusvr.capi.FovPort cannot be cast to com.oculusvr.capi.FovPort$ByValue


    If I dont try the casting I get error directly in the ide


    You can't cast directly, but you should be able to do


    new FovPort.ByValue(eyeFov[eyeNum]);


    and


    new OvrRecti.ByValue(eyeRenderViewport[eyeNum]);
    Brad Davis - Developer for High Fidelity Co-author of Oculus Rift in Action
    Up and Coming
    August 12, 2014
    "jherico" wrote:


    You can't cast directly, but you should be able to do


    new FovPort.ByValue(eyeFov[eyeNum]);


    and


    new OvrRecti.ByValue(eyeRenderViewport[eyeNum]);


    OvrLibrary.INSTANCE.ovrHmd_GetRenderScaleAndOffset(new FovPort.ByValue(eyeFov[eyeNum]), new OvrSizei.ByValue(frameBuffer.getSize()), new OvrRecti.ByValue(eyeRenderViewport[eyeNum]), uvScaleOffset[eyeNum]);


    Exception in thread "main-AWTAnimator" java.lang.IllegalArgumentException: Structure array elements must use contiguous memory (bad backing address at Structure array index 1)
    jhericoAuthor
    Inspiring
    August 12, 2014
    "elect" wrote:

    OvrLibrary.INSTANCE.ovrHmd_GetRenderScaleAndOffset(new FovPort.ByValue(eyeFov[eyeNum]), new OvrSizei.ByValue(frameBuffer.getSize()), new OvrRecti.ByValue(eyeRenderViewport[eyeNum]), uvScaleOffset[eyeNum]);


    Exception in thread "main-AWTAnimator" java.lang.IllegalArgumentException: Structure array elements must use contiguous memory (bad backing address at Structure array index 1)


    It's a quirk of JNA that arrays passed through the C API have to be contiguous in memory. You can create a contiguous array using the toArray() member in the structure base class like so:


    OvrVector2f results[] = (OvrVector2f[]) new OvrVector2f().toArray(2);


    The casting here is because the base class will only return the type Structure[].

    Assuming uvScaleOffset is declared as


    OvrVector2f uvScaleOffset[][];


    you should be able to initialize it as


    OvrVector2f uvScaleOffset[][] = {
    (OvrVector2f[]) new OvrVector2f().toArray(2),
    (OvrVector2f[]) new OvrVector2f().toArray(2)
    };


    Of course the point of the Hmd helper method is that you don't have to jump through all these 'byvalue' and 'contiguous memory' hoops. The implementation in the Hmd class look like so:


    public static OvrVector2f[] getRenderScaleAndOffset(FovPort fov, OvrSizei textureSize,
    OvrRecti renderViewport) {
    OvrVector2f results[] = (OvrVector2f[]) new OvrVector2f().toArray(2);
    OvrLibrary.INSTANCE.ovrHmd_GetRenderScaleAndOffset(
    byValue(fov),
    byValue(textureSize),
    byValue(renderViewport),
    results);
    return results;
    }


    The byValue calls there are static members of the Hmd class (which are private, but should probably be public) that inspect the type and up-convert to a ByValue if the type isn't already one.
    Brad Davis - Developer for High Fidelity Co-author of Oculus Rift in Action
    Up and Coming
    August 13, 2014
    Ok, I tried to detach the library containing the jovr and attach it again, I see it now.. maybe some caching, dont know

    Anyway, I gave it a try declaring it like this

    uvScaleOffset = new OvrVector2f[2][2];


    and getting the scale and offset like

    uvScaleOffset[eyeNum] = Hmd.getRenderScaleAndOffset(eyeFov[eyeNum], renderTargetSize, eyeRenderViewport[eyeNum]);


    It is working.. and more important I think that small pincushion effect I still had is definitely gone now (first I hardcoded those value based on the c example and I gave it a check, they are different) and now the image looks perfect, no more line distortion at the borders

    40.png

    viewtopic.php?f=20&t=12015#wrap

    Thanks! ^^
    jhericoAuthor
    Inspiring
    August 13, 2014
    Glad you got it working. I should be able to push out JOVR 0.4.1.0 tonight, though it shouldn't require much if any code changes.
    Brad Davis - Developer for High Fidelity Co-author of Oculus Rift in Action
    jhericoAuthor
    Inspiring
    August 14, 2014
    Bumping thread for new release.
    Brad Davis - Developer for High Fidelity Co-author of Oculus Rift in Action