aboutsummaryrefslogtreecommitdiffstats
path: root/src/oculusvr/classes/jogamp/opengl
diff options
context:
space:
mode:
Diffstat (limited to 'src/oculusvr/classes/jogamp/opengl')
-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;
+ }
}
}