aboutsummaryrefslogtreecommitdiffstats
path: root/src/junit/com
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-04-24 05:11:29 +0200
committerSven Gothel <[email protected]>2010-04-24 05:11:29 +0200
commit1ad8c39df6b097c80ba7a85badf555e7f669cc3f (patch)
tree740606f85dafdef5d5958498b080873c7bf188dd /src/junit/com
parent778225504c00c7ca03386b6eabfbda929542130f (diff)
NEWT/AWT Interoperability
- Moved all event classes to com.jogamp.newt.event and the new AWT event helper to com.jogamp.newt.awt.event - Added Newt<Type>Adapter for convenience - Added AWT<Type>Adapter for - Using AWT agnostic NEWT event listener see com.jogamp.test.junit.jogl.demos.gl2.gears.TestGearsNEWT even for AWT see com.jogamp.test.junit.jogl.demos.gl2.gears.TestGearsAWT (Nice idea by mbien) - Forwarding AWT events to NEWT (refactoring) Misc - GLDrawableFactory.shutdown() is now protected and called by the JVM shutdown hook. Hence removing the validate().
Diffstat (limited to 'src/junit/com')
-rwxr-xr-xsrc/junit/com/jogamp/test/junit/jogl/acore/TestGLProfile01CORE.java49
-rwxr-xr-xsrc/junit/com/jogamp/test/junit/jogl/awt/TestAWT01GLn.java9
-rw-r--r--src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/DebugKeyAdapter.java50
-rw-r--r--src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/Gears.java113
-rw-r--r--src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/QuitKeyAdapter.java51
-rwxr-xr-xsrc/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsAWT.java121
-rwxr-xr-xsrc/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNEWT.java108
-rwxr-xr-xsrc/junit/com/jogamp/test/junit/jogl/drawable/TestDrawable01NEWT.java2
-rwxr-xr-xsrc/junit/com/jogamp/test/junit/jogl/offscreen/TestOffscreen01NEWT.java6
-rwxr-xr-xsrc/junit/com/jogamp/test/junit/jogl/offscreen/WindowUtilNEWT.java1
10 files changed, 433 insertions, 77 deletions
diff --git a/src/junit/com/jogamp/test/junit/jogl/acore/TestGLProfile01CORE.java b/src/junit/com/jogamp/test/junit/jogl/acore/TestGLProfile01CORE.java
index a1ff0d860..a446be865 100755
--- a/src/junit/com/jogamp/test/junit/jogl/acore/TestGLProfile01CORE.java
+++ b/src/junit/com/jogamp/test/junit/jogl/acore/TestGLProfile01CORE.java
@@ -46,20 +46,15 @@ import java.io.IOException;
public class TestGLProfile01CORE {
static GLProfile glp;
- static GLDrawableFactory factory;
@BeforeClass
public static void initClass() {
glp = GLProfile.getDefault();
Assert.assertNotNull(glp);
- factory = GLDrawableFactory.getFactory(glp);
- Assert.assertNotNull(factory);
}
@AfterClass
public static void releaseClass() {
- factory.shutdown();
- factory=null;
}
@Test
@@ -69,12 +64,52 @@ public class TestGLProfile01CORE {
@Test
public void test02GLProfileMaxFixedFunc() {
- System.out.println("GLProfile <static> getMaxFixedFunc(): "+GLProfile.getMaxFixedFunc());
+ // Assuming at least one fixed profile is available
+ GLProfile maxFixed = GLProfile.getMaxFixedFunc();
+ System.out.println("GLProfile <static> getMaxFixedFunc(): "+maxFixed);
+ if(maxFixed.getName().equals(GLProfile.GL4bc)) {
+ Assert.assertTrue(GLProfile.isGL4bcAvailable());
+ Assert.assertTrue(GLProfile.isGL3bcAvailable());
+ Assert.assertTrue(GLProfile.isGL2Available());
+ Assert.assertTrue(GLProfile.isGL2ES1Available());
+ Assert.assertTrue(GLProfile.isGL2ES2Available());
+ } else if(maxFixed.getName().equals(GLProfile.GL3bc)) {
+ Assert.assertTrue(GLProfile.isGL3bcAvailable());
+ Assert.assertTrue(GLProfile.isGL2Available());
+ Assert.assertTrue(GLProfile.isGL2ES1Available());
+ Assert.assertTrue(GLProfile.isGL2ES2Available());
+ } else if(maxFixed.getName().equals(GLProfile.GL2)) {
+ Assert.assertTrue(GLProfile.isGL2Available());
+ Assert.assertTrue(GLProfile.isGL2ES1Available());
+ Assert.assertTrue(GLProfile.isGL2ES2Available());
+ } else if(maxFixed.getName().equals(GLProfile.GL2ES1)) {
+ Assert.assertTrue(GLProfile.isGL2ES1Available());
+ }
}
@Test
public void test02GLProfileMaxProgrammable() {
- System.out.println("GLProfile <static> getMaxProgrammable(): "+GLProfile.getMaxProgrammable());
+ // Assuming at least one programmable profile is available
+ GLProfile maxProgrammable = GLProfile.getMaxProgrammable();
+ System.out.println("GLProfile <static> getMaxProgrammable(): "+maxProgrammable);
+ if(maxProgrammable.getName().equals(GLProfile.GL4)) {
+ Assert.assertTrue(GLProfile.isGL4Available());
+ Assert.assertTrue(GLProfile.isGL3Available());
+ Assert.assertTrue(GLProfile.isGL2Available());
+ Assert.assertTrue(GLProfile.isGL2ES1Available());
+ Assert.assertTrue(GLProfile.isGL2ES2Available());
+ } else if(maxProgrammable.getName().equals(GLProfile.GL3)) {
+ Assert.assertTrue(GLProfile.isGL3Available());
+ Assert.assertTrue(GLProfile.isGL2Available());
+ Assert.assertTrue(GLProfile.isGL2ES1Available());
+ Assert.assertTrue(GLProfile.isGL2ES2Available());
+ } else if(maxProgrammable.getName().equals(GLProfile.GL2)) {
+ Assert.assertTrue(GLProfile.isGL2Available());
+ Assert.assertTrue(GLProfile.isGL2ES1Available());
+ Assert.assertTrue(GLProfile.isGL2ES2Available());
+ } else if(maxProgrammable.getName().equals(GLProfile.GL2ES2)) {
+ Assert.assertTrue(GLProfile.isGL2ES2Available());
+ }
}
public static void main(String args[]) throws IOException {
diff --git a/src/junit/com/jogamp/test/junit/jogl/awt/TestAWT01GLn.java b/src/junit/com/jogamp/test/junit/jogl/awt/TestAWT01GLn.java
index ac34b46b5..c8cedd434 100755
--- a/src/junit/com/jogamp/test/junit/jogl/awt/TestAWT01GLn.java
+++ b/src/junit/com/jogamp/test/junit/jogl/awt/TestAWT01GLn.java
@@ -89,16 +89,11 @@ public class TestAWT01GLn {
runTestGL(caps);
}
- /** Both fail on ATI .. if GLn n>2
- public void test02GL3bc() throws InterruptedException {
- GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL3bc));
- runTestGL(caps);
- }
-
+ @Test
public void test03GLMaxFixed() throws InterruptedException {
GLCapabilities caps = new GLCapabilities(GLProfile.getMaxFixedFunc());
runTestGL(caps);
- } */
+ }
public static void main(String args[]) {
org.junit.runner.JUnitCore.main(TestAWT01GLn.class.getName());
diff --git a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/DebugKeyAdapter.java b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/DebugKeyAdapter.java
new file mode 100644
index 000000000..da5e7d62f
--- /dev/null
+++ b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/DebugKeyAdapter.java
@@ -0,0 +1,50 @@
+
+/*
+ * 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.jogl.demos.gl2.gears;
+
+import com.jogamp.newt.event.*;
+
+class DebugKeyAdapter extends KeyAdapter {
+
+ public void keyPressed(KeyEvent e) {
+ System.out.println("KEY-PRESSED "+Thread.currentThread()+": "+e);
+ }
+ public void keyReleased(KeyEvent e) {
+ System.out.println("KEY-RELEASED "+Thread.currentThread()+": "+e);
+ }
+ public void keyTyped(KeyEvent e) {
+ System.out.println("KEY-TYPED "+Thread.currentThread()+": "+e);
+ }
+}
+
diff --git a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/Gears.java b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/Gears.java
index 135efd341..45d5a4a58 100644
--- a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/Gears.java
+++ b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/Gears.java
@@ -1,11 +1,13 @@
package com.jogamp.test.junit.jogl.demos.gl2.gears;
-import javax.media.opengl.GL;
-import javax.media.opengl.GL2ES1;
-import javax.media.opengl.GL2;
-import javax.media.opengl.GLAutoDrawable;
-import javax.media.opengl.GLEventListener;
+import javax.media.opengl.*;
+import javax.media.opengl.awt.*;
+import com.jogamp.newt.event.*;
+import com.jogamp.newt.awt.event.*;
+
+import java.awt.Component;
+import com.jogamp.newt.Window;
/**
* Gears.java <BR>
@@ -14,7 +16,7 @@ import javax.media.opengl.GLEventListener;
* This version is equal to Brian Paul's version 1.2 1999/10/21
*/
-public class Gears implements GLEventListener /* , MouseListener, MouseMotionListener */ {
+public class Gears implements GLEventListener {
private float view_rotx = 20.0f, view_roty = 30.0f, view_rotz = 0.0f;
private int gear1, gear2, gear3;
private float angle = 0.0f;
@@ -28,10 +30,6 @@ public class Gears implements GLEventListener /* , MouseListener, MouseMotionLis
GL2 gl = drawable.getGL().getGL2();
- System.err.println("INIT GL IS: " + gl.getClass().getName());
-
- System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities());
-
gl.setSwapInterval(1);
float pos[] = { 5.0f, 5.0f, 10.0f, 0.0f };
@@ -66,12 +64,15 @@ public class Gears implements GLEventListener /* , MouseListener, MouseMotionLis
gl.glEnable(GL2.GL_NORMALIZE);
- /**
- if (drawable instanceof AWTGLAutoDrawable) {
- AWTGLAutoDrawable awtDrawable = (AWTGLAutoDrawable) drawable;
- awtDrawable.addMouseListener(this);
- awtDrawable.addMouseMotionListener(this);
- } */
+ GearsMouseAdapter gearsMouse = new GearsMouseAdapter();
+
+ if (drawable instanceof Component) {
+ Component comp = (Component) drawable;
+ new AWTMouseAdapter(gearsMouse).addTo(comp);
+ } else if (drawable instanceof Window) {
+ Window window = (Window) drawable;
+ window.addMouseListener(gearsMouse);
+ }
}
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
@@ -81,9 +82,6 @@ public class Gears implements GLEventListener /* , MouseListener, MouseMotionLis
gl.glMatrixMode(GL2.GL_PROJECTION);
- System.err.println("GL_VENDOR: " + gl.glGetString(GL2.GL_VENDOR));
- System.err.println("GL_RENDERER: " + gl.glGetString(GL2.GL_RENDERER));
- System.err.println("GL_VERSION: " + gl.glGetString(GL2.GL_VERSION));
gl.glLoadIdentity();
gl.glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f);
gl.glMatrixMode(GL2.GL_MODELVIEW);
@@ -92,7 +90,6 @@ public class Gears implements GLEventListener /* , MouseListener, MouseMotionLis
}
public void dispose(GLAutoDrawable drawable) {
- System.out.println("Gears.dispose: "+drawable);
}
public void display(GLAutoDrawable drawable) {
@@ -264,43 +261,45 @@ public class Gears implements GLEventListener /* , MouseListener, MouseMotionLis
gl.glEnd();
}
- /***
- // Methods required for the implementation of MouseListener
- public void mouseEntered(MouseEvent e) {}
- public void mouseExited(MouseEvent e) {}
-
- public void mousePressed(MouseEvent e) {
- prevMouseX = e.getX();
- prevMouseY = e.getY();
- if ((e.getModifiers() & e.BUTTON3_MASK) != 0) {
- mouseRButtonDown = true;
- }
- }
-
- public void mouseReleased(MouseEvent e) {
- if ((e.getModifiers() & e.BUTTON3_MASK) != 0) {
- mouseRButtonDown = false;
- }
- }
-
- public void mouseClicked(MouseEvent e) {}
-
- // Methods required for the implementation of MouseMotionListener
- public void mouseDragged(MouseEvent e) {
- int x = e.getX();
- int y = e.getY();
- Dimension size = e.getComponent().getSize();
-
- float thetaY = 360.0f * ( (float)(x-prevMouseX)/(float)size.width);
- float thetaX = 360.0f * ( (float)(prevMouseY-y)/(float)size.height);
-
- prevMouseX = x;
- prevMouseY = y;
+ class GearsMouseAdapter extends MouseAdapter {
+ public void mousePressed(MouseEvent e) {
+ prevMouseX = e.getX();
+ prevMouseY = e.getY();
+ if ((e.getModifiers() & e.BUTTON3_MASK) != 0) {
+ mouseRButtonDown = true;
+ }
+ }
+
+ public void mouseReleased(MouseEvent e) {
+ if ((e.getModifiers() & e.BUTTON3_MASK) != 0) {
+ mouseRButtonDown = false;
+ }
+ }
+
+ public void mouseDragged(MouseEvent e) {
+ int x = e.getX();
+ int y = e.getY();
+ int width=0, height=0;
+ Object source = e.getSource();
+ if(source instanceof Window) {
+ Window window = (Window) source;
+ width=window.getWidth();
+ height=window.getHeight();
+ } else if (source instanceof Component) {
+ Component comp = (Component) source;
+ width=comp.getWidth();
+ height=comp.getHeight();
+ } else {
+ throw new RuntimeException("Event source neither Window nor Component: "+source);
+ }
+ float thetaY = 360.0f * ( (float)(x-prevMouseX)/(float)width);
+ float thetaX = 360.0f * ( (float)(prevMouseY-y)/(float)height);
+
+ prevMouseX = x;
+ prevMouseY = y;
- view_rotx += thetaX;
- view_roty += thetaY;
+ view_rotx += thetaX;
+ view_roty += thetaY;
+ }
}
-
- public void mouseMoved(MouseEvent e) {}
- */
}
diff --git a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/QuitKeyAdapter.java b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/QuitKeyAdapter.java
new file mode 100644
index 000000000..443fd74b1
--- /dev/null
+++ b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/QuitKeyAdapter.java
@@ -0,0 +1,51 @@
+
+/*
+ * 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.jogl.demos.gl2.gears;
+
+import com.jogamp.opengl.util.Animator;
+import com.jogamp.newt.event.*;
+
+class QuitKeyAdapter extends KeyAdapter {
+ boolean shouldQuit = false;
+
+ public boolean shouldQuit() { return shouldQuit; }
+
+ public void keyTyped(KeyEvent e) {
+ if(e.getKeyChar()=='q') {
+ System.out.println("QUIT "+Thread.currentThread());
+ shouldQuit = true;
+ }
+ }
+}
+
diff --git a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsAWT.java b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsAWT.java
new file mode 100755
index 000000000..36146df58
--- /dev/null
+++ b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsAWT.java
@@ -0,0 +1,121 @@
+/*
+ * 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.jogl.demos.gl2.gears;
+
+import javax.media.opengl.*;
+import com.jogamp.opengl.util.Animator;
+import javax.media.opengl.awt.GLCanvas;
+import com.jogamp.newt.awt.event.AWTKeyAdapter;
+
+import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears;
+import java.awt.Frame;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.AfterClass;
+import org.junit.After;
+import org.junit.Test;
+
+public class TestGearsAWT {
+ static GLProfile glp;
+ static int width, height;
+
+ @BeforeClass
+ public static void initClass() {
+ glp = GLProfile.getDefault();
+ Assert.assertNotNull(glp);
+ width = 512;
+ height = 512;
+ }
+
+ @AfterClass
+ public static void releaseClass() {
+ }
+
+ protected void runTestGL(GLCapabilities caps) throws InterruptedException {
+ Frame frame = new Frame("Gears AWT Test");
+ Assert.assertNotNull(frame);
+
+ GLCanvas glCanvas = new GLCanvas(caps);
+ Assert.assertNotNull(glCanvas);
+ frame.add(glCanvas);
+ frame.setSize(512, 512);
+
+ glCanvas.addGLEventListener(new Gears());
+
+ Animator animator = new Animator(glCanvas);
+ QuitKeyAdapter quitKeyAdapter = new QuitKeyAdapter();
+
+ new AWTKeyAdapter(new DebugKeyAdapter()).addTo(glCanvas);
+ new AWTKeyAdapter(quitKeyAdapter).addTo(glCanvas);
+
+ frame.setVisible(true);
+ animator.start();
+
+ while(!quitKeyAdapter.shouldQuit() && animator.isAnimating() && animator.getDuration()<duration) {
+ Thread.sleep(100);
+ }
+
+ Assert.assertNotNull(frame);
+ Assert.assertNotNull(glCanvas);
+ Assert.assertNotNull(animator);
+
+ animator.stop();
+ frame.setVisible(false);
+ frame.remove(glCanvas);
+ frame.dispose();
+ frame=null;
+ glCanvas=null;
+ }
+
+ @Test
+ public void test01() throws InterruptedException {
+ GLCapabilities caps = new GLCapabilities(GLProfile.getDefault());
+ runTestGL(caps);
+ }
+
+ static long duration = 500; // ms
+
+ public static void main(String args[]) {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ try {
+ duration = Integer.parseInt(args[i]);
+ } catch (Exception ex) { ex.printStackTrace(); }
+ }
+ }
+ org.junit.runner.JUnitCore.main(TestGearsAWT.class.getName());
+ }
+}
diff --git a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNEWT.java b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNEWT.java
new file mode 100755
index 000000000..e1de72ab5
--- /dev/null
+++ b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNEWT.java
@@ -0,0 +1,108 @@
+/*
+ * 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.jogl.demos.gl2.gears;
+
+import javax.media.opengl.*;
+import com.jogamp.opengl.util.Animator;
+
+import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears;
+import com.jogamp.newt.*;
+import com.jogamp.newt.opengl.*;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.AfterClass;
+import org.junit.After;
+import org.junit.Test;
+
+public class TestGearsNEWT {
+ static GLProfile glp;
+ static int width, height;
+
+ @BeforeClass
+ public static void initClass() {
+ glp = GLProfile.getDefault();
+ Assert.assertNotNull(glp);
+ width = 512;
+ height = 512;
+ }
+
+ @AfterClass
+ public static void releaseClass() {
+ }
+
+ protected void runTestGL(GLCapabilities caps) throws InterruptedException {
+ GLWindow glWindow = GLWindow.create(caps);
+ Assert.assertNotNull(glWindow);
+
+ glWindow.addGLEventListener(new Gears());
+
+ Animator animator = new Animator(glWindow);
+ QuitKeyAdapter quitKeyAdapter = new QuitKeyAdapter();
+
+ glWindow.addKeyListener(new DebugKeyAdapter());
+ glWindow.addKeyListener(quitKeyAdapter);
+
+ glWindow.setSize(width, height);
+ glWindow.setVisible(true);
+ animator.start();
+
+ while(!quitKeyAdapter.shouldQuit() && animator.isAnimating() && animator.getDuration()<duration) {
+ Thread.sleep(100);
+ }
+
+ animator.stop();
+ glWindow.destroy(true);
+ }
+
+ @Test
+ public void test01() throws InterruptedException {
+ GLCapabilities caps = new GLCapabilities(GLProfile.getDefault());
+ runTestGL(caps);
+ }
+
+ static long duration = 500; // ms
+
+ public static void main(String args[]) {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ try {
+ duration = Integer.parseInt(args[i]);
+ } catch (Exception ex) { ex.printStackTrace(); }
+ }
+ }
+ org.junit.runner.JUnitCore.main(TestGearsNEWT.class.getName());
+ }
+}
diff --git a/src/junit/com/jogamp/test/junit/jogl/drawable/TestDrawable01NEWT.java b/src/junit/com/jogamp/test/junit/jogl/drawable/TestDrawable01NEWT.java
index 0320c50ae..49dddc701 100755
--- a/src/junit/com/jogamp/test/junit/jogl/drawable/TestDrawable01NEWT.java
+++ b/src/junit/com/jogamp/test/junit/jogl/drawable/TestDrawable01NEWT.java
@@ -65,7 +65,7 @@ public class TestDrawable01NEWT {
@AfterClass
public static void releaseClass() {
- factory.shutdown();
+ Assert.assertNotNull(factory);
factory=null;
}
diff --git a/src/junit/com/jogamp/test/junit/jogl/offscreen/TestOffscreen01NEWT.java b/src/junit/com/jogamp/test/junit/jogl/offscreen/TestOffscreen01NEWT.java
index 459b41f16..67d1d5138 100755
--- a/src/junit/com/jogamp/test/junit/jogl/offscreen/TestOffscreen01NEWT.java
+++ b/src/junit/com/jogamp/test/junit/jogl/offscreen/TestOffscreen01NEWT.java
@@ -48,6 +48,7 @@ import javax.media.opengl.*;
import javax.media.nativewindow.*;
import com.jogamp.newt.*;
+import com.jogamp.newt.event.*;
import com.jogamp.newt.opengl.*;
import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears;
@@ -56,7 +57,6 @@ import java.io.IOException;
public class TestOffscreen01NEWT {
static GLProfile glpDefault;
- static GLDrawableFactory factory;
static int width, height;
GLCapabilities capsDefault;
@@ -64,16 +64,12 @@ public class TestOffscreen01NEWT {
public static void initClass() {
glpDefault = GLProfile.getDefault();
Assert.assertNotNull(glpDefault);
- factory = GLDrawableFactory.getFactory(glpDefault);
- Assert.assertNotNull(factory);
width = 640;
height = 480;
}
@AfterClass
public static void releaseClass() {
- factory.shutdown();
- factory=null;
}
@Before
diff --git a/src/junit/com/jogamp/test/junit/jogl/offscreen/WindowUtilNEWT.java b/src/junit/com/jogamp/test/junit/jogl/offscreen/WindowUtilNEWT.java
index 55ad83d25..7242abf0b 100755
--- a/src/junit/com/jogamp/test/junit/jogl/offscreen/WindowUtilNEWT.java
+++ b/src/junit/com/jogamp/test/junit/jogl/offscreen/WindowUtilNEWT.java
@@ -39,6 +39,7 @@ import org.junit.Assert;
import javax.media.opengl.*;
import javax.media.nativewindow.*;
import com.jogamp.newt.*;
+import com.jogamp.newt.event.*;
import com.jogamp.newt.opengl.*;
public class WindowUtilNEWT {