aboutsummaryrefslogtreecommitdiffstats
path: root/src/oculusvr
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2015-03-27 15:10:54 +0100
committerSven Gothel <[email protected]>2015-03-27 15:10:54 +0100
commitee2c18211a5128f5cde5312a7bbb5c0e80674903 (patch)
tree57ed742992fbe65c0e4cb501433c65a8c0775508 /src/oculusvr
parentd09a50bdc7aca2d441fe7c595711a44fe9dc4a23 (diff)
Bug 1116: Add ShutdownHook for all factories and devices to StereoDeviceFactory using NativeWindowFactory
Diffstat (limited to 'src/oculusvr')
-rw-r--r--src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDevice.java13
-rw-r--r--src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDeviceFactory.java17
2 files changed, 23 insertions, 7 deletions
diff --git a/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDevice.java b/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDevice.java
index fda554fdd..3abea5839 100644
--- a/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDevice.java
+++ b/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDevice.java
@@ -128,9 +128,16 @@ public class OVRStereoDevice implements StereoDevice {
@Override
public final void dispose() {
- OVR.ovrHmd_Destroy(hmdDesc);
- hmdDesc = null;
- handle = null;
+ if( isValid() ) {
+ OVR.ovrHmd_Destroy(hmdDesc);
+ hmdDesc = null;
+ handle = null;
+ }
+ }
+
+ @Override
+ public boolean isValid() {
+ return null != hmdDesc && null != handle;
}
@Override
diff --git a/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDeviceFactory.java b/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDeviceFactory.java
index eecc15c3f..772891115 100644
--- a/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDeviceFactory.java
+++ b/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDeviceFactory.java
@@ -63,12 +63,14 @@ public class OVRStereoDeviceFactory extends StereoDeviceFactory {
return false;
}
+ private boolean isValid = true;
+
private void dumpCaps(final ovrHmdDesc hmdDesc, final int deviceIndex) {
System.err.println(OVRVersion.getAvailableCapabilitiesInfo(hmdDesc, deviceIndex, null).toString());
}
@Override
- public final StereoDevice createDevice(final int deviceIndex, final StereoDeviceConfig config, final boolean verbose) {
+ protected final StereoDevice createDeviceImpl(final int deviceIndex, final StereoDeviceConfig config, final boolean verbose) {
final ovrHmdDesc hmdDesc = OVR.ovrHmd_Create(deviceIndex);
if( null == hmdDesc ) {
if( verbose ) {
@@ -86,12 +88,19 @@ public class OVRStereoDeviceFactory extends StereoDeviceFactory {
if( verbose ) {
dumpCaps(hmdDesc, deviceIndex);
}
- final OVRStereoDevice ctx = new OVRStereoDevice(this, hmdDesc, deviceIndex);
- return ctx;
+ return new OVRStereoDevice(this, hmdDesc, deviceIndex);
+ }
+
+ @Override
+ public boolean isValid() {
+ return isValid;
}
@Override
public final void shutdown() {
- OVR.ovr_Shutdown();
+ if( isValid ) {
+ OVR.ovr_Shutdown();
+ isValid = false;
+ }
}
}