diff options
author | Sven Gothel <[email protected]> | 2010-12-19 00:24:59 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2010-12-19 00:24:59 +0100 |
commit | d8293b3a8cf0974e10ea842b0652194799d6e801 (patch) | |
tree | 0ae835548c574107e69b0ccf63a1168b89fd4961 /src/jogl | |
parent | e1682f8cd5eab26b12c868f19ff3adc544098077 (diff) |
Fix GLProfile initProfilesForDevice and DEBUG ; Fix JoglVersion.getGLInfo
GLProfile.initProfilesForDevice: use either desktop or egl factory on one device
GLProfile.DEBUG: Print proper factory instance, full device
JoglVersion.getGLInfo: Print only availability of used device, otherwise we could kick off initialization
Diffstat (limited to 'src/jogl')
-rw-r--r-- | src/jogl/classes/com/jogamp/opengl/JoglVersion.java | 10 | ||||
-rw-r--r-- | src/jogl/classes/javax/media/opengl/GLProfile.java | 61 |
2 files changed, 36 insertions, 35 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/JoglVersion.java b/src/jogl/classes/com/jogamp/opengl/JoglVersion.java index b096f84ae..b1db2974a 100644 --- a/src/jogl/classes/com/jogamp/opengl/JoglVersion.java +++ b/src/jogl/classes/com/jogamp/opengl/JoglVersion.java @@ -33,8 +33,10 @@ import javax.media.opengl.*; import com.jogamp.common.os.Platform; import com.jogamp.common.util.VersionUtil; import com.jogamp.common.util.JogampVersion; +import com.jogamp.common.util.ReflectionUtil; import com.jogamp.nativewindow.NativeWindowVersion; import java.util.jar.Manifest; +import javax.media.nativewindow.AbstractGraphicsDevice; public class JoglVersion extends JogampVersion { @@ -68,15 +70,17 @@ public class JoglVersion extends JogampVersion { } public static StringBuffer getGLInfo(GL gl, StringBuffer sb) { + AbstractGraphicsDevice device = gl.getContext().getGLDrawable().getNativeSurface() + .getGraphicsConfiguration().getNativeGraphicsConfiguration().getScreen().getDevice(); if(null==sb) { sb = new StringBuffer(); } GLContext ctx = gl.getContext(); sb.append(VersionUtil.SEPERATOR).append(Platform.getNewline()); - sb.append("Default Desktop ").append(GLProfile.getDefaultDesktopDevice().getConnection()).append(": ").append(GLProfile.glAvailabilityToString(GLProfile.getDefaultDesktopDevice())); - sb.append(Platform.getNewline()); - sb.append("Default EGL ").append(GLProfile.getDefaultEGLDevice().getConnection()).append(": ").append(GLProfile.glAvailabilityToString(GLProfile.getDefaultEGLDevice())); + sb.append(ReflectionUtil.getBaseName(device.getClass())).append("[type ") + .append(device.getType()).append(", connection ").append(device.getConnection()).append("]: ") + .append(GLProfile.glAvailabilityToString(device)); sb.append(Platform.getNewline()); sb.append("Swap Interval ").append(gl.getSwapInterval()); sb.append(Platform.getNewline()); diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java index 05c78b17b..378d3df9c 100644 --- a/src/jogl/classes/javax/media/opengl/GLProfile.java +++ b/src/jogl/classes/javax/media/opengl/GLProfile.java @@ -1087,7 +1087,6 @@ public class GLProfile { * Throws an GLException if no profile could be found at all. */ private static void initProfilesForDefaultDevices(boolean firstUIActionOnProcess) { - NativeWindowFactory.initSingleton(firstUIActionOnProcess); if(DEBUG) { @@ -1192,7 +1191,7 @@ public class GLProfile { boolean addedAnyProfile = initProfilesForDevice(defaultDesktopDevice) || initProfilesForDevice(defaultEGLDevice); - + if(DEBUG) { System.err.println("GLProfile.init isAWTAvailable "+isAWTAvailable); System.err.println("GLProfile.init has desktopFactory "+(null!=desktopFactory)); @@ -1201,8 +1200,8 @@ public class GLProfile { System.err.println("GLProfile.init has eglFactory "+(null!=eglFactory)); System.err.println("GLProfile.init hasGLES1Impl "+hasGLES1Impl); System.err.println("GLProfile.init hasGLES2Impl "+hasGLES2Impl); - System.err.println("GLProfile.init defaultDesktopDevice "+defaultDevice); - System.err.println("GLProfile.init defaultEGLDevice "+defaultDevice); + System.err.println("GLProfile.init defaultDesktopDevice "+defaultDesktopDevice); + System.err.println("GLProfile.init defaultEGLDevice "+defaultEGLDevice); System.err.println("GLProfile.init defaultDevice "+defaultDevice); } @@ -1216,10 +1215,13 @@ public class GLProfile { * @return true if any profile for the device exists, otherwise false */ private static synchronized boolean initProfilesForDevice(AbstractGraphicsDevice device) { + if(null == device) { + return false; + } boolean isSet = GLContext.getAvailableGLVersionsSet(device); if(DEBUG) { - String msg = "Info: GLProfile.initProfilesForDevice: "+device.getConnection()+", isSet "+isSet; + String msg = "Info: GLProfile.initProfilesForDevice: "+device+", isSet "+isSet; Throwable t = new Throwable(msg); t.printStackTrace(); // System.err.println(msg); @@ -1239,7 +1241,7 @@ public class GLProfile { // hence querying all available GLProfiles boolean desktopSharedCtxAvail = desktopFactory.getIsSharedContextAvailable(device); if (DEBUG) { - System.err.println("GLProfile.initProfilesForDevice: "+device.getConnection()+": desktop Shared Ctx "+desktopSharedCtxAvail); + System.err.println("GLProfile.initProfilesForDevice: "+device+": desktop Shared Ctx "+desktopSharedCtxAvail); } if( null == GLContext.getAvailableGLVersion(device, 2, GLContext.CTX_PROFILE_COMPAT) ) { // nobody yet set the available desktop versions, see {@link GLContextImpl#makeCurrent}, @@ -1248,13 +1250,8 @@ public class GLProfile { 2, GLContext.CTX_PROFILE_COMPAT, 1, 5, GLContext.CTX_PROFILE_COMPAT|GLContext.CTX_OPTION_ANY); } - computeProfileMap(device, false /* desktopCtxUndef*/, false /* eglCtxUndef */); - addedDesktopProfile = null != GLProfile.getDefault(device); - } else if(DEBUG) { - System.err.println("GLProfile: DesktopFactory - Device is not available: "+device.getConnection()); - } - - if( null!=eglFactory && ( hasGLES2Impl || hasGLES1Impl ) && eglFactory.getIsDeviceCompatible(device)) { + addedDesktopProfile = computeProfileMap(device, false /* desktopCtxUndef*/, false /* eglCtxUndef */); + } else if( null!=eglFactory && ( hasGLES2Impl || hasGLES1Impl ) && eglFactory.getIsDeviceCompatible(device)) { // 1st pretend we have all EGL profiles .. computeProfileMap(device, false /* desktopCtxUndef*/, true /* eglCtxUndef */); @@ -1262,7 +1259,7 @@ public class GLProfile { // hence querying all available GLProfiles boolean eglSharedCtxAvail = eglFactory.getIsSharedContextAvailable(device); if (DEBUG) { - System.err.println("GLProfile.initProfilesForDevice: "+device.getConnection()+": egl Shared Ctx "+eglSharedCtxAvail); + System.err.println("GLProfile.initProfilesForDevice: "+device+": egl Shared Ctx "+eglSharedCtxAvail); } if(hasGLES2Impl && null == GLContext.getAvailableGLVersion(device, 2, GLContext.CTX_PROFILE_ES) ) { // nobody yet set the available desktop versions, see {@link GLContextImpl#makeCurrent}, @@ -1278,10 +1275,12 @@ public class GLProfile { 1, GLContext.CTX_PROFILE_ES, 1, 0, GLContext.CTX_PROFILE_ES|GLContext.CTX_OPTION_ANY); } - computeProfileMap(device, false /* desktopCtxUndef*/, false /* eglCtxUndef */); - addedEGLProfile = null != GLProfile.get(device, GL_PROFILE_LIST_GLES); - } else if(DEBUG) { - System.err.println("GLProfile: EGLFactory - Device is not available: "+device.getConnection()); + addedEGLProfile = computeProfileMap(device, false /* desktopCtxUndef*/, false /* eglCtxUndef */); + } else { + setProfileMap(device, new HashMap()); // empty + if(DEBUG) { + System.err.println("GLProfile: EGLFactory - Device is not available: "+device); + } } if(!GLContext.getAvailableGLVersionsSet(device)) { @@ -1293,8 +1292,7 @@ public class GLProfile { System.err.println("GLProfile.initProfilesForDevice: "+device.getConnection()+": "+glAvailabilityToString(device)); if(addedDesktopProfile) { dumpGLInfo(desktopFactory, device); - } - if(addedEGLProfile) { + } else if(addedEGLProfile) { dumpGLInfo(eglFactory, device); } } @@ -1304,17 +1302,16 @@ public class GLProfile { private static void dumpGLInfo(GLDrawableFactoryImpl factory, AbstractGraphicsDevice device) { GLContext ctx = factory.getOrCreateSharedContext(device); - AbstractGraphicsDevice nativeDevice = ctx.getGLDrawable().getNativeSurface() - .getGraphicsConfiguration().getNativeGraphicsConfiguration() - .getScreen().getDevice(); - nativeDevice.lock(); + System.err.println("GLProfile.dumpGLInfo: "+ctx); + ctx.makeCurrent(); try { - ctx.makeCurrent(); + System.err.println("GLProfile.dumpGLInfo: p2"); System.err.println(JoglVersion.getGLInfo(ctx.getGL(), null)); - ctx.release(); + System.err.println("GLProfile.dumpGLInfo: p3"); } finally { - nativeDevice.unlock(); + ctx.release(); } + System.err.println("GLProfile.dumpGLInfo: p4"); } public static AbstractGraphicsDevice getDefaultDevice() { @@ -1364,7 +1361,7 @@ public class GLProfile { sb.append("]"); } - private static void computeProfileMap(AbstractGraphicsDevice device, boolean desktopCtxUndef, boolean eglCtxUndef) { + private static boolean computeProfileMap(AbstractGraphicsDevice device, boolean desktopCtxUndef, boolean eglCtxUndef) { if (DEBUG) { System.err.println("GLProfile.init map "+device.getConnection()+", desktopCtxUndef "+desktopCtxUndef+", eglCtxUndef "+eglCtxUndef); } @@ -1395,6 +1392,7 @@ public class GLProfile { _mappedProfiles.put(GL_DEFAULT, defaultGLProfile); } setProfileMap(device, _mappedProfiles); + return _mappedProfiles.size() > 0; } /** @@ -1494,11 +1492,10 @@ public class GLProfile { String deviceKey = device.getUniqueID(); HashMap map = (HashMap) deviceConn2ProfileMap.get(deviceKey); if(null==map) { - map = new HashMap(); - synchronized ( deviceConn2ProfileMap ) { - deviceConn2ProfileMap.put(deviceKey, map); - } initProfilesForDevice(device); + if( null == deviceConn2ProfileMap.get(deviceKey) ) { + throw new InternalError("initProfilesForDevice(..) didn't issue setProfileMap(..) on "+device); + } } return map; } |