28package com.jogamp.opengl.util.stereo;
30import java.lang.ref.WeakReference;
31import java.util.ArrayList;
33import com.jogamp.common.util.ReflectionUtil;
34import com.jogamp.nativewindow.NativeWindowFactory;
48 private static final String OVRStereoDeviceClazzName =
"jogamp.opengl.oculusvr.OVRStereoDeviceFactory";
49 private static final String GenericStereoDeviceClazzName = com.jogamp.opengl.util.stereo.generic.GenericStereoDeviceFactory.class.getName();
50 private static final String isAvailableMethodName =
"isAvailable";
94 final String className;
97 case Generic: className = GenericStereoDeviceClazzName;
break;
98 case OculusVR: className = OVRStereoDeviceClazzName;
break;
99 default:
throw new InternalError(
"Unsupported type "+type);
108 if(((Boolean)ReflectionUtil.callStaticMethod(implName, isAvailableMethodName,
null,
null, cl)).booleanValue()) {
111 }
catch (
final Throwable t) {
if(
StereoDevice.
DEBUG) { System.err.println(
"Caught "+t.getClass().getName()+
": "+t.getMessage()); t.printStackTrace(); } }
113 addFactory2List(res);
127 if(
null != device ) {
128 addDevice2List(device);
145 private static final ArrayList<WeakReference<StereoDeviceFactory>> factoryList =
new ArrayList<WeakReference<StereoDeviceFactory>>();
147 synchronized(factoryList) {
150 while( i < factoryList.size() ) {
151 if(
null == factoryList.get(i).get() ) {
152 factoryList.remove(i);
157 factoryList.add(
new WeakReference<StereoDeviceFactory>(factory));
160 private static final ArrayList<WeakReference<StereoDevice>> deviceList =
new ArrayList<WeakReference<StereoDevice>>();
161 private static void addDevice2List(
final StereoDevice device) {
162 synchronized(deviceList) {
165 while( i < deviceList.size() ) {
166 if(
null == deviceList.get(i).get() ) {
167 deviceList.remove(i);
172 deviceList.add(
new WeakReference<StereoDevice>(device));
176 private final static void shutdownAll() {
180 private final static void shutdownFactories() {
181 while( 0 < factoryList.size() ) {
182 final StereoDeviceFactory f = factoryList.remove(0).get();
183 if(
null != f && f.isValid() ) {
188 private final static void shutdownDevices() {
189 while( 0 < deviceList.size() ) {
190 final StereoDevice d = deviceList.remove(0).get();
191 if(
null != d && d.isValid() ) {
Provides a pluggable mechanism for arbitrary window toolkits to adapt their components to the NativeW...
static void addCustomShutdownHook(final boolean head, final Runnable runnable)
Add a custom shutdown hook to be performed at JVM shutdown before shutting down NativeWindowFactory i...
Merely a class providing a type-tag for extended configuration.
Platform agnostic StereoDevice factory.
abstract void shutdown()
Shutdown factory if valid.
static StereoDeviceFactory createDefaultFactory()
static StereoDeviceFactory createFactory(final ClassLoader cl, final String implName)
abstract StereoDevice createDeviceImpl(final int deviceIndex, final StereoDeviceConfig config, final boolean verbose)
static StereoDeviceFactory createFactory(final DeviceType type)
final StereoDevice createDevice(final int deviceIndex, final StereoDeviceConfig config, final boolean verbose)
abstract boolean isValid()
Returns true, if instance is created and not shutdown() otherwise returns false.
StereoDevice type used for createFactory(type).
Default
Auto selection of device in the following order:
Generic
Generic software implementation.
OculusVR
OculusVR DK1 implementation.
Interface describing a native stereoscopic device.
static final boolean DEBUG