From 9e66972c193399d6dcdf9e6662f4335bdf15736a Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 25 Feb 2012 17:27:23 +0100 Subject: 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). --- src/jogl/classes/javax/media/opengl/GLProfile.java | 56 +++++++++++++++------- 1 file changed, 40 insertions(+), 16 deletions(-) (limited to 'src/jogl/classes/javax/media/opengl/GLProfile.java') 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 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 map = deviceConn2ProfileMap.get(deviceKey); if( null != map ) { return map; -- cgit v1.2.3