aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/javax/media/opengl/GLDrawableFactory.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2008-06-28 14:30:26 +0000
committerSven Gothel <[email protected]>2008-06-28 14:30:26 +0000
commitd96486967efcfb6f43226da9fa60cbc3d68ab323 (patch)
treeadbda7e1a8fce8f3300c46dbba398783e4039a1e /src/classes/javax/media/opengl/GLDrawableFactory.java
parent8d00556b137564705a4ae8b963804d0adab078fb (diff)
3rd round cdcfp - compile clean.
Re-adding cdcfp: com/sun/opengl/impl/glu/mipmap/* com/sun/opengl/impl/GLPbufferImpl.java Using 'BufferUtil.nativeOrder(ByteBuffer)' to set up the native byte order. 'BufferUtil.nativeOrder' is now public. GLDrawableFactory: - removed 'hardcoded' awt attribute. Cleanup NEWT's AWT wrapping implementation. - NativeWindowFactory incooperates with the wrapping property. Bugs on X11/NEWT/AWT: - no events - deadlock at shutdown - deadlock if EGLDrawable with AWT get's locked git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1700 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/classes/javax/media/opengl/GLDrawableFactory.java')
-rw-r--r--src/classes/javax/media/opengl/GLDrawableFactory.java78
1 files changed, 50 insertions, 28 deletions
diff --git a/src/classes/javax/media/opengl/GLDrawableFactory.java b/src/classes/javax/media/opengl/GLDrawableFactory.java
index 2e6e2ccac..50cf96a33 100644
--- a/src/classes/javax/media/opengl/GLDrawableFactory.java
+++ b/src/classes/javax/media/opengl/GLDrawableFactory.java
@@ -90,7 +90,7 @@ public abstract class GLDrawableFactory {
// and if so, try to instantiate the EGLDrawableFactory
if (GLProfile.isGLES()) {
try {
- awtFactory = (GLDrawableFactory) GLReflection.createInstance("com.sun.opengl.impl.egl.awt.EGLDrawableFactory");
+ awtFactory = (GLDrawableFactory) GLReflection.createInstance("com.sun.opengl.impl.egl.awt.EGLAWTDrawableFactory");
return;
} catch (Exception e) {
e.printStackTrace();
@@ -134,6 +134,19 @@ public abstract class GLDrawableFactory {
}
}
+ private static GLDrawableFactory getAWTFactory()
+ throws GLException
+ {
+ if(null==GLProfile.getProfile()) {
+ throw new GLException("No choosen/preset profile");
+ }
+ initializeAWTFactory();
+ if(awtFactory == null) {
+ throw new GLException("Could not determine the AWT-GLDrawableFactory");
+ }
+ return awtFactory;
+ }
+
/** Initializes the sole GLDrawableFactory instance for the given profile. */
private static void initializeNWFactory() throws GLException {
if (nwFactory != null) {
@@ -183,51 +196,60 @@ public abstract class GLDrawableFactory {
}
}
+ private static GLDrawableFactory getNWFactory()
+ throws GLException
+ {
+ if(null==GLProfile.getProfile()) {
+ throw new GLException("No choosen/preset profile");
+ }
+ initializeNWFactory();
+ if(nwFactory == null) {
+ throw new GLException("Could not determine the NativeWindow-GLDrawableFactory");
+ }
+ return nwFactory;
+ }
+
/** Creates a new GLDrawableFactory instance. End users do not need
to call this method. */
protected GLDrawableFactory() {
}
- public static GLDrawableFactory getFactory(Object target)
+ /** Returns a GLDrawableFactory suitable to the passed winObj.
+ In case winObj is a NativeWindow, the wrapped window object will be used. */
+ public static GLDrawableFactory getFactory(Object winObj)
throws GLException
{
- if (target == null) {
- throw new IllegalArgumentException("target is null");
+ if (winObj == null) {
+ throw new IllegalArgumentException("winObj is null");
}
- if (target instanceof NativeWindow) {
- if (((NativeWindow) target).getWrappedWindow() != null) {
- target = ((NativeWindow) target).getWrappedWindow();
+ if ( winObj instanceof NativeWindow ) {
+ NativeWindow nw = (NativeWindow)winObj;
+ if(null!=nw.getWrappedWindow()) {
+ winObj = nw.getWrappedWindow();
}
}
- if (target instanceof NativeWindow) {
- return getFactory(false);
- } else if (NativeWindowFactory.isAWTComponent(target)) {
- return getFactory(true);
+ return getFactory(winObj.getClass());
+ }
+
+ /** Returns a GLDrawableFactory suitable to the passed winClazz. */
+ public static GLDrawableFactory getFactory(Class winClazz)
+ throws GLException
+ {
+ if (GLReflection.implementationOf(winClazz, NativeWindow.class.getName())) {
+ return getNWFactory();
+ } else if (GLReflection.isAWTComponent(winClazz)) {
+ return getAWTFactory();
}
throw new IllegalArgumentException("Target type is unsupported. Currently supported: \n"+
"\tjavax.media.opengl.NativeWindow\n"+
"\tjava.awt.Component\n");
}
- public static GLDrawableFactory getFactory(boolean awt)
+ /** Returns the common GLDrawableFactory, suitable for NativeWindow. */
+ public static GLDrawableFactory getFactory()
throws GLException
{
- if(null==GLProfile.getProfile()) {
- throw new GLException("No choosen/preset profile");
- }
- if(awt) {
- initializeAWTFactory();
- if(awtFactory == null) {
- throw new GLException("Could not determine the AWT-GLDrawableFactory");
- }
- return awtFactory;
- } else {
- initializeNWFactory();
- if(nwFactory == null) {
- throw new GLException("Could not determine the NativeWindow-GLDrawableFactory");
- }
- return nwFactory;
- }
+ return getNWFactory();
}
/** Shuts down this GLDrawableFactory, releasing resources