From 57140d444b3b783bfd5e400674eb46ab780a483e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 18 Dec 2011 18:00:53 +0100 Subject: TestInitConcurrentNEWT: Nice window layout - don't wait/sync for start thread, only for shutdown. --- .../junit/jogl/acore/TestInitConcurrentNEWT.java | 68 +++++++++++++++++----- 1 file changed, 52 insertions(+), 16 deletions(-) (limited to 'src/test/com/jogamp/opengl') diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestInitConcurrentNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestInitConcurrentNEWT.java index b6c6e0a91..fc025d023 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestInitConcurrentNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestInitConcurrentNEWT.java @@ -30,12 +30,17 @@ package com.jogamp.opengl.test.junit.jogl.acore; import java.io.IOException; +import javax.media.nativewindow.Capabilities; +import javax.media.nativewindow.util.InsetsImmutable; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLProfile; import org.junit.Assert; +import org.junit.BeforeClass; import org.junit.Test; +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.Window; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; import com.jogamp.opengl.test.junit.util.UITestCase; @@ -43,33 +48,61 @@ import com.jogamp.opengl.util.Animator; public class TestInitConcurrentNEWT extends UITestCase { + static final int demoSize = 128; + static long duration = 300; // ms + static InsetsImmutable insets = null; + static int scrnHeight, scrnWidth; + static int num_x, num_y; + + @BeforeClass + public static void initClass() { + Window dummyWindow = NewtFactory.createWindow(new Capabilities()); + dummyWindow.setSize(demoSize, demoSize); + dummyWindow.setVisible(true); + Assert.assertEquals(true, dummyWindow.isVisible()); + Assert.assertEquals(true, dummyWindow.isNativeValid()); + insets = dummyWindow.getInsets(); + scrnHeight = dummyWindow.getScreen().getHeight(); + scrnWidth = dummyWindow.getScreen().getWidth(); + num_x = scrnWidth / ( demoSize + insets.getTotalWidth() ) - 2; + num_y = scrnHeight / ( demoSize + insets.getTotalHeight() ) - 2; + dummyWindow.destroy(); + } + public class JOGLTask implements Runnable { + private int id; private Object postSync; private boolean done = false; - public JOGLTask(Object postSync) { + public JOGLTask(Object postSync, int id) { this.postSync = postSync; + this.id = id; } public void run() { - System.err.println(Thread.currentThread().getName()+" START"); + int x = ( id % num_x ) * ( demoSize + insets.getTotalHeight() ); + int y = ( (id / num_x) % num_y ) * ( demoSize + insets.getTotalHeight() ); + + System.err.println("JOGLTask "+id+": START: "+x+"/"+y+" - "+Thread.currentThread().getName()); GLWindow glWindow = GLWindow.create(new GLCapabilities(GLProfile.getDefault())); Assert.assertNotNull(glWindow); - glWindow.setTitle("Gears NEWT Test"); + glWindow.setTitle("Task "+id); + glWindow.setPosition(x + insets.getLeftWidth(), y + insets.getTopHeight() ); glWindow.addGLEventListener(new GearsES2(0)); Animator animator = new Animator(glWindow); - glWindow.setSize(128, 128); + glWindow.setSize(demoSize, demoSize); glWindow.setVisible(true); - animator.setUpdateFPSFrames(60, System.err); + animator.setUpdateFPSFrames(60, null); animator.start(); Assert.assertEquals(true, animator.isAnimating()); Assert.assertEquals(true, glWindow.isVisible()); Assert.assertEquals(true, glWindow.isNativeValid()); Assert.assertEquals(true, glWindow.isRealized()); + System.err.println("JOGLTask "+id+": RUNNING: "+Thread.currentThread().getName()); while(animator.isAnimating() && animator.getTotalFPSDuration()