diff options
-rwxr-xr-x | make/scripts/targetcommand-awt.sh | 2 | ||||
-rwxr-xr-x | make/scripts/tests.sh | 4 | ||||
-rw-r--r-- | src/jogl/classes/javax/media/opengl/awt/GLCanvas.java | 11 | ||||
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/jogl/awt/TestAWT01GLn.java | 60 |
4 files changed, 37 insertions, 40 deletions
diff --git a/make/scripts/targetcommand-awt.sh b/make/scripts/targetcommand-awt.sh index d776abd16..6bd4dd22c 100755 --- a/make/scripts/targetcommand-awt.sh +++ b/make/scripts/targetcommand-awt.sh @@ -18,7 +18,7 @@ XTRA_FLAGS="-Dnewt.test.Screen.disableScreenMode -Djogl.debug.EGL -Dnativewindow #TSTCLASS=com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT #TSTCLASS=com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestGLDrawable01AWT +TSTCLASS=com.jogamp.opengl.test.junit.jogl.awt.TestAWT01GLn mkdir -p $THISDIR/projects-cross diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 6aa69fa34..5a8d596df 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -274,7 +274,7 @@ function testawtswt() { #testawt javax.media.opengl.awt.GLCanvas $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug551AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT01GLn $* +testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT01GLn $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestAWTCloseX11DisplayBug565 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextNewtAWTBug523 $* @@ -411,8 +411,6 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* #linux: -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDrawable01NEWT $* # osx: #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 03fd78ac7..033591fe3 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -146,6 +146,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing private final GLDrawableHelper helper = new GLDrawableHelper(); private AWTGraphicsConfiguration awtConfig; private volatile GLDrawable drawable; // volatile: avoid locking for read-only access + private volatile JAWTWindow jawtWindow; // the JAWTWindow presentation of this AWT Canvas, bound to the 'drawable' lifecycle private GLContextImpl context; private volatile boolean sendReshape = false; // volatile: maybe written by EDT w/o locking @@ -268,9 +269,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing @Override public final boolean isOffscreenLayerSurfaceEnabled() { - final GLDrawable _drawable = drawable; - if(null != _drawable) { - return ((JAWTWindow)_drawable.getNativeSurface()).isOffscreenLayerSurfaceEnabled(); + final JAWTWindow _jawtWindow = jawtWindow; + if(null != _jawtWindow) { + return _jawtWindow.isOffscreenLayerSurfaceEnabled(); } return false; } @@ -539,7 +540,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing private void createDrawableAndContext() { // no lock required, since this resource ain't available yet - final JAWTWindow jawtWindow = (JAWTWindow) NativeWindowFactory.getNativeWindow(this, awtConfig); + jawtWindow = (JAWTWindow) NativeWindowFactory.getNativeWindow(this, awtConfig); jawtWindow.setShallUseOffscreenLayer(shallUseOffscreenLayer); jawtWindow.lockSurface(); try { @@ -811,11 +812,11 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing public void run() { context=null; if(null!=drawable) { - final JAWTWindow jawtWindow = (JAWTWindow)drawable.getNativeSurface(); drawable.setRealized(false); drawable=null; if(null!=jawtWindow) { jawtWindow.destroy(); + jawtWindow=null; } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestAWT01GLn.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestAWT01GLn.java index 64a1a0138..e1048c2f8 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestAWT01GLn.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestAWT01GLn.java @@ -40,49 +40,23 @@ import java.awt.Frame; import org.junit.Assert; import org.junit.Assume; -import org.junit.Before; import org.junit.BeforeClass; -import org.junit.After; import org.junit.Test; public class TestAWT01GLn extends UITestCase { - Frame frame=null; - GLCanvas glCanvas=null; - @BeforeClass public static void startup() { System.out.println("GLProfile "+GLProfile.glAvailabilityToString()); } - @Before - public void init() { - frame = new Frame("Texture Test"); - Assert.assertNotNull(frame); - } - - @After - public void release() { - Assert.assertNotNull(frame); - Assert.assertNotNull(glCanvas); - try { - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - frame.setVisible(false); - frame.remove(glCanvas); - frame.dispose(); - }}); - } catch (Throwable t) { - t.printStackTrace(); - Assume.assumeNoException(t); - } - frame=null; - glCanvas=null; - } - protected void runTestGL(GLCapabilities caps) throws InterruptedException { - glCanvas = new GLCanvas(caps); + final Frame frame = new Frame("Texture Test"); + Assert.assertNotNull(frame); + + final GLCanvas glCanvas = new GLCanvas(caps); Assert.assertNotNull(glCanvas); + glCanvas.addGLEventListener(new GearsES2()); frame.add(glCanvas); @@ -110,6 +84,18 @@ public class TestAWT01GLn extends UITestCase { Thread.sleep(500); // 500 ms animator.stop(); + + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setVisible(false); + frame.remove(glCanvas); + frame.dispose(); + }}); + } catch (Throwable t) { + t.printStackTrace(); + Assume.assumeNoException(t); + } } @Test @@ -136,6 +122,18 @@ public class TestAWT01GLn extends UITestCase { } } + @Test + public void test02ES2() throws InterruptedException { + if(GLProfile.isAvailable(GLProfile.GLES2)) { + GLProfile glprofile = GLProfile.get(GLProfile.GLES2); + System.out.println( "GLProfile GLES2: " + glprofile ); + GLCapabilities caps = new GLCapabilities(glprofile); + runTestGL(caps); + } else { + System.out.println("GLES2 n/a"); + } + } + public static void main(String args[]) { org.junit.runner.JUnitCore.main(TestAWT01GLn.class.getName()); } |