From bb6a8fdc8decdbec64bbab0fe2175e76211d0e77 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 26 Mar 2015 23:36:50 +0100 Subject: Bug 1116 - Add OculusVR DK2 Support - Part-2 (DK1 and DK2 on DK2 SDK w/ Eye Tracker if available) --- .../classes/com/jogamp/oculusvr/OVRVersion.java | 46 ++++---------- .../jogamp/opengl/oculusvr/OVRStereoDevice.java | 72 +++++++++++----------- .../opengl/oculusvr/OVRStereoDeviceFactory.java | 8 +-- .../opengl/oculusvr/OVRStereoDeviceRenderer.java | 40 ++++++------ .../classes/jogamp/opengl/oculusvr/OVRUtil.java | 2 +- 5 files changed, 73 insertions(+), 95 deletions(-) (limited to 'src/oculusvr/classes') diff --git a/src/oculusvr/classes/com/jogamp/oculusvr/OVRVersion.java b/src/oculusvr/classes/com/jogamp/oculusvr/OVRVersion.java index cf6eb5dda..9be37e193 100644 --- a/src/oculusvr/classes/com/jogamp/oculusvr/OVRVersion.java +++ b/src/oculusvr/classes/com/jogamp/oculusvr/OVRVersion.java @@ -33,9 +33,7 @@ import com.jogamp.common.os.Platform; import com.jogamp.common.util.VersionUtil; import com.jogamp.common.util.JogampVersion; import com.jogamp.oculusvr.OVR; -import com.jogamp.oculusvr.OvrHmdContext; import com.jogamp.oculusvr.ovrHmdDesc; -import com.jogamp.oculusvr.ovrSensorDesc; import com.jogamp.oculusvr.ovrSizei; import com.jogamp.oculusvr.ovrVector2i; @@ -69,10 +67,10 @@ public class OVRVersion extends JogampVersion { if( !OVR.ovr_Initialize() ) { // recursive .. sb.append("\tOVR not available").append(Platform.getNewline()); } else { - final OvrHmdContext ovrHmdCtx = OVR.ovrHmd_Create(ovrHmdIndex); - if( null != ovrHmdCtx ) { - getAvailableCapabilitiesInfo(ovrHmdCtx, ovrHmdIndex, sb); - OVR.ovrHmd_Destroy(ovrHmdCtx); + final ovrHmdDesc hmdDesc = OVR.ovrHmd_Create(ovrHmdIndex); + if( null != hmdDesc ) { + getAvailableCapabilitiesInfo(hmdDesc, ovrHmdIndex, sb); + OVR.ovrHmd_Destroy(hmdDesc); } else { sb.append("\thmd."+ovrHmdIndex+" not available").append(Platform.getNewline()); } @@ -81,34 +79,6 @@ public class OVRVersion extends JogampVersion { sb.append(Platform.getNewline()); return sb; } - /** - * - * @param ovrHmdCtx - * @param ovrHmdIndex only for informal purposes, OVR HMD index of created ovrHmdHandle - * @param sb - * @return - */ - public static StringBuilder getAvailableCapabilitiesInfo(final OvrHmdContext ovrHmdCtx, final int ovrHmdIndex, StringBuilder sb) { - if(null == ovrHmdCtx) { - throw new IllegalArgumentException("null ovrHmdHandle"); - } - if(null==sb) { - sb = new StringBuilder(); - } - final ovrHmdDesc hmdDesc = ovrHmdDesc.create(); - OVR.ovrHmd_GetDesc(ovrHmdCtx, hmdDesc); - getAvailableCapabilitiesInfo(hmdDesc, ovrHmdIndex, sb); - - final ovrSensorDesc sensorDesc = ovrSensorDesc.create(); - if( OVR.ovrHmd_GetSensorDesc(ovrHmdCtx, sensorDesc) ) { - sb.append("\thmd."+ovrHmdIndex+".sensor.productId:\t0x"+Integer.toHexString(sensorDesc.getProductId())).append(Platform.getNewline()); - sb.append("\thmd."+ovrHmdIndex+".sensor.vendorId:\t0x"+Integer.toHexString(sensorDesc.getVendorId())).append(Platform.getNewline()); - sb.append("\thmd."+ovrHmdIndex+".sensor.serial:\t"+sensorDesc.getSerialNumberAsString()).append(Platform.getNewline()); - } else { - sb.append("\thmd."+ovrHmdIndex+".sensor:\tn/a").append(Platform.getNewline()); - } - return sb; - } /** * * @param hmdDesc @@ -117,16 +87,22 @@ public class OVRVersion extends JogampVersion { * @return */ public static StringBuilder getAvailableCapabilitiesInfo(final ovrHmdDesc hmdDesc, final int ovrHmdIndex, StringBuilder sb) { + if(null == hmdDesc) { + throw new IllegalArgumentException("null hmdDesc"); + } if(null==sb) { sb = new StringBuilder(); } sb.append("\thmd."+ovrHmdIndex+".productName:\t"+hmdDesc.getProductNameAsString()).append(Platform.getNewline()); sb.append("\thmd."+ovrHmdIndex+".vendorName:\t"+hmdDesc.getManufacturerAsString()).append(Platform.getNewline()); sb.append("\thmd."+ovrHmdIndex+".deviceName:\t"+hmdDesc.getDisplayDeviceNameAsString()).append(Platform.getNewline()); + sb.append("\thmd."+ovrHmdIndex+".productId:\t0x"+Integer.toHexString(hmdDesc.getProductId())).append(Platform.getNewline()); + sb.append("\thmd."+ovrHmdIndex+".vendorId:\t0x"+Integer.toHexString(hmdDesc.getVendorId())).append(Platform.getNewline()); + sb.append("\thmd."+ovrHmdIndex+".serial:\t"+hmdDesc.getSerialNumberAsString()).append(Platform.getNewline()); sb.append("\thmd."+ovrHmdIndex+".type:\t"+hmdDesc.getType()).append(Platform.getNewline()); sb.append("\thmd."+ovrHmdIndex+".hmdCaps:\t"+hmdDesc.getHmdCaps()).append(Platform.getNewline()); sb.append("\thmd."+ovrHmdIndex+".distorCaps:\t"+hmdDesc.getDistortionCaps()).append(Platform.getNewline()); - sb.append("\thmd."+ovrHmdIndex+".sensorCaps:\t"+hmdDesc.getSensorCaps()).append(Platform.getNewline()); + sb.append("\thmd."+ovrHmdIndex+".sensorCaps:\t"+hmdDesc.getTrackingCaps()).append(Platform.getNewline()); final ovrSizei resolution = hmdDesc.getResolution(); sb.append("\thmd."+ovrHmdIndex+".resolution:\t"+resolution.getW()+"x"+resolution.getH()).append(Platform.getNewline()); final ovrVector2i winPos = hmdDesc.getWindowsPos(); diff --git a/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDevice.java b/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDevice.java index 3dadb94b0..89f7797ae 100644 --- a/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDevice.java +++ b/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDevice.java @@ -64,15 +64,18 @@ public class OVRStereoDevice implements StereoDevice { private final PointImmutable position; private final int dkVersion; - public OVRStereoDevice(final StereoDeviceFactory factory, final OvrHmdContext nativeContext, final int deviceIndex) { + public OVRStereoDevice(final StereoDeviceFactory factory, final ovrHmdDesc hmdDesc, final int deviceIndex) { + if( null == hmdDesc ) { + throw new IllegalArgumentException("Passed null hmdDesc"); + } + final OvrHmdContext nativeContext = hmdDesc.getHandle(); if( null == nativeContext ) { - throw new IllegalArgumentException("Passed null nativeContext"); + throw new IllegalArgumentException("hmdDesc has null OvrHmdContext"); } this.factory = factory; this.handle = nativeContext; this.deviceIndex = deviceIndex; - this.hmdDesc = ovrHmdDesc.create(); - OVR.ovrHmd_GetDesc(handle, hmdDesc); + this.hmdDesc = hmdDesc; final ovrFovPort[] defaultOVREyeFov = hmdDesc.getDefaultEyeFov(0, new ovrFovPort[ovrHmdDesc.getEyeRenderOrderArrayLength()]); defaultEyeFov = new FovHVHalves[defaultOVREyeFov.length]; for(int i=0; i