diff options
author | Sven Gothel <[email protected]> | 2010-12-19 00:29:04 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2010-12-19 00:29:04 +0100 |
commit | 5f67805a1cba7390cde0f862cbe4d4fcce3396ee (patch) | |
tree | d6f91f5076853ef40f702c91f1ec89972124acd4 | |
parent | d8293b3a8cf0974e10ea842b0652194799d6e801 (diff) |
GLDrawableFactory: Add getFactory(AbstractGraphicsDevice device)
-rw-r--r-- | src/jogl/classes/javax/media/opengl/GLDrawableFactory.java | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java index f9591e84d..78ca24be0 100644 --- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java +++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java @@ -47,7 +47,6 @@ import com.jogamp.common.util.ReflectionUtil; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.ArrayList; -import java.util.HashSet; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeSurface; @@ -298,6 +297,26 @@ public abstract class GLDrawableFactory { throw new GLException("No native platform GLDrawableFactory, nor EGLDrawableFactory available: "+glProfileImplName); } + /** + * Returns the sole GLDrawableFactory instance. + * + * @param device AbstractGraphicsDevice to determine the factory type, ie EGLDrawableFactory, + * or one of the native GLDrawableFactory's, ie X11/GLX, Windows/WGL or MacOSX/CGL. + */ + public static GLDrawableFactory getFactory(AbstractGraphicsDevice device) throws GLException { + return getFactoryImpl(device); + } + + protected static GLDrawableFactory getFactoryImpl(AbstractGraphicsDevice device) throws GLException { + if(null != nativeOSFactory && nativeOSFactory.getIsDeviceCompatible(device)) { + return nativeOSFactory; + } + if(null != eglFactory && eglFactory.getIsDeviceCompatible(device)) { + return eglFactory; + } + throw new GLException("No native platform GLDrawableFactory, nor EGLDrawableFactory available: "+device); + } + //---------------------------------------------------------------------- // Methods to create high-level objects |