diff options
author | Sven Gothel <[email protected]> | 2010-04-24 05:11:29 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2010-04-24 05:11:29 +0200 |
commit | 1ad8c39df6b097c80ba7a85badf555e7f669cc3f (patch) | |
tree | 740606f85dafdef5d5958498b080873c7bf188dd /src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java | |
parent | 778225504c00c7ca03386b6eabfbda929542130f (diff) |
NEWT/AWT Interoperability
- Moved all event classes to
com.jogamp.newt.event
and the new AWT event helper to
com.jogamp.newt.awt.event
- Added Newt<Type>Adapter for convenience
- Added AWT<Type>Adapter for
- Using AWT agnostic NEWT event listener
see com.jogamp.test.junit.jogl.demos.gl2.gears.TestGearsNEWT
even for AWT
see com.jogamp.test.junit.jogl.demos.gl2.gears.TestGearsAWT
(Nice idea by mbien)
- Forwarding AWT events to NEWT (refactoring)
Misc
- GLDrawableFactory.shutdown() is now protected and called
by the JVM shutdown hook. Hence removing the validate().
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java')
-rw-r--r-- | src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java b/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java index cdf5beb24..8f0299c1c 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java @@ -54,24 +54,10 @@ import java.lang.reflect.*; public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { protected static final boolean DEBUG = Debug.debug("GLDrawableFactory"); - private boolean isValid = false; - - public void shutdown() { - validate(); - isValid = false; - } - - protected final void validate() { - if(!isValid) { - throw new GLException("GLDrawableFactory is already shutdown!"); - } - } - //--------------------------------------------------------------------------- // Dispatching GLDrawable construction in respect to the NativeWindow Capabilities // public GLDrawable createGLDrawable(NativeWindow target) { - validate(); if (target == null) { throw new IllegalArgumentException("Null target"); } @@ -132,7 +118,6 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { GLCapabilitiesChooser chooser, int width, int height) { - validate(); if(height<=0 || height<=0) { throw new GLException("Width and height of pbuffer must be positive (were (" + width + ", " + height + "))"); @@ -148,7 +133,6 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { int width, int height, GLContext shareWith) { - validate(); return new GLPbufferImpl( (GLDrawableImpl) createGLPbufferDrawable(capabilities, chooser, height, height), shareWith); } @@ -165,7 +149,6 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { GLCapabilitiesChooser chooser, int width, int height) { - validate(); if(width<=0 || height<=0) { throw new GLException("Width and height of pbuffer must be positive (were (" + width + ", " + height + "))"); @@ -185,10 +168,30 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { protected abstract GLDrawableImpl getSharedDrawable(); protected abstract GLContextImpl getSharedContext(); + protected abstract void shutdown(); + + // Shutdown hook mechanism for the factory + private boolean factoryShutdownHookRegistered; + private Thread factoryShutdownHook; + private synchronized void registerFactoryShutdownHook() { + if (factoryShutdownHookRegistered) + return; + if (factoryShutdownHook == null) { + factoryShutdownHook = new Thread(new Runnable() { + public void run() { + synchronized (GLDrawableFactoryImpl.this) { + shutdown(); + } + } + }); + } + Runtime.getRuntime().addShutdownHook(factoryShutdownHook); + factoryShutdownHookRegistered = true; + } protected GLDrawableFactoryImpl() { super(); - isValid = true; + registerFactoryShutdownHook(); } protected void maybeDoSingleThreadedWorkaround(Runnable action) { @@ -294,7 +297,6 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { * out-of-bounds */ public boolean setDisplayGamma(float gamma, float brightness, float contrast) throws IllegalArgumentException { - validate(); if ((brightness < -1.0f) || (brightness > 1.0f)) { throw new IllegalArgumentException("Brightness must be between -1.0 and 1.0"); } @@ -327,7 +329,6 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { } public synchronized void resetDisplayGamma() { - validate(); if (gammaShutdownHook == null) { throw new IllegalArgumentException("Should not call this unless setDisplayGamma called first"); } |