aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2015-03-27 14:25:07 +0100
committerSven Gothel <[email protected]>2015-03-27 14:25:07 +0100
commitd09a50bdc7aca2d441fe7c595711a44fe9dc4a23 (patch)
tree54c676d1dd10c8afdb48018e6d5cdc5b4d24835c /src
parent3b7a8f5f4e89adf84fd871c1440859ed3d89802e (diff)
Bug 1116: Oculus SDK 0.4.4: Add extra DK1 detection; Add call to ovr_Shutdown() and ovrHmd_Destroy(hmdDesc).
Add extra DK1 detection - SDK 0.4.4 w/ DK1 (Linux): ovrHmd_Detect() returns zero! - In such case: Try creating one device, which works for DK1 on Linux Add call to ovr_Shutdown() and ovrHmd_Destroy(hmdDesc). - Add StereoDeviceFactory.shutdown() and call ovr_Shutdown() for in OVRStereoDeviceFactory.shutdown(). - Call ovrHmd_Destroy(hmdDesc) in OVRStereoDevice.dispose().
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/stereo/StereoDeviceFactory.java5
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/stereo/generic/GenericStereoDeviceFactory.java5
-rw-r--r--src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDevice.java8
-rw-r--r--src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDeviceFactory.java27
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/stereo/StereoDemo01.java1
5 files changed, 42 insertions, 4 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoDeviceFactory.java b/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoDeviceFactory.java
index 13aa2e891..3847b7d3e 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoDeviceFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoDeviceFactory.java
@@ -107,4 +107,9 @@ public abstract class StereoDeviceFactory {
* @return
*/
public abstract StereoDevice createDevice(final int deviceIndex, final StereoDeviceConfig config, final boolean verbose);
+
+ /**
+ * Shutdown factory
+ */
+ public abstract void shutdown();
}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/stereo/generic/GenericStereoDeviceFactory.java b/src/jogl/classes/com/jogamp/opengl/util/stereo/generic/GenericStereoDeviceFactory.java
index 1d5000c97..9c28c0767 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/stereo/generic/GenericStereoDeviceFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/stereo/generic/GenericStereoDeviceFactory.java
@@ -190,4 +190,9 @@ public class GenericStereoDeviceFactory extends StereoDeviceFactory {
public final StereoDevice createDevice(final int deviceIndex, final StereoDeviceConfig config, final boolean verbose) {
return new GenericStereoDevice(this, deviceIndex, config);
}
+
+ @Override
+ public void shutdown() {
+ // NOP
+ }
}
diff --git a/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDevice.java b/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDevice.java
index 89f7797ae..fda554fdd 100644
--- a/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDevice.java
+++ b/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDevice.java
@@ -49,11 +49,11 @@ public class OVRStereoDevice implements StereoDevice {
private static final float[] DEFAULT_EYE_POSITION_OFFSET = { 0.0f, 1.6f, -5.0f };
private final StereoDeviceFactory factory;
- public final OvrHmdContext handle;
public final int deviceIndex;
- public final ovrHmdDesc hmdDesc;
private final FovHVHalves[] defaultEyeFov;
+ public ovrHmdDesc hmdDesc;
+ public OvrHmdContext handle;
private boolean sensorsStarted = false;
private final int[] eyeRenderOrder;
private final int supportedDistortionBits, recommendedDistortionBits, minimumDistortionBits;
@@ -128,7 +128,9 @@ public class OVRStereoDevice implements StereoDevice {
@Override
public final void dispose() {
- // NOP
+ OVR.ovrHmd_Destroy(hmdDesc);
+ hmdDesc = null;
+ handle = null;
}
@Override
diff --git a/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDeviceFactory.java b/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDeviceFactory.java
index 21d6cab7b..eecc15c3f 100644
--- a/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDeviceFactory.java
+++ b/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDeviceFactory.java
@@ -29,6 +29,7 @@ package jogamp.opengl.oculusvr;
import com.jogamp.oculusvr.OVR;
import com.jogamp.oculusvr.OVRVersion;
+import com.jogamp.oculusvr.OvrHmdContext;
import com.jogamp.oculusvr.ovrHmdDesc;
import com.jogamp.opengl.util.stereo.StereoDeviceConfig;
import com.jogamp.opengl.util.stereo.StereoDevice;
@@ -38,7 +39,26 @@ public class OVRStereoDeviceFactory extends StereoDeviceFactory {
public static boolean isAvailable() {
if( OVR.ovr_Initialize() ) { // recursive ..
- return 0 < OVR.ovrHmd_Detect();
+ boolean res = false;
+ final int count = OVR.ovrHmd_Detect();
+ System.err.println("Detect.0: ovrHmd_Detect() -> "+count);
+ if( 0 < count ) {
+ res = true;
+ } else {
+ // SDK 0.4.4 w/ DK1 (Linux): ovrHmd_Detect() returns zero!
+ final ovrHmdDesc hmdDesc = OVR.ovrHmd_Create(0);
+ if( null != hmdDesc ) {
+ final OvrHmdContext ctx = hmdDesc.getHandle();
+ if( null != ctx ) {
+ res = true;
+ System.err.println("Detect.1: hmdDesc: "+hmdDesc.getProductNameAsString());
+ }
+ OVR.ovrHmd_Destroy(hmdDesc);
+ }
+ }
+ return res;
+ } else {
+ System.err.println("ovr_Initialize() failed");
}
return false;
}
@@ -69,4 +89,9 @@ public class OVRStereoDeviceFactory extends StereoDeviceFactory {
final OVRStereoDevice ctx = new OVRStereoDevice(this, hmdDesc, deviceIndex);
return ctx;
}
+
+ @Override
+ public final void shutdown() {
+ OVR.ovr_Shutdown();
+ }
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/stereo/StereoDemo01.java b/src/test/com/jogamp/opengl/test/junit/jogl/stereo/StereoDemo01.java
index 37c7d0e1a..693f2f72b 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/stereo/StereoDemo01.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/stereo/StereoDemo01.java
@@ -375,5 +375,6 @@ public class StereoDemo01 {
window.destroy();
screen.removeReference(); // StereoDeviceUtil.getMonitorDevice(stereoDevice, true);
stereoDevice.dispose();
+ stereoDeviceFactory.shutdown();
}
}