aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/com')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java11
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestRedSquareES1NEWT.java11
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java11
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java53
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java44
-rw-r--r--src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java9
8 files changed, 83 insertions, 64 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java
index 8b41141f1..dffe61f69 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java
@@ -47,19 +47,10 @@ import org.junit.AfterClass;
import org.junit.Test;
public class TestGearsES1NEWT extends UITestCase {
- static GLProfile glp;
static int width, height;
@BeforeClass
public static void initClass() {
- /* if(GLProfile.isAvailable(GLProfile.getDefaultEGLDevice(), GLProfile.GLES1)) {
- // exact match
- glp = GLProfile.get(GLProfile.getDefaultEGLDevice(), GLProfile.GLES1);
- } else */ {
- // default device, somehow ES1 compatible
- glp = GLProfile.getGL2ES1();
- }
- Assert.assertNotNull(glp);
width = 512;
height = 512;
}
@@ -115,7 +106,7 @@ public class TestGearsES1NEWT extends UITestCase {
@Test
public void test01() throws InterruptedException {
- GLCapabilities caps = new GLCapabilities(glp);
+ GLCapabilities caps = new GLCapabilities(GLProfile.getGL2ES1());
runTestGL(caps);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestRedSquareES1NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestRedSquareES1NEWT.java
index 13aafe48f..c327a3005 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestRedSquareES1NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestRedSquareES1NEWT.java
@@ -47,19 +47,10 @@ import org.junit.AfterClass;
import org.junit.Test;
public class TestRedSquareES1NEWT extends UITestCase {
- static GLProfile glp;
static int width, height;
@BeforeClass
public static void initClass() {
- /* if(GLProfile.isAvailable(GLProfile.getDefaultEGLDevice(), GLProfile.GLES1)) {
- // exact match
- glp = GLProfile.get(GLProfile.getDefaultEGLDevice(), GLProfile.GLES1);
- } else */ {
- // default device, somehow ES1 compatible
- glp = GLProfile.getGL2ES1();
- }
- Assert.assertNotNull(glp);
width = 512;
height = 512;
}
@@ -115,7 +106,7 @@ public class TestRedSquareES1NEWT extends UITestCase {
@Test
public void test01() throws InterruptedException {
- GLCapabilities caps = new GLCapabilities(glp);
+ GLCapabilities caps = new GLCapabilities(GLProfile.getGL2ES1());
runTestGL(caps);
}
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 262a79671..5a106901d 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
@@ -174,7 +174,9 @@ public class GearsES2 implements GLEventListener {
}
st.useProgram(gl, false);
- gl.setSwapInterval(swapInterval);
+ if(0<=swapInterval) {
+ gl.setSwapInterval(swapInterval);
+ }
System.err.println(Thread.currentThread()+" GearsES2.init FIN");
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java
index 2a86a5bd8..6f3438ec8 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java
@@ -122,6 +122,10 @@ public class RedSquareES2 implements GLEventListener {
gl.glEnable(GL2ES2.GL_DEPTH_TEST);
st.useProgram(gl, false);
+ if(0<=swapInterval) {
+ gl.setSwapInterval(swapInterval);
+ }
+
if (glad instanceof GLWindow) {
glWindow = (GLWindow) glad;
glWindow.addMouseListener(myMouse);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java
index e2b1e4844..5bf341388 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java
@@ -49,14 +49,12 @@ import org.junit.AfterClass;
import org.junit.Test;
public class TestGearsES2AWT extends UITestCase {
- static GLProfile glp;
static int width, height;
static boolean firstUIActionOnProcess = false;
+ static boolean forceES2 = false;
@BeforeClass
public static void initClass() {
- glp = GLProfile.getGL2ES2();
- Assert.assertNotNull(glp);
width = 512;
height = 512;
}
@@ -86,7 +84,7 @@ public class TestGearsES2AWT extends UITestCase {
public void run() {
frame.setVisible(true);
}});
- animator.setUpdateFPSFrames(60, System.err);
+ animator.setUpdateFPSFrames(60, System.err);
animator.start();
while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
@@ -110,7 +108,7 @@ public class TestGearsES2AWT extends UITestCase {
@Test
public void test01() throws InterruptedException, InvocationTargetException {
- GLCapabilities caps = new GLCapabilities(glp);
+ GLCapabilities caps = new GLCapabilities(forceES2 ? GLProfile.get(GLProfile.GLES2) : GLProfile.getGL2ES2());
runTestGL(caps);
}
@@ -123,10 +121,13 @@ public class TestGearsES2AWT extends UITestCase {
try {
duration = Integer.parseInt(args[i]);
} catch (Exception ex) { ex.printStackTrace(); }
+ } else if(args[i].equals("-es2")) {
+ forceES2 = true;
} else if(args[i].equals("-firstUIAction")) {
firstUIActionOnProcess = true;
}
}
+ System.err.println("forceES2 "+forceES2);
org.junit.runner.JUnitCore.main(TestGearsES2AWT.class.getName());
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java
index d2ba81294..88da8db23 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java
@@ -40,6 +40,7 @@ import com.jogamp.newt.event.KeyEvent;
import com.jogamp.newt.event.WindowEvent;
import com.jogamp.newt.event.WindowAdapter;
import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.test.junit.util.QuitAdapter;
@@ -55,6 +56,7 @@ import javax.media.nativewindow.util.DimensionImmutable;
import javax.media.opengl.GLAnimatorControl;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLCapabilitiesImmutable;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLProfile;
@@ -79,6 +81,8 @@ public class TestGearsES2NEWT extends UITestCase {
static boolean mouseVisible = true;
static boolean mouseConfined = false;
static boolean showFPS = false;
+ static int loops = 1;
+ static boolean forceES2 = false;
@BeforeClass
public static void initClass() {
@@ -91,13 +95,13 @@ public class TestGearsES2NEWT extends UITestCase {
public static void releaseClass() {
}
- protected void runTestGL(GLCapabilities caps, boolean undecorated) throws InterruptedException {
- System.err.println("requested: "+caps);
+ protected void runTestGL(GLCapabilitiesImmutable caps, boolean undecorated) throws InterruptedException {
+ System.err.println("requested: vsync "+vsync+", "+caps);
Display dpy = NewtFactory.createDisplay(null);
Screen screen = NewtFactory.createScreen(dpy, screenIdx);
final GLWindow glWindow = GLWindow.create(screen, caps);
Assert.assertNotNull(glWindow);
- glWindow.setTitle("Gears NEWT Test (translucent "+!caps.isBackgroundOpaque()+"), size "+wsize+", pos "+wpos);
+ glWindow.setTitle("Gears NEWT Test (translucent "+!caps.isBackgroundOpaque()+"), vsync "+vsync+", size "+wsize+", pos "+wpos);
glWindow.setSize(wsize.getWidth(), wsize.getHeight());
if(null != wpos) {
glWindow.setPosition(wpos.getX(), wpos.getY());
@@ -108,7 +112,7 @@ public class TestGearsES2NEWT extends UITestCase {
glWindow.setPointerVisible(mouseVisible);
glWindow.confinePointer(mouseConfined);
- final GearsES2 demo = new GearsES2(vsync ? 1 : 0);
+ final GearsES2 demo = new GearsES2(vsync ? 1 : -1);
demo.setPMVUseBackingArray(pmvUseBackingArray);
glWindow.addGLEventListener(demo);
if(waitForKey) {
@@ -215,15 +219,17 @@ public class TestGearsES2NEWT extends UITestCase {
}
});
- animator.setUpdateFPSFrames(60, showFPS ? System.err : null);
animator.start();
// glWindow.setSkipContextReleaseThread(animator.getThread());
glWindow.setVisible(true);
- System.err.println("chosen: "+glWindow.getChosenCapabilities());
+ System.err.println("NW chosen: "+glWindow.getDelegatedWindow().getChosenCapabilities());
+ System.err.println("GL chosen: "+glWindow.getChosenCapabilities());
System.err.println("window pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets());
+ animator.setUpdateFPSFrames(60, showFPS ? System.err : null);
+
while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
Thread.sleep(100);
}
@@ -234,19 +240,15 @@ public class TestGearsES2NEWT extends UITestCase {
@Test
public void test01GL2ES2() throws InterruptedException {
- GLCapabilities caps = new GLCapabilities(GLProfile.getGL2ES2());
+ GLCapabilities caps = new GLCapabilities(forceES2 ? GLProfile.get(GLProfile.GLES2) : GLProfile.getGL2ES2());
caps.setBackgroundOpaque(opaque);
- runTestGL(caps, undecorated);
+ for(int i=1; i<=loops; i++) {
+ System.err.println("Loop "+i+"/"+loops);
+ runTestGL(caps, undecorated);
+ }
}
- static int atoi(String a) {
- try {
- return Integer.parseInt(a);
- } catch (Exception ex) { throw new RuntimeException(ex); }
- }
-
- public static void main(String args[]) throws IOException {
-
+ public static void main(String args[]) throws IOException {
int x=0, y=0, w=200, h=200;
boolean useSize = false;
boolean usePos = false;
@@ -254,7 +256,7 @@ public class TestGearsES2NEWT extends UITestCase {
for(int i=0; i<args.length; i++) {
if(args[i].equals("-time")) {
i++;
- duration = atoi(args[i]);
+ duration = MiscUtils.atol(args[i], duration);
} else if(args[i].equals("-translucent")) {
opaque = false;
} else if(args[i].equals("-undecorated")) {
@@ -267,6 +269,8 @@ public class TestGearsES2NEWT extends UITestCase {
pmvUseBackingArray = false;
} else if(args[i].equals("-vsync")) {
vsync = true;
+ } else if(args[i].equals("-es2")) {
+ forceES2 = true;
} else if(args[i].equals("-wait")) {
waitForKey = true;
} else if(args[i].equals("-mouseInvisible")) {
@@ -277,23 +281,26 @@ public class TestGearsES2NEWT extends UITestCase {
showFPS = true;
} else if(args[i].equals("-width")) {
i++;
- w = atoi(args[i]);
+ w = MiscUtils.atoi(args[i], w);
useSize = true;
} else if(args[i].equals("-height")) {
i++;
- h = atoi(args[i]);
+ h = MiscUtils.atoi(args[i], h);
useSize = true;
} else if(args[i].equals("-x")) {
i++;
- x = atoi(args[i]);
+ x = MiscUtils.atoi(args[i], x);
usePos = true;
} else if(args[i].equals("-y")) {
i++;
- y = atoi(args[i]);
+ y = MiscUtils.atoi(args[i], y);
usePos = true;
} else if(args[i].equals("-screen")) {
i++;
- screenIdx = atoi(args[i]);
+ screenIdx = MiscUtils.atoi(args[i], 0);
+ } else if(args[i].equals("-loops")) {
+ i++;
+ loops = MiscUtils.atoi(args[i], 1);
}
}
if(useSize) {
@@ -313,6 +320,8 @@ public class TestGearsES2NEWT extends UITestCase {
System.err.println("vsync "+vsync);
System.err.println("mouseVisible "+mouseVisible);
System.err.println("mouseConfined "+mouseConfined);
+ System.err.println("loops "+loops);
+ System.err.println("forceES2 "+forceES2);
if(waitForKey) {
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java
index 49dbc062a..f658b2b2b 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java
@@ -31,11 +31,13 @@ package com.jogamp.opengl.test.junit.jogl.demos.es2.newt;
import com.jogamp.newt.event.KeyAdapter;
import com.jogamp.newt.event.KeyEvent;
import com.jogamp.newt.opengl.GLWindow;
+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.util.Animator;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2;
import javax.media.opengl.GLCapabilities;
@@ -48,6 +50,9 @@ import org.junit.Test;
public class TestRedSquareES2NEWT extends UITestCase {
static int width, height;
+ static int loops = 1;
+ static boolean vsync = false;
+ static boolean forceES2 = false;
@BeforeClass
public static void initClass() {
@@ -60,11 +65,13 @@ public class TestRedSquareES2NEWT extends UITestCase {
}
protected void runTestGL(GLCapabilities caps) throws InterruptedException {
+ System.err.println("requested: vsync "+vsync+", "+caps);
GLWindow glWindow = GLWindow.create(caps);
Assert.assertNotNull(glWindow);
glWindow.setTitle("Gears NEWT Test");
+ glWindow.setSize(width, height);
- glWindow.addGLEventListener(new RedSquareES2());
+ glWindow.addGLEventListener(new RedSquareES2(vsync ? 1 : -1));
Animator animator = new Animator(glWindow);
QuitAdapter quitAdapter = new QuitAdapter();
@@ -91,11 +98,16 @@ public class TestRedSquareES2NEWT extends UITestCase {
}
});
- glWindow.setSize(width, height);
- glWindow.setVisible(true);
- animator.setUpdateFPSFrames(60, System.err);
animator.start();
+
+ glWindow.setVisible(true);
+ System.err.println("NW chosen: "+glWindow.getDelegatedWindow().getChosenCapabilities());
+ System.err.println("GL chosen: "+glWindow.getChosenCapabilities());
+ System.err.println("window pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets());
+
+ animator.setUpdateFPSFrames(60, System.err);
+
while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
Thread.sleep(100);
}
@@ -106,20 +118,13 @@ public class TestRedSquareES2NEWT extends UITestCase {
@Test
public void test01GL2ES2() throws InterruptedException {
- GLCapabilities caps = new GLCapabilities(GLProfile.getGL2ES2());
- runTestGL(caps);
- }
-
- @Test
- public void test02GLES2() throws InterruptedException {
- if(!GLProfile.isAvailable(GLProfile.GLES2)) {
- System.out.println("GLProfile GLES2 n/a");
- return;
+ GLCapabilities caps = new GLCapabilities(forceES2 ? GLProfile.get(GLProfile.GLES2) : GLProfile.getGL2ES2());
+ for(int i=1; i<=loops; i++) {
+ System.err.println("Loop "+i+"/"+loops);
+ runTestGL(caps);
}
- GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES2));
- runTestGL(caps);
}
-
+
static long duration = 500; // ms
public static void main(String args[]) {
@@ -129,8 +134,15 @@ public class TestRedSquareES2NEWT extends UITestCase {
try {
duration = Integer.parseInt(args[i]);
} catch (Exception ex) { ex.printStackTrace(); }
+ } else if(args[i].equals("-es2")) {
+ forceES2 = true;
+ } else if(args[i].equals("-loops")) {
+ i++;
+ loops = MiscUtils.atoi(args[i], 1);
}
}
+ System.err.println("loops "+loops);
+ System.err.println("forceES2 "+forceES2);
org.junit.runner.JUnitCore.main(TestRedSquareES2NEWT.class.getName());
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java b/src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java
index 506fe2d97..9cbeabb85 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java
@@ -40,6 +40,15 @@ public class MiscUtils {
}
return def;
}
+
+ public static long atol(String str, long def) {
+ try {
+ return Long.parseLong(str);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ return def;
+ }
public static boolean setFieldIfExists(Object instance, String fieldName, Object value) {
try {