summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/javax
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-02-25 17:27:23 +0100
committerSven Gothel <[email protected]>2012-02-25 17:27:23 +0100
commit9e66972c193399d6dcdf9e6662f4335bdf15736a (patch)
treeda7d45b883edc68b1fd279c5dbaf7b9b9a8b4951 /src/jogl/classes/javax
parent90e4f6aa688c9730bcdedea727031d5dccb32b39 (diff)
Fix GLProfile/GLDrawableFactory bug: Recursion on default desktop device, since no profile was mapped.
GLDrawableFactory*: - Initialize defaultDevice, even if impl. is not available (no GL libraries for impl.), hence - getDefaultDevice() always returns a valid device - getIsDeviceCompatible() only returns 'true' if device is supported _and_ drawable factory is functional GLProfile: - default-desktop-device becomes default-device even if the desktop-factory itself is not functional. This is due to the fact that the subsequent EGL-factory always handles desktop-devices (X11->EGL, GDI->EGL, etc).
Diffstat (limited to 'src/jogl/classes/javax')
-rw-r--r--src/jogl/classes/javax/media/opengl/GLDrawableFactory.java17
-rw-r--r--src/jogl/classes/javax/media/opengl/GLProfile.java56
2 files changed, 55 insertions, 18 deletions
diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
index 088ff054a..9a921091c 100644
--- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
+++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
@@ -240,13 +240,22 @@ public abstract class GLDrawableFactory {
* Retrieve the default <code>device</code> {@link AbstractGraphicsDevice#getConnection() connection},
* {@link AbstractGraphicsDevice#getUnitID() unit ID} and {@link AbstractGraphicsDevice#getUniqueID() unique ID name}. for this factory<br>
* The implementation must return a non <code>null</code> default device, which must not be opened, ie. it's native handle is <code>null</code>.
+ * <p>
+ * This method shall return the default device if available
+ * even if the GLDrawableFactory is not functional and hence not compatible.
+ * The latter situation may happen because no native OpenGL implementation is available for the specific implementation.
+ * </p>
* @return the default shared device for this factory, eg. :0.0 on X11 desktop.
+ * @see #getIsDeviceCompatible(AbstractGraphicsDevice)
*/
public abstract AbstractGraphicsDevice getDefaultDevice();
/**
* @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be <code>null</code> for the platform's default device.
- * @return true if the device is compatible with this factory, ie. if it can be used for creation. Otherwise false.
+ * @return true if the device is compatible with this factory, ie. if it can be used for GLDrawable creation. Otherwise false.
+ * This implies validation whether the implementation is functional.
+ *
+ * @see #getDefaultDevice()
*/
public abstract boolean getIsDeviceCompatible(AbstractGraphicsDevice device);
@@ -259,7 +268,11 @@ public abstract class GLDrawableFactory {
if (GLProfile.DEBUG) {
System.err.println("Info: GLDrawableFactory.validateDevice: using default device : "+device);
}
- } else if( !getIsDeviceCompatible(device) ) {
+ }
+
+ // Always validate the device,
+ // since even the default device may not be used by this factory.
+ if( !getIsDeviceCompatible(device) ) {
if (GLProfile.DEBUG) {
System.err.println("Info: GLDrawableFactory.validateDevice: device not compatible : "+device);
}
diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java
index 1e7346116..83e8e0bbf 100644
--- a/src/jogl/classes/javax/media/opengl/GLProfile.java
+++ b/src/jogl/classes/javax/media/opengl/GLProfile.java
@@ -1395,16 +1395,22 @@ public class GLProfile {
if(null!=t) {
t.printStackTrace();
}
- if(null == desktopFactory) {
- System.err.println("Info: GLProfile.init - Desktop GLDrawable factory not available");
- }
}
+ final AbstractGraphicsDevice defaultDesktopDevice;
if(null == desktopFactory) {
hasDesktopGLFactory = false;
hasGL234Impl = false;
+ defaultDesktopDevice = null;
+ if(DEBUG) {
+ System.err.println("Info: GLProfile.init - Desktop GLDrawable factory not available");
+ }
} else {
- defaultDevice = desktopFactory.getDefaultDevice();
+ defaultDesktopDevice = desktopFactory.getDefaultDevice();
+ defaultDevice = defaultDesktopDevice;
+ if(DEBUG) {
+ System.err.println("Info: GLProfile.init - Default device is desktop derived: "+defaultDevice);
+ }
}
if ( ReflectionUtil.isClassAvailable("jogamp.opengl.egl.EGLDrawableFactory", classloader) ) {
@@ -1430,22 +1436,36 @@ public class GLProfile {
if(null!=t) {
t.printStackTrace();
}
- if(null == eglFactory) {
- System.err.println("Info: GLProfile.init - EGL GLDrawable factory not available");
- }
}
}
+ final AbstractGraphicsDevice defaultEGLDevice;
if(null == eglFactory) {
hasGLES2Impl = false;
hasGLES1Impl = false;
- } else if(null == defaultDevice) {
- defaultDevice = eglFactory.getDefaultDevice();
+ defaultEGLDevice = null;
+ if(DEBUG) {
+ System.err.println("Info: GLProfile.init - EGL GLDrawable factory not available");
+ }
+ } else {
+ defaultEGLDevice = eglFactory.getDefaultDevice();
+ if(null == defaultDevice) {
+ defaultDevice = defaultEGLDevice;
+ if(DEBUG) {
+ System.err.println("Info: GLProfile.init - Default device is EGL derived: "+defaultDevice);
+ }
+ }
}
- final boolean addedAnyProfile = initProfilesForDevice(defaultDevice);
+ /** Should not be required .. but keep it here if simple probe on defaultDevice ain't enough.
+ final boolean addedDesktopProfile = initProfilesForDevice(defaultDesktopDevice);
+ final boolean addedEGLProfile = initProfilesForDevice(defaultEGLDevice);
+ final boolean addedAnyProfile = addedDesktopProfile || addedEGLProfile ;
+ */
+ final boolean addedAnyProfile = initProfilesForDevice(defaultDevice);
if(DEBUG) {
+ // System.err.println("GLProfile.init addedAnyProfile "+addedAnyProfile+" (desktop: "+addedDesktopProfile+", egl "+addedEGLProfile+")");
System.err.println("GLProfile.init addedAnyProfile "+addedAnyProfile);
System.err.println("GLProfile.init isAWTAvailable "+isAWTAvailable);
System.err.println("GLProfile.init hasDesktopGLFactory "+hasDesktopGLFactory);
@@ -1484,13 +1504,17 @@ public class GLProfile {
boolean isSet = GLContext.getAvailableGLVersionsSet(device);
if(DEBUG) {
- String msg = "Info: GLProfile.initProfilesForDevice: "+device+", isSet "+isSet;
- Throwable t = new Throwable(msg);
- t.printStackTrace();
- // System.err.println(msg);
+ System.err.println("Info: GLProfile.initProfilesForDevice: "+device+", isSet "+isSet);
+ Thread.dumpStack();
}
if(isSet) {
- return GLProfile.isAvailable(device, GL_DEFAULT);
+ // Avoid recursion and check whether impl. is sane!
+ final String deviceKey = device.getUniqueID();
+ HashMap<String /*GLProfile_name*/, GLProfile> map = deviceConn2ProfileMap.get(deviceKey);
+ if( null == map ) {
+ throw new InternalError("GLContext Avail. GLVersion is set - but no profile map for device: "+device);
+ }
+ return null != map.get(GL_DEFAULT);
}
boolean addedDesktopProfile = false;
@@ -1859,7 +1883,7 @@ public class GLProfile {
if(null==device) {
device = defaultDevice;
}
- String deviceKey = device.getUniqueID();
+ final String deviceKey = device.getUniqueID();
HashMap<String /*GLProfile_name*/, GLProfile> map = deviceConn2ProfileMap.get(deviceKey);
if( null != map ) {
return map;