aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl
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
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')
-rw-r--r--src/jogl/classes/javax/media/opengl/GLDrawableFactory.java17
-rw-r--r--src/jogl/classes/javax/media/opengl/GLProfile.java56
-rw-r--r--src/jogl/classes/jogamp/opengl/GLContextImpl.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java8
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java5
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java5
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java9
7 files changed, 71 insertions, 31 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;
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
index f9e8a60db..b87437088 100644
--- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
@@ -547,7 +547,7 @@ public abstract class GLContextImpl extends GLContext {
ctxMajorVersion, ctxMinorVersion, ctxOptions);
GLContext.setAvailableGLVersionsSet(device);
if (DEBUG) {
- System.err.println(getThreadName() + ": createContextOLD-MapVersionsAvailable HAVE: " +reqMajor+"."+reqProfile+ " -> "+getGLVersion());
+ System.err.println(getThreadName() + ": createContextOLD-MapVersionsAvailable HAVE: " + device+" -> "+reqMajor+"."+reqProfile+ " -> "+getGLVersion());
}
}
}
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java
index 2a6985d90..1ab66674b 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java
@@ -70,6 +70,8 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
} catch (JogampRuntimeException jre) { /* n/a .. */ }
}
+ defaultDevice = new EGLGraphicsDevice(AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT);
+
// FIXME: Probably need to move EGL from a static model
// to a dynamic one, where there can be 2 instances
// for each ES profile with their own ProcAddressTable.
@@ -139,9 +141,6 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
}
}
}
- if(null != eglES1DynamicLookupHelper || null != eglES2DynamicLookupHelper) {
- defaultDevice = new EGLGraphicsDevice(AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT);
- }
}
protected final void destroy(ShutdownType shutdownType) {
@@ -206,7 +205,8 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
}
public final boolean getIsDeviceCompatible(AbstractGraphicsDevice device) {
- return true; // via mappings (X11/WGL/.. -> EGL) we shall be able to handle all types.
+ // via mappings (X11/WGL/.. -> EGL) we shall be able to handle all types.
+ return null==eglES2DynamicLookupHelper || null==eglES1DynamicLookupHelper;
}
/**
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java
index 91d05f945..5327f7bf5 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java
@@ -97,6 +97,8 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
}
}
+ defaultDevice = new MacOSXGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT);
+
if(null!=macOSXCGLDynamicLookupHelper) {
// Register our GraphicsConfigurationFactory implementations
// The act of constructing them causes them to be registered
@@ -108,7 +110,6 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
} catch (JogampRuntimeException jre) { /* n/a .. */ }
}
- defaultDevice = new MacOSXGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT);
sharedMap = new HashMap<String, SharedResource>();
}
}
@@ -167,7 +168,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
}
public final boolean getIsDeviceCompatible(AbstractGraphicsDevice device) {
- if(device instanceof MacOSXGraphicsDevice) {
+ if(null!=macOSXCGLDynamicLookupHelper && device instanceof MacOSXGraphicsDevice) {
return true;
}
return false;
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java
index 6784ddded..9ddab4239 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java
@@ -103,6 +103,8 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
}
}
+ defaultDevice = new WindowsGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT);
+
if(null!=windowsWGLDynamicLookupHelper) {
// Register our GraphicsConfigurationFactory implementations
// The act of constructing them causes them to be registered
@@ -114,7 +116,6 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
} catch (JogampRuntimeException jre) { /* n/a .. */ }
}
- defaultDevice = new WindowsGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT);
sharedMap = new HashMap<String, SharedResourceRunner.Resource>();
// Init shared resources off thread
@@ -379,7 +380,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
}
public final boolean getIsDeviceCompatible(AbstractGraphicsDevice device) {
- if(device instanceof WindowsGraphicsDevice) {
+ if(null!=windowsWGLDynamicLookupHelper && device instanceof WindowsGraphicsDevice) {
return true;
}
return false;
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java
index d356e64c6..4f333406f 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java
@@ -101,12 +101,13 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
}
}
+ defaultDevice = new X11GraphicsDevice(X11Util.getNullDisplayName(), AbstractGraphicsDevice.DEFAULT_UNIT);
+
if(null!=x11GLXDynamicLookupHelper) {
// Register our GraphicsConfigurationFactory implementations
// The act of constructing them causes them to be registered
X11GLXGraphicsConfigurationFactory.registerFactory();
- defaultDevice = new X11GraphicsDevice(X11Util.getNullDisplayName(), AbstractGraphicsDevice.DEFAULT_UNIT);
sharedMap = new HashMap<String, SharedResourceRunner.Resource>();
// Init shared resources off thread
@@ -139,7 +140,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
X11Util.shutdown( false, DEBUG );
}
- public GLDynamicLookupHelper getGLDynamicLookupHelper(int profile) {
+ public final GLDynamicLookupHelper getGLDynamicLookupHelper(int profile) {
return x11GLXDynamicLookupHelper;
}
@@ -219,7 +220,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
// NativeWindowFactory.getNullToolkitLock(), true); // own non-shared display connection, no locking
sharedDevice.lock();
try {
- GLXUtil.initGLXClientDataSingleton(sharedDevice);
+ GLXUtil.initGLXClientDataSingleton(sharedDevice);
final String glXServerVendorName = GLX.glXQueryServerString(sharedDevice.getHandle(), 0, GLX.GLX_VENDOR);
final VersionNumber glXServerVersion = GLXUtil.getGLXServerVersionNumber(sharedDevice.getHandle());
final boolean glXServerMultisampleAvailable = GLXUtil.isMultisampleAvailable(GLX.glXQueryServerString(sharedDevice.getHandle(), 0, GLX.GLX_EXTENSIONS));
@@ -310,7 +311,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
}
public final boolean getIsDeviceCompatible(AbstractGraphicsDevice device) {
- if(device instanceof X11GraphicsDevice) {
+ if(null != x11GLXDynamicLookupHelper && device instanceof X11GraphicsDevice) {
return true;
}
return false;