From 9a4fcc7ea4ec61e4ceed791acced734ac04ea270 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 27 Mar 2013 12:27:57 +0100 Subject: SharedRessourceRunner: Add isDeviceSupported(..) query before spawn off thread, allowing a more gracefull detection of n/a GLX on X11 --- src/jogl/classes/jogamp/opengl/SharedResourceRunner.java | 12 ++++++++++-- .../opengl/windows/wgl/WindowsWGLDrawableFactory.java | 5 +++++ .../jogamp/opengl/x11/glx/X11GLXDrawableFactory.java | 16 ++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) (limited to 'src/jogl/classes') diff --git a/src/jogl/classes/jogamp/opengl/SharedResourceRunner.java b/src/jogl/classes/jogamp/opengl/SharedResourceRunner.java index a33e03a1a..7e050c81e 100644 --- a/src/jogl/classes/jogamp/opengl/SharedResourceRunner.java +++ b/src/jogl/classes/jogamp/opengl/SharedResourceRunner.java @@ -44,6 +44,12 @@ public class SharedResourceRunner implements Runnable { } public static interface Implementation { + /** + * @param connection for creation a {@link AbstractGraphicsDevice} instance. + * @return true if the device supports all protocols required for the implementation, otherwise false. + */ + boolean isDeviceSupported(String connection); + /** * @param connection for creation a {@link AbstractGraphicsDevice} instance. * @return A new shared resource instance @@ -157,8 +163,10 @@ public class SharedResourceRunner implements Runnable { if (DEBUG) { System.err.println("SharedResourceRunner.getOrCreateShared() " + connection + ": trying - "+Thread.currentThread().getName()); } - doAndWait(connection, null); - sr = impl.mapGet(connection); + if ( impl.isDeviceSupported(connection) ) { + doAndWait(connection, null); + sr = impl.mapGet(connection); + } if (DEBUG) { System.err.println("SharedResourceRunner.getOrCreateShared() " + connection + ": "+ ( ( null != sr ) ? "success" : "failed" ) +" - "+Thread.currentThread().getName()); } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java index c6bc61a27..9c96f3e3c 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java @@ -308,6 +308,11 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { } } + @Override + public boolean isDeviceSupported(String connection) { + return true; + } + @Override public SharedResourceRunner.Resource createSharedResource(String connection) { final WindowsGraphicsDevice sharedDevice = new WindowsGraphicsDevice(connection, AbstractGraphicsDevice.DEFAULT_UNIT); diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java index e38aabef8..8d1717e75 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java @@ -227,6 +227,22 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { } } + @Override + public boolean isDeviceSupported(String connection) { + final boolean res; + final X11GraphicsDevice x11Device = new X11GraphicsDevice(X11Util.openDisplay(connection), AbstractGraphicsDevice.DEFAULT_UNIT, true /* owner */); + x11Device.lock(); + try { + res = GLXUtil.isGLXAvailableOnServer(x11Device); + } finally { + x11Device.unlock(); + } + if(DEBUG) { + System.err.println("GLX "+(res ? "is" : "not")+" available on device/server: "+x11Device); + } + return res; + } + @Override public SharedResourceRunner.Resource createSharedResource(String connection) { final X11GraphicsDevice sharedDevice = new X11GraphicsDevice(X11Util.openDisplay(connection), AbstractGraphicsDevice.DEFAULT_UNIT, true /* owner */); -- cgit v1.2.3