From 9d78ea65a6bf1064887bc7524c01a689a1fc2a5c Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 13 Apr 2013 08:15:21 +0200 Subject: NEWT/AWT: Fix 'AWT driver' to work w/ OSX CALayer ; WindowImpl: 'Object getWrappedWindow()' -> 'NativeSurface getWrappedSurface()' WindowImpl: 'Object getWrappedWindow()' -> 'NativeSurface getWrappedSurface()' - AWT driver itself instantiates the JAWTWindow for eager initialization at createNative(). Fix 'AWT driver' to work w/ OSX CALayer - See above - size reconfig changed to ease OSX CALayer, i.e. set frame's size if already visible reducing CALayer artefacts. --- .../opengl/test/junit/jogl/demos/es2/GearsES2.java | 2 +- .../demos/gl2/newt/TestGearsNewtAWTWrapper.java | 68 +++++++++++++--------- 2 files changed, 43 insertions(+), 27 deletions(-) (limited to 'src/test/com') diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java index 5e523c780..9bbbbce05 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java @@ -270,7 +270,7 @@ public class GearsES2 implements GLEventListener { public void display(GLAutoDrawable drawable) { GLAnimatorControl anim = drawable.getAnimator(); if( verbose && ( null == anim || !anim.isAnimating() ) ) { - System.err.println(Thread.currentThread()+" GearsES2.display"+drawable.getWidth()+"x"+drawable.getHeight()+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(drawable.getHandle())); + System.err.println(Thread.currentThread()+" GearsES2.display "+drawable.getWidth()+"x"+drawable.getHeight()+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(drawable.getHandle())); } // Turn the gears' teeth if(doRotate) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestGearsNewtAWTWrapper.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestGearsNewtAWTWrapper.java index cc20cc27e..0b907d5ee 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestGearsNewtAWTWrapper.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestGearsNewtAWTWrapper.java @@ -34,6 +34,7 @@ import javax.media.opengl.*; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.test.junit.util.QuitAdapter; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; @@ -49,6 +50,9 @@ import org.junit.Test; public class TestGearsNewtAWTWrapper extends UITestCase { static GLProfile glp; static int width, height; + static boolean useAnimator = true; + static boolean doResizeTest = true; + static long duration = 500; // ms @BeforeClass public static void initClass() { @@ -73,39 +77,50 @@ public class TestGearsNewtAWTWrapper extends UITestCase { glWindow.addGLEventListener(new GearsES2(1)); - Animator animator = new Animator(glWindow); + Animator animator = useAnimator ? new Animator(glWindow) : null; QuitAdapter quitAdapter = new QuitAdapter(); glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter)); glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter)); + if( useAnimator ) { + animator.start(); + } + int div = 3; glWindow.setSize(width/div, height/div); glWindow.setVisible(true); - glWindow.display(); - Assert.assertTrue("Size not reached: Expected "+(width/div)+"x"+(height/div)+", Is "+glWindow.getWidth()+"x"+glWindow.getHeight(), - AWTRobotUtil.waitForSize(glWindow, width/div, height/div)); - - div = 2; - glWindow.setSize(width/div, height/div); - glWindow.display(); - Assert.assertTrue("Size not reached: Expected "+(width/div)+"x"+(height/div)+", Is "+glWindow.getWidth()+"x"+glWindow.getHeight(), - AWTRobotUtil.waitForSize(glWindow, width/div, height/div)); - - div = 1; - glWindow.setSize(width/div, height/div); - glWindow.display(); - Assert.assertTrue("Size not reached: Expected "+(width/div)+"x"+(height/div)+", Is "+glWindow.getWidth()+"x"+glWindow.getHeight(), - AWTRobotUtil.waitForSize(glWindow, width/div, height/div)); - - animator.setUpdateFPSFrames(1, null); - animator.start(); + if( doResizeTest ) { + glWindow.display(); + Assert.assertTrue("Size not reached: Expected "+(width/div)+"x"+(height/div)+", Is "+glWindow.getWidth()+"x"+glWindow.getHeight(), + AWTRobotUtil.waitForSize(glWindow, width/div, height/div)); + Thread.sleep(600); + + div = 2; + glWindow.setSize(width/div, height/div); + glWindow.display(); + Assert.assertTrue("Size not reached: Expected "+(width/div)+"x"+(height/div)+", Is "+glWindow.getWidth()+"x"+glWindow.getHeight(), + AWTRobotUtil.waitForSize(glWindow, width/div, height/div)); + Thread.sleep(600); + + div = 1; + glWindow.setSize(width/div, height/div); + glWindow.display(); + Assert.assertTrue("Size not reached: Expected "+(width/div)+"x"+(height/div)+", Is "+glWindow.getWidth()+"x"+glWindow.getHeight(), + AWTRobotUtil.waitForSize(glWindow, width/div, height/div)); + Thread.sleep(600); + } - while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()