From 0d24458c68ac1bb92da21a1701633f8f32a267bb Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 16 Jun 2010 06:57:15 +0200 Subject: JOGL.GLAutoDrawable: - Add: 'public void addGLEventListener(int index, GLEventListener listener)' Fixes previous GLWindow addition, ie public in interface and common impl. behavior. - Add: 'public void invoke(boolean wait, GLRunnable glRunnable)' - Change: 'public void display()' semantics, in regards to the GLRunnable queue New: GLRunnable, invoke() at GLAutoDrawable Allows injection of GL commands from other threads, executed after the GLEventListener's display() notifyier by the GLAutoDrawable. NEWT: - Fix EDTUTil.invokeAndWait() and Display.enqueueAndWait() impl., where we only wait for the single action/event to be processed now. JUnit: NEWT Parenting - Added test cases for Swing (JFrame, JPanel and COntainer) with NewtCanvasAWT - Added thread calling 'invoke(true, GLRunnable)' - start Animator ASAP --- .../jogamp/test/junit/newt/GLRunnableDummy.java | 63 +++ .../test/junit/newt/TestListenerCom01AWT.java | 2 +- .../jogamp/test/junit/newt/TestParenting01AWT.java | 429 --------------------- .../test/junit/newt/TestParenting01NEWT.java | 2 +- .../test/junit/newt/TestParenting01aAWT.java | 429 +++++++++++++++++++++ .../test/junit/newt/TestParenting01bAWT.java | 188 +++++++++ .../test/junit/newt/TestParenting01cAWT.java | 195 ++++++++++ .../test/junit/newt/TestParenting01cSwingAWT.java | 374 ++++++++++++++++++ .../jogamp/test/junit/newt/TestParenting02AWT.java | 2 +- .../test/junit/newt/TestParenting02NEWT.java | 2 +- .../jogamp/test/junit/newt/TestParentingAWT.java | 188 --------- 11 files changed, 1253 insertions(+), 621 deletions(-) create mode 100644 src/junit/com/jogamp/test/junit/newt/GLRunnableDummy.java delete mode 100755 src/junit/com/jogamp/test/junit/newt/TestParenting01AWT.java create mode 100755 src/junit/com/jogamp/test/junit/newt/TestParenting01aAWT.java create mode 100755 src/junit/com/jogamp/test/junit/newt/TestParenting01bAWT.java create mode 100755 src/junit/com/jogamp/test/junit/newt/TestParenting01cAWT.java create mode 100755 src/junit/com/jogamp/test/junit/newt/TestParenting01cSwingAWT.java delete mode 100755 src/junit/com/jogamp/test/junit/newt/TestParentingAWT.java (limited to 'src/junit/com') diff --git a/src/junit/com/jogamp/test/junit/newt/GLRunnableDummy.java b/src/junit/com/jogamp/test/junit/newt/GLRunnableDummy.java new file mode 100644 index 000000000..990a0c37d --- /dev/null +++ b/src/junit/com/jogamp/test/junit/newt/GLRunnableDummy.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2010 Sven Gothel. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name Sven Gothel or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + */ + +package com.jogamp.test.junit.newt; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.AfterClass; +import org.junit.Test; + +import javax.media.opengl.*; + +public class GLRunnableDummy implements GLRunnable { + float r=0.0f; + float g=0.0f; + float b=0.0f; + float d=0.001f; + + public void run(GLAutoDrawable drawable) { + // nop .. + GL2ES1 gl = drawable.getGL().getGL2ES1(); + gl.glClearColor(r, g, b, 1f); + r+=d; + if(r>1f) { + r=1f; + d*=-1f; + } else if(r<0f) { + r=0f; + d*=-1f; + } + } + +} diff --git a/src/junit/com/jogamp/test/junit/newt/TestListenerCom01AWT.java b/src/junit/com/jogamp/test/junit/newt/TestListenerCom01AWT.java index b661d02f3..495b8bb3e 100755 --- a/src/junit/com/jogamp/test/junit/newt/TestListenerCom01AWT.java +++ b/src/junit/com/jogamp/test/junit/newt/TestListenerCom01AWT.java @@ -142,7 +142,7 @@ public class TestListenerCom01AWT { static int atoi(String a) { int i=0; try { - durationPerTest = Integer.parseInt(a); + i = Integer.parseInt(a); } catch (Exception ex) { ex.printStackTrace(); } return i; } diff --git a/src/junit/com/jogamp/test/junit/newt/TestParenting01AWT.java b/src/junit/com/jogamp/test/junit/newt/TestParenting01AWT.java deleted file mode 100755 index 39659d763..000000000 --- a/src/junit/com/jogamp/test/junit/newt/TestParenting01AWT.java +++ /dev/null @@ -1,429 +0,0 @@ -/* - * Copyright (c) 2010 Sven Gothel. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name Sven Gothel or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - */ - -package com.jogamp.test.junit.newt; - -import java.lang.reflect.*; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Test; - -import java.awt.Button; -import java.awt.BorderLayout; -import java.awt.Canvas; -import java.awt.Frame; -import java.awt.Dimension; - -import javax.media.opengl.*; -import javax.media.nativewindow.*; - -import com.jogamp.opengl.util.Animator; -import com.jogamp.newt.*; -import com.jogamp.newt.event.*; -import com.jogamp.newt.opengl.*; -import com.jogamp.newt.awt.NewtCanvasAWT; - -import java.io.IOException; - -import com.jogamp.test.junit.util.*; -import com.jogamp.test.junit.jogl.demos.es1.RedSquare; -import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears; - -public class TestParenting01AWT { - static int width, height; - static long durationPerTest = 800; - static long waitReparent = 0; - static GLCapabilities glCaps; - - @BeforeClass - public static void initClass() { - width = 640; - height = 480; - glCaps = new GLCapabilities(null); - } - - @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 frame = new Frame("AWT Parent Frame"); - Assert.assertNotNull(frame); - frame.add(newtCanvasAWT); - frame.setSize(width, height); - - // visible test - frame.setVisible(true); - Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParentNativeWindow()); - - Animator animator1 = new Animator(glWindow1); - animator1.start(); - while(animator1.isAnimating() && animator1.getDuration()