@Test public void testWindowParenting02CreateVisibleDestroy3Odd() throws InterruptedException { int x = 0; int y = 0; NEWTEventFiFo eventFifo = new NEWTEventFiFo(); GLWindow glWindow1 = GLWindow.create(glCaps); GLEventListener demo1 = new RedSquare(); setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); Frame frame = new Frame("AWT Parent Frame"); Assert.assertNotNull(frame); frame.setSize(width, height); // visible test frame.setVisible(true); frame.add(newtCanvasAWT); Animator animator1 = new Animator(glWindow1); animator1.start(); while (animator1.isAnimating() && animator1.getDuration() < durationPerTest) { Thread.sleep(100); } Assert.assertEquals(true, animator1.isAnimating()); // !!! frame.dispose(); glWindow1.destroy(true); }
@Test public void testWindowParenting04ReparentNewtWin2TopLayouted() throws InterruptedException { int x = 0; int y = 0; NEWTEventFiFo eventFifo = new NEWTEventFiFo(); GLWindow glWindow1 = GLWindow.create(glCaps); GLEventListener demo1 = new RedSquare(); setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); Frame frame = new Frame("AWT Parent Frame"); frame.setLayout(new BorderLayout()); frame.add(new Button("North"), BorderLayout.NORTH); frame.add(new Button("South"), BorderLayout.SOUTH); frame.add(new Button("East"), BorderLayout.EAST); frame.add(new Button("West"), BorderLayout.WEST); frame.setSize(width, height); frame.setLocation(640, 480); frame.setVisible(true); frame.add(newtCanvasAWT, BorderLayout.CENTER); Assert.assertEquals(newtCanvasAWT.getNativeWindow(), glWindow1.getParentNativeWindow()); Animator animator1 = new Animator(glWindow1); animator1.start(); int state = 0; while (animator1.isAnimating() && animator1.getDuration() < 3 * durationPerTest) { Thread.sleep(durationPerTest); switch (state) { case 0: glWindow1.reparentWindow(null, null); Assert.assertEquals(true, glWindow1.isNativeWindowValid()); Assert.assertNull(glWindow1.getParentNativeWindow()); break; case 1: glWindow1.reparentWindow(newtCanvasAWT.getNativeWindow(), null); Assert.assertEquals(true, glWindow1.isNativeWindowValid()); Assert.assertEquals(newtCanvasAWT.getNativeWindow(), glWindow1.getParentNativeWindow()); break; } state++; } animator1.stop(); Assert.assertEquals(false, animator1.isAnimating()); frame.dispose(); glWindow1.destroy(true); }
private void testImpl(final GLCapabilities caps, final GLEventListener glel) throws InterruptedException { final GLWindow glWindow = GLWindow.create(caps); Assert.assertNotNull(glWindow); glWindow.setSize(800, 600); glWindow.setVisible(true); glWindow.setTitle("JOGL Tessellation Shader Test"); Assert.assertTrue(glWindow.isNativeValid()); final QuitAdapter quitAdapter = new QuitAdapter(); glWindow.addKeyListener(quitAdapter); glWindow.addWindowListener(quitAdapter); glWindow.addGLEventListener(glel); final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); glWindow.addGLEventListener(snapshotGLEventListener); final Animator animator = new Animator(glWindow); animator.start(); animator.setUpdateFPSFrames(60, System.err); snapshotGLEventListener.setMakeSnapshot(); while (!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration() < duration) { Thread.sleep(100); } animator.stop(); glWindow.destroy(); }
protected void runTestGL(final GLCapabilities caps, final boolean forceFFPEmu) throws InterruptedException { final GLWindow glWindow = GLWindow.create(caps); Assert.assertNotNull(glWindow); glWindow.setTitle("Gears NEWT Test"); final GearsES1 demo = new GearsES1(swapInterval); demo.setForceFFPEmu(forceFFPEmu, forceFFPEmu, false, false); glWindow.addGLEventListener(demo); final SnapshotGLEventListener snap = new SnapshotGLEventListener(); glWindow.addGLEventListener(snap); final Animator animator = new Animator(glWindow); final QuitAdapter quitAdapter = new QuitAdapter(); // glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter)); // glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter)); glWindow.addKeyListener(quitAdapter); glWindow.addWindowListener(quitAdapter); final GLWindow f_glWindow = glWindow; glWindow.addKeyListener( new KeyAdapter() { public void keyReleased(final KeyEvent e) { if (!e.isPrintableKey() || e.isAutoRepeat()) { return; } if (e.getKeyChar() == 'f') { new Thread() { public void run() { f_glWindow.setFullscreen(!f_glWindow.isFullscreen()); } }.start(); } else if (e.getKeyChar() == 'd') { new Thread() { public void run() { f_glWindow.setUndecorated(!f_glWindow.isUndecorated()); } }.start(); } } }); glWindow.setSize(width, height); glWindow.setVisible(true); animator.setUpdateFPSFrames(1, null); animator.start(); snap.setMakeSnapshot(); while (!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration() < duration) { Thread.sleep(100); } animator.stop(); glWindow.destroy(); }
/** handle button events. */ public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); if (cmd.equals("run")) { if (animator.isAnimating()) stop(); else start(); } else if (cmd.equals("transparancy")) { if (drawable != null) drawable.setOpaque(!checkBox.isSelected()); } }
public void testImpl(boolean useFFP, final InputStream istream) throws InterruptedException, IOException { final GLReadBufferUtil screenshot = new GLReadBufferUtil(true, false); GLProfile glp; if (useFFP && GLProfile.isAvailable(GLProfile.GL2)) { glp = GLProfile.getMaxFixedFunc(true); } else if (!useFFP && GLProfile.isAvailable(GLProfile.GL2ES2)) { glp = GLProfile.getGL2ES2(); } else { System.err.println(getSimpleTestName(".") + ": GLProfile n/a, useFFP: " + useFFP); return; } final GLCapabilities caps = new GLCapabilities(glp); caps.setAlphaBits(1); final TextureData texData = TextureIO.newTextureData(glp, istream, false /* mipmap */, TextureIO.TGA); System.err.println("TextureData: " + texData); final GLWindow glad = GLWindow.create(caps); glad.setTitle("TestTGATextureGL2FromFileNEWT"); // Size OpenGL to Video Surface glad.setSize(texData.getWidth(), texData.getHeight()); // load texture from file inside current GL context to match the way // the bug submitter was doing it final GLEventListener gle = useFFP ? new TextureDraw01GL2Listener(texData) : new TextureDraw01ES2Listener(texData, 0); glad.addGLEventListener(gle); glad.addGLEventListener( new GLEventListener() { boolean shot = false; @Override public void init(GLAutoDrawable drawable) {} public void display(GLAutoDrawable drawable) { // 1 snapshot if (null != ((TextureDraw01Accessor) gle).getTexture() && !shot) { shot = true; snapshot(0, null, drawable.getGL(), screenshot, TextureIO.PNG, null); } } @Override public void dispose(GLAutoDrawable drawable) {} @Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {} }); Animator animator = new Animator(glad); animator.setUpdateFPSFrames(60, showFPS ? System.err : null); QuitAdapter quitAdapter = new QuitAdapter(); glad.addKeyListener(quitAdapter); glad.addWindowListener(quitAdapter); glad.setVisible(true); animator.start(); while (!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration() < duration) { Thread.sleep(100); } animator.stop(); glad.destroy(); }
@Test public void testWindowParenting01CreateVisibleDestroy1() throws InterruptedException { int x = 0; int y = 0; NEWTEventFiFo eventFifo = new NEWTEventFiFo(); GLWindow glWindow1 = GLWindow.create(glCaps); Assert.assertNotNull(glWindow1); Assert.assertEquals(false, glWindow1.isVisible()); Assert.assertEquals(false, glWindow1.isNativeWindowValid()); Assert.assertNull(glWindow1.getParentNativeWindow()); glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy"); GLEventListener demo1 = new RedSquare(); setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); Assert.assertNotNull(newtCanvasAWT); Assert.assertEquals(false, glWindow1.isVisible()); Assert.assertEquals(false, glWindow1.isNativeWindowValid()); Assert.assertNull(glWindow1.getParentNativeWindow()); Frame frame1 = new Frame("AWT Parent Frame"); frame1.setLayout(new BorderLayout()); frame1.add(new Button("North"), BorderLayout.NORTH); frame1.add(new Button("South"), BorderLayout.SOUTH); frame1.add(new Button("East"), BorderLayout.EAST); frame1.add(new Button("West"), BorderLayout.WEST); Container container1 = new Container(); container1.setLayout(new BorderLayout()); container1.add(new Button("north"), BorderLayout.NORTH); container1.add(new Button("south"), BorderLayout.SOUTH); container1.add(new Button("east"), BorderLayout.EAST); container1.add(new Button("west"), BorderLayout.WEST); container1.add(newtCanvasAWT, BorderLayout.CENTER); frame1.add(container1, BorderLayout.CENTER); frame1.setSize(width, height); // visible test frame1.setVisible(true); Assert.assertEquals(newtCanvasAWT.getNativeWindow(), glWindow1.getParentNativeWindow()); Animator animator1 = new Animator(glWindow1); animator1.start(); while (animator1.isAnimating() && animator1.getDuration() < durationPerTest) { Thread.sleep(100); } animator1.stop(); Assert.assertEquals(false, animator1.isAnimating()); frame1.setVisible(false); Assert.assertEquals(false, glWindow1.isDestroyed()); frame1.setVisible(true); Assert.assertEquals(false, glWindow1.isDestroyed()); frame1.remove(newtCanvasAWT); // Assert.assertNull(glWindow1.getParentNativeWindow()); Assert.assertEquals(false, glWindow1.isDestroyed()); frame1.dispose(); Assert.assertEquals(false, glWindow1.isDestroyed()); glWindow1.destroy(true); // Assert.assertEquals(true, glWindow1.isDestroyed()); }
@Test public void compileShader() throws InterruptedException { GLProfile glp = GLProfile.get(GLProfile.GL2GL3); GLCapabilities caps = new GLCapabilities(glp); // commenting out this line makes it work caps.setStencilBits(8); // commenting in this line also makes it work // caps.setSampleBuffers(true); final Frame frame = new Frame("Bug 459 shader compilation test"); Assert.assertNotNull(frame); final GLCanvas glCanvas = new GLCanvas(caps); Assert.assertNotNull(glCanvas); frame.add(glCanvas); glCanvas.addGLEventListener( new GLEventListener() { /* @Override */ public void init(GLAutoDrawable drawable) { String code = "void main(void){gl_Position = vec4(0,0,0,1);}"; GL2GL3 gl = drawable.getGL().getGL2GL3(); int id = gl.glCreateShader(GL2GL3.GL_VERTEX_SHADER); try { gl.glShaderSource(id, 1, new String[] {code}, (int[]) null, 0); gl.glCompileShader(id); int[] compiled = new int[1]; gl.glGetShaderiv(id, GL2GL3.GL_COMPILE_STATUS, compiled, 0); if (compiled[0] == GL2GL3.GL_FALSE) { int[] logLength = new int[1]; gl.glGetShaderiv(id, GL2GL3.GL_INFO_LOG_LENGTH, logLength, 0); byte[] log = new byte[logLength[0]]; gl.glGetShaderInfoLog(id, logLength[0], (int[]) null, 0, log, 0); System.err.println("Error compiling the shader: " + new String(log)); gl.glDeleteShader(id); } else { System.out.println("Shader compiled: id=" + id); } } catch (GLException e) { glexception = e; } } /* @Override */ public void dispose(GLAutoDrawable drawable) {} /* @Override */ public void display(GLAutoDrawable drawable) {} /* @Override */ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {} }); Animator animator = new Animator(glCanvas); try { javax.swing.SwingUtilities.invokeAndWait( new Runnable() { public void run() { frame.setSize(512, 512); frame.setVisible(true); } }); } catch (Exception ex) { throw new RuntimeException(ex); } animator.setUpdateFPSFrames(1, null); animator.start(); while (animator.isAnimating() && animator.getTotalFPSDuration() < duration) { Thread.sleep(100); } Assert.assertTrue(glexception != null ? glexception.getMessage() : "", glexception == null); Assert.assertNotNull(frame); Assert.assertNotNull(glCanvas); Assert.assertNotNull(animator); animator.stop(); Assert.assertEquals(false, animator.isAnimating()); try { javax.swing.SwingUtilities.invokeAndWait( new Runnable() { public void run() { frame.setVisible(false); frame.remove(glCanvas); frame.dispose(); } }); } catch (Throwable throwable) { throwable.printStackTrace(); Assume.assumeNoException(throwable); } }
public void asyncEachOneAnimator(final boolean destroyCleanOrder) throws InterruptedException, InvocationTargetException { final Frame f1 = new Frame(); final Animator a1 = new Animator(); final GearsES2 g1 = new GearsES2(0); final GLCanvas c1 = createGLCanvas(f1, 0, 0, g1); a1.add(c1); a1.start(); // f1.setVisible(true); // we do this post f2 .. to test pending creation! final Frame f2 = new Frame(); final Animator a2 = new Animator(); final GearsES2 g2 = new GearsES2(0); g2.setSharedGears(g1); final GLCanvas c2 = createGLCanvas(f2, f1.getX() + width, f1.getY() + 0, g2); c2.setSharedAutoDrawable(c1); a2.add(c2); a2.start(); javax.swing.SwingUtilities.invokeAndWait( new Runnable() { public void run() { f2.setVisible(true); } }); Thread.sleep(200); // wait a while .. javax.swing.SwingUtilities.invokeAndWait( new Runnable() { public void run() { f1.setVisible(true); // test pending creation of f2 } }); final Frame f3 = new Frame(); final Animator a3 = new Animator(); final GearsES2 g3 = new GearsES2(0); g3.setSharedGears(g1); final GLCanvas c3 = createGLCanvas(f3, f1.getX() + 0, f1.getY() + height, g3); c3.setSharedAutoDrawable(c1); a3.add(c3); a3.start(); javax.swing.SwingUtilities.invokeAndWait( new Runnable() { public void run() { f3.setVisible(true); } }); Thread.sleep( 1000 / 60 * 10); // wait ~10 frames giving a chance to create (blocking until master share is // valid) Assert.assertTrue(AWTRobotUtil.waitForRealized(c1, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(c1, true)); Assert.assertTrue(AWTRobotUtil.waitForContextCreated(c1, true)); Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true)); Assert.assertTrue(AWTRobotUtil.waitForRealized(c2, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(c2, true)); Assert.assertTrue(AWTRobotUtil.waitForContextCreated(c2, true)); Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true)); Assert.assertTrue(AWTRobotUtil.waitForRealized(c3, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(c3, true)); Assert.assertTrue(AWTRobotUtil.waitForContextCreated(c3, true)); Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true)); final GLContext ctx1 = c1.getContext(); final GLContext ctx2 = c2.getContext(); final GLContext ctx3 = c3.getContext(); { final List<GLContext> ctx1Shares = ctx1.getCreatedShares(); final List<GLContext> ctx2Shares = ctx2.getCreatedShares(); final List<GLContext> ctx3Shares = ctx3.getCreatedShares(); MiscUtils.dumpSharedGLContext("XXX-C-3.1", ctx1); MiscUtils.dumpSharedGLContext("XXX-C-3.2", ctx2); MiscUtils.dumpSharedGLContext("XXX-C-3.3", ctx3); Assert.assertTrue("Ctx1 is not shared", ctx1.isShared()); Assert.assertTrue("Ctx2 is not shared", ctx2.isShared()); Assert.assertTrue("Ctx3 is not shared", ctx3.isShared()); Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size()); Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size()); Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size()); } Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears()); Assert.assertTrue("Gears2 is not shared", g2.usesSharedGears()); Assert.assertTrue("Gears3 is not shared", g3.usesSharedGears()); try { Thread.sleep(duration); } catch (final Exception e) { e.printStackTrace(); } // Stopped animator allows native windowing system 'repaint' event // to trigger GLAD 'display' a1.stop(); Assert.assertEquals(false, a1.isAnimating()); a2.stop(); Assert.assertEquals(false, a2.isAnimating()); a3.stop(); Assert.assertEquals(false, a3.isAnimating()); if (destroyCleanOrder) { System.err.println("XXX Destroy in clean order NOW"); } else { System.err.println( "XXX Destroy in creation order NOW - Driver Impl. Ma trigger driver Bug i.e. not postponing GL ctx destruction after releasing all refs."); } javax.swing.SwingUtilities.invokeAndWait( new Runnable() { public void run() { try { if (destroyCleanOrder) { f3.dispose(); } else { f1.dispose(); } } catch (final Throwable t) { throw new RuntimeException(t); } } }); javax.swing.SwingUtilities.invokeAndWait( new Runnable() { public void run() { try { f2.dispose(); } catch (final Throwable t) { throw new RuntimeException(t); } } }); javax.swing.SwingUtilities.invokeAndWait( new Runnable() { public void run() { try { if (destroyCleanOrder) { f1.dispose(); } else { f3.dispose(); } } catch (final Throwable t) { throw new RuntimeException(t); } } }); Assert.assertTrue(AWTRobotUtil.waitForRealized(c1, false)); Assert.assertTrue(AWTRobotUtil.waitForRealized(c2, false)); Assert.assertTrue(AWTRobotUtil.waitForRealized(c3, false)); }
public void testImpl() throws InterruptedException { final JFrame frame = new JFrame(this.getSimpleTestName(".")); // // GLDrawableFactory factory = GLDrawableFactory.getFactory(GLProfile.get(GLProfile.GL2)); // GLContext sharedContext = factory.getOrCreateSharedContext(factory.getDefaultDevice()); // final GLCapabilities glCapabilities = new GLCapabilities(GLProfile.get(GLProfile.GL2)); glCapabilities.setSampleBuffers(true); glCapabilities.setNumSamples(4); final GearsES2 eventListener1 = new GearsES2(0); final GearsES2 eventListener2 = new GearsES2(1); final Component openGLComponent1; final Component openGLComponent2; final GLAutoDrawable openGLAutoDrawable1; final GLAutoDrawable openGLAutoDrawable2; final GLWindow glWindow1 = GLWindow.create(glCapabilities); final NewtCanvasAWT newtCanvasAWT1 = new NewtCanvasAWT(glWindow1); newtCanvasAWT1.setPreferredSize(new Dimension(640, 480)); glWindow1.addGLEventListener(eventListener1); // final GLWindow glWindow2 = GLWindow.create(glCapabilities); final NewtCanvasAWT newtCanvasAWT2 = new NewtCanvasAWT(glWindow2); newtCanvasAWT2.setPreferredSize(new Dimension(640, 480)); glWindow2.addGLEventListener(eventListener2); openGLComponent1 = newtCanvasAWT1; openGLComponent2 = newtCanvasAWT2; openGLAutoDrawable1 = glWindow1; openGLAutoDrawable2 = glWindow2; // group both OpenGL canvases / windows into a horizontal panel final JPanel openGLPanel = new JPanel(); openGLPanel.setLayout(new BoxLayout(openGLPanel, BoxLayout.LINE_AXIS)); openGLPanel.add(openGLComponent1); openGLPanel.add(Box.createHorizontalStrut(5)); openGLPanel.add(openGLComponent2); final JPanel mainPanel = (JPanel) frame.getContentPane(); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.LINE_AXIS)); mainPanel.add(Box.createHorizontalGlue()); mainPanel.add(openGLPanel); mainPanel.add(Box.createHorizontalGlue()); final Animator animator = new Animator(Thread.currentThread().getThreadGroup()); animator.setUpdateFPSFrames(1, null); animator.add(openGLAutoDrawable1); animator.add(openGLAutoDrawable2); // make the window visible using the EDT SwingUtilities.invokeLater( new Runnable() { public void run() { frame.pack(); frame.setVisible(true); } }); Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); Assert.assertEquals(true, AWTRobotUtil.waitForRealized(openGLComponent1, true)); Assert.assertEquals(true, AWTRobotUtil.waitForRealized(openGLComponent2, true)); animator.start(); // sleep for test duration, then request the window to close, wait for the window to close,s and // stop the animation while (animator.isAnimating() && animator.getTotalFPSDuration() < durationPerTest) { Thread.sleep(100); } animator.stop(); // ask the EDT to dispose of the frame; // if using newt, explicitly dispose of the canvases because otherwise it seems our destroy // methods are not called SwingUtilities.invokeLater( new Runnable() { public void run() { newtCanvasAWT1.destroy(); // removeNotify does not destroy GLWindow newtCanvasAWT2.destroy(); // removeNotify does not destroy GLWindow frame.dispose(); } }); Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, false)); Assert.assertEquals(true, AWTRobotUtil.waitForRealized(openGLComponent1, false)); Assert.assertEquals(true, AWTRobotUtil.waitForRealized(openGLComponent2, false)); }
protected void runTestGL( final GLCapabilities caps, final FrameLayout frameLayout, final boolean twoCanvas, final boolean resizeByComp) throws InterruptedException, InvocationTargetException { final JFrame frame = new JFrame("Bug816: " + this.getTestMethodName()); Assert.assertNotNull(frame); final Container framePane = frame.getContentPane(); final GLCanvas glCanvas1 = new GLCanvas(caps); Assert.assertNotNull(glCanvas1); final GLCanvas glCanvas2; if (twoCanvas) { glCanvas2 = new GLCanvas(caps); Assert.assertNotNull(glCanvas2); } else { glCanvas2 = null; } final Dimension glcDim = new Dimension(width / 2, height); final Dimension frameDim = new Dimension(twoCanvas ? width + 64 : width / 2 + 64, height + 64); setComponentSize(null, glCanvas1, glcDim, glCanvas2, glcDim); switch (frameLayout) { case None: { framePane.add(glCanvas1); } break; case Flow: { final Container c = new Container(); c.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); c.add(glCanvas1); if (twoCanvas) { c.add(glCanvas2); } framePane.add(c); } break; case DoubleBorderCenterSurrounded: { final Container c = new Container(); c.setLayout(new BorderLayout()); c.add(new Button("north"), BorderLayout.NORTH); c.add(new Button("south"), BorderLayout.SOUTH); c.add(new Button("east"), BorderLayout.EAST); c.add(new Button("west"), BorderLayout.WEST); if (twoCanvas) { final Container c2 = new Container(); c2.setLayout(new GridLayout(1, 2)); c2.add(glCanvas1); c2.add(glCanvas2); c.add(c2, BorderLayout.CENTER); } else { c.add(glCanvas1, BorderLayout.CENTER); } framePane.setLayout(new BorderLayout()); framePane.add(new Button("NORTH"), BorderLayout.NORTH); framePane.add(new Button("SOUTH"), BorderLayout.SOUTH); framePane.add(new Button("EAST"), BorderLayout.EAST); framePane.add(new Button("WEST"), BorderLayout.WEST); framePane.add(c, BorderLayout.CENTER); } break; case Box: { final Container c = new Container(); c.setLayout(new BoxLayout(c, BoxLayout.X_AXIS)); c.add(glCanvas1); if (twoCanvas) { c.add(glCanvas2); } framePane.add(c); } break; case Split: { final Dimension sbDim = new Dimension(16, 16); final JScrollPane vsp = new JScrollPane( ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); { final JScrollBar vsb = vsp.getVerticalScrollBar(); vsb.setPreferredSize(sbDim); final BoundedRangeModel model = vsb.getModel(); model.setMinimum(0); model.setMaximum(100); model.setValue(50); model.setExtent(1); vsb.setEnabled(true); } final JScrollPane hsp = new JScrollPane( ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); { final JScrollBar hsb = hsp.getHorizontalScrollBar(); hsb.setPreferredSize(sbDim); final BoundedRangeModel model = hsb.getModel(); model.setMinimum(0); model.setMaximum(100); model.setValue(50); model.setExtent(1); hsb.setEnabled(true); } final JSplitPane horizontalSplitPane = new JSplitPane( JSplitPane.HORIZONTAL_SPLIT, true, twoCanvas ? glCanvas2 : vsp, glCanvas1); horizontalSplitPane.setResizeWeight(0.5); final JSplitPane verticalSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, horizontalSplitPane, hsp); verticalSplitPane.setResizeWeight(0.5); framePane.add(verticalSplitPane); } break; } final GearsES2 demo1 = new GearsES2(swapInterval); glCanvas1.addGLEventListener(demo1); if (twoCanvas) { final RedSquareES2 demo2 = new RedSquareES2(swapInterval); glCanvas2.addGLEventListener(demo2); } final Animator animator = new Animator(); animator.add(glCanvas1); if (twoCanvas) { animator.add(glCanvas2); } final QuitAdapter quitAdapter = new QuitAdapter(); new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter), glCanvas1).addTo(frame); javax.swing.SwingUtilities.invokeAndWait( new Runnable() { public void run() { if (resizeByComp) { frame.pack(); } else { setFrameSize(frame, true, frameDim); } frame.setVisible(true); } }); Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas1, true)); if (twoCanvas) { Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas2, true)); } animator.start(); Assert.assertTrue(animator.isStarted()); Assert.assertTrue(animator.isAnimating()); System.err.println( "canvas1 pos/siz: " + glCanvas1.getX() + "/" + glCanvas1.getY() + " " + glCanvas1.getSurfaceWidth() + "x" + glCanvas1.getSurfaceHeight()); if (twoCanvas) { System.err.println( "canvas2 pos/siz: " + glCanvas2.getX() + "/" + glCanvas2.getY() + " " + glCanvas2.getSurfaceWidth() + "x" + glCanvas2.getSurfaceHeight()); } Thread.sleep(Math.max(1000, duration / 2)); if (null != rwsize) { final Dimension compRSizeHalf = new Dimension(rwsize.width / 2, rwsize.height); final Dimension frameRSizeHalf = new Dimension(twoCanvas ? rwsize.width + 64 : rwsize.width / 2 + 64, rwsize.height + 64); if (resizeByComp) { setComponentSize(frame, glCanvas1, compRSizeHalf, glCanvas2, compRSizeHalf); } else { setFrameSize(frame, true, frameRSizeHalf); } System.err.println( "resize canvas1 pos/siz: " + glCanvas1.getX() + "/" + glCanvas1.getY() + " " + glCanvas1.getSurfaceWidth() + "x" + glCanvas1.getSurfaceHeight()); if (twoCanvas) { System.err.println( "resize canvas2 pos/siz: " + glCanvas2.getX() + "/" + glCanvas2.getY() + " " + glCanvas2.getSurfaceWidth() + "x" + glCanvas2.getSurfaceHeight()); } } final long t0 = System.currentTimeMillis(); long t1 = t0; while (!quitAdapter.shouldQuit() && t1 - t0 < duration) { Thread.sleep(100); t1 = System.currentTimeMillis(); } Assert.assertNotNull(frame); Assert.assertNotNull(glCanvas1); if (twoCanvas) { Assert.assertNotNull(glCanvas2); } else { Assert.assertNull(glCanvas2); } Assert.assertNotNull(animator); animator.stop(); Assert.assertFalse(animator.isAnimating()); Assert.assertFalse(animator.isStarted()); javax.swing.SwingUtilities.invokeAndWait( new Runnable() { public void run() { frame.setVisible(false); } }); Assert.assertEquals(false, frame.isVisible()); javax.swing.SwingUtilities.invokeAndWait( new Runnable() { public void run() { frame.remove(glCanvas1); if (twoCanvas) { frame.remove(glCanvas2); } frame.dispose(); } }); }