From cc93cf413a59532bb31a4768c9d268234b859858 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 1 May 2012 03:19:57 +0200 Subject: EGLGraphicsConfigurationFactory: Add 'unregisterFactory()' static entry allowing to remove EGL/ES based factory --- .../opengl/egl/EGLGraphicsConfigurationFactory.java | 17 ++++++++++++++++- .../nativewindow/GraphicsConfigurationFactory.java | 17 +++++++++++++---- 2 files changed, 29 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java index 9d2973f05..904110eb2 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java @@ -73,6 +73,7 @@ import java.nio.IntBuffer; public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFactory { static VisualIDHolder.VIDComparator EglCfgIDComparator = new VisualIDHolder.VIDComparator(VisualIDHolder.VIDType.EGL_CONFIG); static GraphicsConfigurationFactory nativeGraphicsConfigurationFactory = null; + static GraphicsConfigurationFactory kdeglGraphicsConfigurationFactory = null; static void registerFactory() { GraphicsConfigurationFactory eglFactory = new EGLGraphicsConfigurationFactory(); @@ -87,7 +88,21 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact } */ // become the selector for KD/EGL .. - GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.egl.EGLGraphicsDevice.class, eglFactory); + kdeglGraphicsConfigurationFactory = GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.egl.EGLGraphicsDevice.class, eglFactory); + } + + static void unregisterFactory() { + final String nwType = NativeWindowFactory.getNativeWindowType(false); + if(NativeWindowFactory.TYPE_X11 == nwType) { + GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.x11.X11GraphicsDevice.class, nativeGraphicsConfigurationFactory); + } /* else if(NativeWindowFactory.TYPE_WINDOWS == NativeWindowFactory.getNativeWindowType(false)) { + GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.windows.WindowsGraphicsDevice.class, nativeGraphicsConfigurationFactory); + } else if(NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(false)) { + } */ + nativeGraphicsConfigurationFactory = null; + + GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.egl.EGLGraphicsDevice.class, kdeglGraphicsConfigurationFactory); + kdeglGraphicsConfigurationFactory = null; } private EGLGraphicsConfigurationFactory() { diff --git a/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java b/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java index e5f230b4c..2610f2cfa 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java @@ -190,10 +190,19 @@ public abstract class GraphicsConfigurationFactory { if (!(abstractGraphicsDeviceClass.isAssignableFrom(abstractGraphicsDeviceImplementor))) { throw new IllegalArgumentException("Given class must implement AbstractGraphicsDevice"); } - GraphicsConfigurationFactory prevFactory = registeredFactories.put(abstractGraphicsDeviceImplementor, factory); - if(DEBUG) { - System.err.println("GraphicsConfigurationFactory.registerFactory() "+abstractGraphicsDeviceImplementor+" -> "+factory+ - ", overridding: "+prevFactory); + final GraphicsConfigurationFactory prevFactory; + if(null == factory) { + prevFactory = registeredFactories.remove(abstractGraphicsDeviceImplementor); + if(DEBUG) { + System.err.println("GraphicsConfigurationFactory.registerFactory() remove "+abstractGraphicsDeviceImplementor+ + ", deleting: "+prevFactory); + } + } else { + prevFactory = registeredFactories.put(abstractGraphicsDeviceImplementor, factory); + if(DEBUG) { + System.err.println("GraphicsConfigurationFactory.registerFactory() put "+abstractGraphicsDeviceImplementor+" -> "+factory+ + ", overridding: "+prevFactory); + } } return prevFactory; } -- cgit v1.2.3