summaryrefslogtreecommitdiffstats
path: root/src/test/com/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-03-05 04:34:41 +0100
committerSven Gothel <[email protected]>2012-03-05 04:34:41 +0100
commit90c46b1ef1f199ceb63e85c85e9ebeb919d49c4a (patch)
treeded4b93e80eb39ff33c80638c10a531222c105a3 /src/test/com/jogamp
parent875042340b68137b584907c539b7b7ecc5c5b15c (diff)
Complete LOCK_SURFACE_CHANGED ; Introduce NativeVisualID (Daisy chaining *GraphicsConfiguration) ; ...
NativeVisualID: New interface for Capabilities implementations, allowing retrieval of the native 'visual id'. Impl. by WGL, X11 and EGL. JAWTWindow.lockSurface() - Detect surfaceHandle change an return LOCK_SURFACE_CHANGED (see: LOCK_SURFACE_CHANGED) EGLDrawable: - Impl. updateHandle() (see: LOCK_SURFACE_CHANGED) - use NativeVisualID for EGLGraphicsConfiguration selection to respect a native 'visual id' EGLContext.createContextImpl: Use NIO for attributes EGLDisplayUtil: Enhance eglGetDisplay w/ DEBUG code and NativeSurface / EGL_DEFAULT_DISPLAY variation EGL, XGL, WGL GraphicsConfiguration: - Don't set ALPHA_SIZE and STENCIL_SIZE if not requested in attribute list for context creation. - toString() shows proper identification, eg.: egl, x11, win32 .. EGLGraphicsConfigurationFactory: Daisy chain GraphicsConfigurationFactory for native device type (currently only X11). This allows choosing the EGLGraphicsConfiguration and hence native visual id based on EGL when invoked via the factory model (generic). In case EGLGraphicsConfigurationFactory is not suitable or doesn't produce a native visual id, it falls back the the original one. X11AWTGraphicsConfigurationFactory and X11Window: Use generic NativeVisualID which allows EGLGraphicsConfiguration implicit. *GraphicsConfiguration's DEBUG flag is pushed up to DefaultGraphicsConfiguration LOCK_SURFACE_CHANGED: - commit 006e9fe402a0a47b45fd2c4af51296aef895e8b5 - commit a0177c8a1048683e5d43f4712f8f9e37091d4e85 Impact: - Fixes EGL/GLES (wrapper/native) usage on X11, proper Xvisual selection w/ EGL - Fixes EGL/GLES (wrapper/native) usage on Windows, ANGLE works w/ NEWT and forced ES2
Diffstat (limited to 'src/test/com/jogamp')
-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 {