aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/com/jogamp/opengl/test/android/MovieCubeActivity0a.java13
-rw-r--r--src/test/com/jogamp/opengl/test/android/MovieCubeActivity0b.java13
-rw-r--r--src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java13
-rw-r--r--src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java18
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/FontSet01.java35
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/TestFontsNEWT00.java93
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java103
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWTBugXXXX.java224
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/GLEventListenerButton.java6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeMono.ttfbin0 -> 592632 bytes
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeMonoBold.ttfbin0 -> 299136 bytes
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeMonoBoldOblique.ttfbin0 -> 298940 bytes
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeMonoOblique.ttfbin0 -> 395188 bytes
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSans.ttfbin0 -> 1563256 bytes
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSansBold.ttfbin0 -> 416128 bytes
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSansBoldOblique.ttfbin0 -> 342492 bytes
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSansOblique.ttfbin0 -> 763676 bytes
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSerif.ttfbin0 -> 3303588 bytes
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSerifBold.ttfbin0 -> 1310828 bytes
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSerifBoldItalic.ttfbin0 -> 608676 bytes
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSerifItalic.ttfbin0 -> 922104 bytes
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/GLReadBuffer00Base.java13
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/GLReadBuffer00BaseAWT.java120
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/InitConcurrentBaseNEWT.java6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableFactoryNEWT.java180
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java8
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMix2DemosES2NEWT.java45
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java8
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOnThreadSharedContext1DemoES2NEWT.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLException01NEWT.java412
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLOffscreenAutoDrawableBug1044AWT.java106
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile00NEWT.java26
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile01NEWT.java973
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLCanvasAWT.java116
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLJPanelAWT.java121
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLWindowNEWT.java39
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGPUMemSec01NEWT.java6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestInitConcurrent01NEWT.java6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestInitConcurrent02NEWT.java8
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMapBufferRead01NEWT.java6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextNewtAWTBug523.java15
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java9
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java18
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3b.java18
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT0.java45
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT1.java16
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java95
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT3.java84
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT4.java231
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2SWT3.java18
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestVersionSemanticsNOUI.java40
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/GLContextDrawableSwitchBase0.java264
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/GLContextDrawableSwitchBase1.java (renamed from src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/GLContextDrawableSwitchBase.java)2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestBug722GLContextDrawableSwitchNewt2AWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch02AWT.java112
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch02NEWT.java100
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch11NewtAWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch12AWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch13Newt2AWT.java (renamed from src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch21Newt2AWT.java)4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/caps/TestTranslucencyNEWT.java14
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/FBOMix2DemosES2.java31
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java12
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/MultisampleDemoES2.java15
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw02ES2ListenerFBO.java31
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/CrossFadePlayer.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java19
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSBSStereo.java41
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java25
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelAWT.java34
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java13
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java78
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Teapot.java62
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/Bug818GLJPanelAndGLCanvasApplet.java (renamed from src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/Bug818GLJPanelApplet.java)30
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/GLJPanelsAndGLCanvasDemoGL2Applet.java180
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsGLJPanelAWT.java51
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TessellationShader01aGL4.java191
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TessellationShader01bGL4.java142
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/newt/TestTessellationShader01GL4NEWT.java117
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/shader/tess_example01.fp6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/shader/tess_example01.tcp12
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/shader/tess_example01.tep8
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/shader/tess_example01.vp12
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java8
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestTransformFeedbackVaryingsBug407NEWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit01AWT.java120
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java153
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/stereo/StereoDemo01.java50
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/TestMultipleNewtCanvasAWT.java185
-rw-r--r--src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java10
-rw-r--r--src/test/com/jogamp/opengl/test/junit/util/NEWTGLContext.java40
93 files changed, 4417 insertions, 1087 deletions
diff --git a/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0a.java b/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0a.java
index 79b6952ee..66959e90f 100644
--- a/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0a.java
+++ b/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0a.java
@@ -29,7 +29,6 @@ package com.jogamp.opengl.test.android;
import java.io.IOException;
import java.net.HttpURLConnection;
-import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLConnection;
import java.util.Arrays;
@@ -39,12 +38,12 @@ import javax.media.opengl.GLProfile;
import jogamp.newt.driver.android.NewtBaseActivity;
+import com.jogamp.common.net.Uri;
import com.jogamp.common.util.IOUtil;
import com.jogamp.newt.NewtFactory;
import com.jogamp.newt.event.MouseAdapter;
import com.jogamp.newt.event.MouseEvent;
import com.jogamp.newt.opengl.GLWindow;
-
import com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube;
import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.util.av.GLMediaPlayer;
@@ -75,7 +74,7 @@ public class MovieCubeActivity0a extends NewtBaseActivity {
System.getProperty("jnlp.media0_url0"),
System.getProperty("jnlp.media0_url1"),
System.getProperty("jnlp.media0_url2") };
- final URI streamLoc = getURI(streamLocs, 0, false);
+ final Uri streamLoc = getUri(streamLocs, 0, false);
if(null == streamLoc) { throw new RuntimeException("no media reachable: "+Arrays.asList(streamLocs)); }
// also initializes JOGL
@@ -136,15 +135,15 @@ public class MovieCubeActivity0a extends NewtBaseActivity {
Log.d(TAG, "onCreate - X");
}
- static URI getURI(final String path[], final int off, final boolean checkAvail) {
- URI uri = null;
+ static Uri getUri(final String path[], final int off, final boolean checkAvail) {
+ Uri uri = null;
for(int i=off; null==uri && i<path.length; i++) {
if(null != path[i] && path[i].length()>0) {
if( checkAvail ) {
final URLConnection uc = IOUtil.getResource(path[i], null);
if( null != uc ) {
try {
- uri = uc.getURL().toURI();
+ uri = Uri.valueOf(uc.getURL());
} catch (final URISyntaxException e) {
uri = null;
}
@@ -154,7 +153,7 @@ public class MovieCubeActivity0a extends NewtBaseActivity {
}
} else {
try {
- uri = new URI(path[i]);
+ uri = Uri.cast(path[i]);
} catch (final URISyntaxException e) {
uri = null;
}
diff --git a/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0b.java b/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0b.java
index 5303276a6..33dbe8fc5 100644
--- a/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0b.java
+++ b/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0b.java
@@ -29,7 +29,6 @@ package com.jogamp.opengl.test.android;
import java.io.IOException;
import java.net.HttpURLConnection;
-import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLConnection;
import java.util.Arrays;
@@ -39,12 +38,12 @@ import javax.media.opengl.GLProfile;
import jogamp.newt.driver.android.NewtBaseActivity;
+import com.jogamp.common.net.Uri;
import com.jogamp.common.util.IOUtil;
import com.jogamp.newt.NewtFactory;
import com.jogamp.newt.event.MouseAdapter;
import com.jogamp.newt.event.MouseEvent;
import com.jogamp.newt.opengl.GLWindow;
-
import com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube;
import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.util.av.GLMediaPlayer;
@@ -75,7 +74,7 @@ public class MovieCubeActivity0b extends NewtBaseActivity {
System.getProperty("jnlp.media0_url0"),
System.getProperty("jnlp.media0_url1"),
System.getProperty("jnlp.media0_url2") };
- final URI streamLoc = getURI(streamLocs, 0, false);
+ final Uri streamLoc = getUri(streamLocs, 0, false);
if(null == streamLoc) { throw new RuntimeException("no media reachable: "+Arrays.asList(streamLocs)); }
// also initializes JOGL
@@ -138,15 +137,15 @@ public class MovieCubeActivity0b extends NewtBaseActivity {
Log.d(TAG, "onCreate - X");
}
- static URI getURI(final String path[], final int off, final boolean checkAvail) {
- URI uri = null;
+ static Uri getUri(final String path[], final int off, final boolean checkAvail) {
+ Uri uri = null;
for(int i=off; null==uri && i<path.length; i++) {
if(null != path[i] && path[i].length()>0) {
if( checkAvail ) {
final URLConnection uc = IOUtil.getResource(path[i], null);
if( null != uc ) {
try {
- uri = uc.getURL().toURI();
+ uri = Uri.valueOf(uc.getURL());
} catch (final URISyntaxException e) {
uri = null;
}
@@ -156,7 +155,7 @@ public class MovieCubeActivity0b extends NewtBaseActivity {
}
} else {
try {
- uri = new URI(path[i]);
+ uri = Uri.cast(path[i]);
} catch (final URISyntaxException e) {
uri = null;
}
diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java
index 47e1b1796..5991e28ee 100644
--- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java
+++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java
@@ -28,7 +28,6 @@
package com.jogamp.opengl.test.android;
import java.net.HttpURLConnection;
-import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLConnection;
import java.util.Arrays;
@@ -38,13 +37,13 @@ import javax.media.opengl.GLProfile;
import jogamp.newt.driver.android.NewtBaseActivity;
+import com.jogamp.common.net.Uri;
import com.jogamp.common.util.IOUtil;
import com.jogamp.newt.NewtFactory;
import com.jogamp.newt.Window;
import com.jogamp.newt.event.MouseAdapter;
import com.jogamp.newt.event.MouseEvent;
import com.jogamp.newt.opengl.GLWindow;
-
import com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple;
import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.util.av.GLMediaPlayer;
@@ -74,7 +73,7 @@ public class MovieSimpleActivity0 extends NewtBaseActivity {
System.getProperty("jnlp.media0_url0"),
System.getProperty("jnlp.media0_url1"),
System.getProperty("jnlp.media0_url2") };
- final URI streamLoc = getURI(streamLocs, 0, false);
+ final Uri streamLoc = getUri(streamLocs, 0, false);
if(null == streamLoc) { throw new RuntimeException("no media reachable: "+Arrays.asList(streamLocs)); }
// also initializes JOGL
@@ -129,15 +128,15 @@ public class MovieSimpleActivity0 extends NewtBaseActivity {
Log.d(TAG, "onCreate - X");
}
- static URI getURI(final String path[], final int off, final boolean checkAvail) {
- URI uri = null;
+ static Uri getUri(final String path[], final int off, final boolean checkAvail) {
+ Uri uri = null;
for(int i=off; null==uri && i<path.length; i++) {
if(null != path[i] && path[i].length()>0) {
if( checkAvail ) {
final URLConnection uc = IOUtil.getResource(path[i], null);
if( null != uc ) {
try {
- uri = uc.getURL().toURI();
+ uri = Uri.valueOf(uc.getURL());
} catch (final URISyntaxException e) {
uri = null;
}
@@ -147,7 +146,7 @@ public class MovieSimpleActivity0 extends NewtBaseActivity {
}
} else {
try {
- uri = new URI(path[i]);
+ uri = Uri.cast(path[i]);
} catch (final URISyntaxException e) {
uri = null;
}
diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java
index 7c99e2cf3..0267db514 100644
--- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java
+++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java
@@ -28,7 +28,6 @@
package com.jogamp.opengl.test.android;
import java.net.HttpURLConnection;
-import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLConnection;
import java.util.Arrays;
@@ -41,6 +40,7 @@ import javax.media.opengl.GLRunnable;
import jogamp.newt.driver.android.NewtBaseActivity;
+import com.jogamp.common.net.Uri;
import com.jogamp.common.util.IOUtil;
import com.jogamp.newt.NewtFactory;
import com.jogamp.newt.Window;
@@ -82,15 +82,15 @@ public class MovieSimpleActivity1 extends NewtBaseActivity {
System.getProperty("jnlp.media0_url0"),
System.getProperty("jnlp.media0_url1"),
System.getProperty("jnlp.media0_url2") };
- final URI streamLoc0 = getURI(streamLocs, 2, false);
+ final Uri streamLoc0 = getUri(streamLocs, 2, false);
if(null == streamLoc0) { throw new RuntimeException("no media reachable: "+Arrays.asList(streamLocs)); }
- final URI streamLoc1;
+ final Uri streamLoc1;
{
- URI _streamLoc1 = null;
+ Uri _streamLoc1 = null;
if(mPlayerHUD && !mPlayerSharedHUD) {
final String[] urls1 = new String[] { System.getProperty("jnlp.media1_url0") };
- _streamLoc1 = getURI(urls1, 1, false);
+ _streamLoc1 = getUri(urls1, 1, false);
}
if(null == _streamLoc1) { _streamLoc1 = streamLoc0; }
streamLoc1 = _streamLoc1;
@@ -231,15 +231,15 @@ public class MovieSimpleActivity1 extends NewtBaseActivity {
Log.d(TAG, "onCreate - X");
}
- static URI getURI(final String path[], final int off, final boolean checkAvail) {
- URI uri = null;
+ static Uri getUri(final String path[], final int off, final boolean checkAvail) {
+ Uri uri = null;
for(int i=off; null==uri && i<path.length; i++) {
if(null != path[i] && path[i].length()>0) {
if( checkAvail ) {
final URLConnection uc = IOUtil.getResource(path[i], null);
if( null != uc ) {
try {
- uri = uc.getURL().toURI();
+ uri = Uri.valueOf(uc.getURL());
} catch (final URISyntaxException e) {
uri = null;
}
@@ -249,7 +249,7 @@ public class MovieSimpleActivity1 extends NewtBaseActivity {
}
} else {
try {
- uri = new URI(path[i]);
+ uri = Uri.cast(path[i]);
} catch (final URISyntaxException e) {
uri = null;
}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/FontSet01.java b/src/test/com/jogamp/opengl/test/junit/graph/FontSet01.java
new file mode 100644
index 000000000..03a00af78
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/graph/FontSet01.java
@@ -0,0 +1,35 @@
+package com.jogamp.opengl.test.junit.graph;
+
+import java.io.IOException;
+
+import com.jogamp.common.util.IOUtil;
+import com.jogamp.graph.font.Font;
+import com.jogamp.graph.font.FontFactory;
+import com.jogamp.graph.font.FontSet;
+
+public class FontSet01 {
+ public static Font[] getSet01() throws IOException {
+ final Font[] fonts = new Font[11];
+ int i = 0;
+ fonts[i++] = FontFactory.get(FontFactory.UBUNTU).getDefault(); // FontSet.FAMILY_REGULAR, FontSet.STYLE_NONE
+ fonts[i++] = FontFactory.get(FontFactory.UBUNTU).get(FontSet.FAMILY_REGULAR, FontSet.STYLE_ITALIC);
+ fonts[i++] = FontFactory.get(FontFactory.UBUNTU).get(FontSet.FAMILY_REGULAR, FontSet.STYLE_BOLD);
+ fonts[i++] = FontFactory.get(IOUtil.getResource(TestTextRendererNEWTBugXXXX.class,
+ "fonts/freefont/FreeMono.ttf"));
+ fonts[i++] = FontFactory.get(IOUtil.getResource(TestTextRendererNEWTBugXXXX.class,
+ "fonts/freefont/FreeMonoBold.ttf"));
+ fonts[i++] = FontFactory.get(IOUtil.getResource(TestTextRendererNEWTBugXXXX.class,
+ "fonts/freefont/FreeSans.ttf"));
+ fonts[i++] = FontFactory.get(IOUtil.getResource(TestTextRendererNEWTBugXXXX.class,
+ "fonts/freefont/FreeSansBold.ttf"));
+ fonts[i++] = FontFactory.get(IOUtil.getResource(TestTextRendererNEWTBugXXXX.class,
+ "fonts/freefont/FreeSerif.ttf"));
+ fonts[i++] = FontFactory.get(IOUtil.getResource(TestTextRendererNEWTBugXXXX.class,
+ "fonts/freefont/FreeSerifBold.ttf"));
+ fonts[i++] = FontFactory.get(IOUtil.getResource(TestTextRendererNEWTBugXXXX.class,
+ "fonts/freefont/FreeSerifBoldItalic.ttf"));
+ fonts[i++] = FontFactory.get(IOUtil.getResource(TestTextRendererNEWTBugXXXX.class,
+ "fonts/freefont/FreeSerifItalic.ttf"));
+ return fonts;
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestFontsNEWT00.java b/src/test/com/jogamp/opengl/test/junit/graph/TestFontsNEWT00.java
new file mode 100644
index 000000000..e0c6d2ac0
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/graph/TestFontsNEWT00.java
@@ -0,0 +1,93 @@
+/**
+ * Copyright 2012 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.opengl.test.junit.graph;
+
+import java.io.IOException;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.FixMethodOrder;
+import org.junit.runners.MethodSorters;
+
+import com.jogamp.graph.font.Font;
+import com.jogamp.graph.font.Font.Glyph;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestFontsNEWT00 extends UITestCase {
+ static boolean mainRun = false;
+
+ static int atoi(final String a) {
+ try {
+ return Integer.parseInt(a);
+ } catch (final Exception ex) { throw new RuntimeException(ex); }
+ }
+
+ public static void main(final String args[]) throws IOException {
+ mainRun = true;
+ final String tstname = TestFontsNEWT00.class.getName();
+ org.junit.runner.JUnitCore.main(tstname);
+ }
+
+ @Test
+ public void test00() throws InterruptedException, IOException {
+ testFontImpl(FontSet01.getSet01());
+ }
+ void testFontImpl(final Font[] fonts) throws InterruptedException, IOException {
+ final float fontSize = 10;
+ final float dpi = 96;
+ for(int i=0; i<fonts.length; i++) {
+ final Font font = fonts[i];
+ final float pixelSize = font.getPixelSize(fontSize, dpi);
+ System.err.println(font.getFullFamilyName(null).toString()+": "+fontSize+"p, "+dpi+"dpi -> "+pixelSize+"px:");
+ testFontGlyphAdvancedSize(font, ' ', Glyph.ID_SPACE, fontSize, dpi, pixelSize);
+ testFontGlyphAdvancedSize(font, 'X', 'X', fontSize, dpi, pixelSize);
+ }
+ }
+ void testFontGlyphAdvancedSize(final Font font, final char c, final int glyphID,
+ final float fontSize, final float dpi, final float pixelSize) {
+ final float glyphScale = font.getGlyph(c).getScale(pixelSize);
+ final float fontScale = font.getMetrics().getScale(pixelSize);
+
+ // return this.metrics.getAdvance(pixelSize, useFrationalMetrics);
+ // this.metrics.getAdvance(pixelSize, useFrationalMetrics)
+ // this.advance * this.font.getMetrics().getScale(pixelSize)
+ // font.getHmtxTable().getAdvanceWidth(glyphID) * this.font.getMetrics().getScale(pixelSize)
+ final float spaceAdvanceSizeOfGlyph = font.getGlyph(c).getAdvance(pixelSize, true);
+
+ // font.getHmtxTable().getAdvanceWidth(glyphID) * metrics.getScale(pixelSize);
+ // font.getHmtxTable().getAdvanceWidth(glyphID) * pixelSize * unitsPerEM_Inv;
+ final float spaceAdvanceWidth = font.getAdvanceWidth(glyphID, pixelSize);
+ System.err.println(" Char '"+c+"', "+glyphID+":");
+ System.err.println(" glyphScale "+glyphScale);
+ System.err.println(" glyphSize "+spaceAdvanceSizeOfGlyph);
+ System.err.println(" fontScale "+fontScale);
+ System.err.println(" fontWidth "+spaceAdvanceWidth);
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java
index cb9f3e3d4..c0753ba85 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java
@@ -27,12 +27,14 @@
*/
package com.jogamp.opengl.test.junit.graph;
+import java.io.File;
import java.io.IOException;
import javax.media.opengl.GL;
import javax.media.opengl.GL2ES2;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLDrawable;
+import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
import javax.media.opengl.fixedfunc.GLMatrixFunc;
@@ -42,6 +44,8 @@ import org.junit.Test;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
+import com.jogamp.common.util.IOUtil;
+import com.jogamp.graph.curve.Region;
import com.jogamp.graph.curve.opengl.RenderState;
import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.graph.curve.opengl.TextRegionUtil;
@@ -49,8 +53,10 @@ import com.jogamp.graph.font.Font;
import com.jogamp.graph.font.FontFactory;
import com.jogamp.graph.geom.SVertex;
import com.jogamp.opengl.math.geom.AABBox;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.test.junit.util.NEWTGLContext;
import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.GLReadBufferUtil;
import com.jogamp.opengl.util.PMVMatrix;
@@ -64,13 +70,16 @@ public class TestTextRendererNEWT10 extends UITestCase {
static boolean mainRun = false;
static boolean useMSAA = true;
- static final int[] texSize = new int[] { 0 };
- static final int fontSize = 24;
static Font font;
+ static float fontSize = 24;
+ static String customStr = null;
@BeforeClass
public static void setup() throws IOException {
- font = FontFactory.get(FontFactory.UBUNTU).getDefault();
+ if( null == font ) {
+ font = FontFactory.get(FontFactory.UBUNTU).getDefault();
+ // font = FontFactory.get(FontFactory.JAVA).getDefault();
+ }
}
static int atoi(final String a) {
@@ -91,6 +100,15 @@ public class TestTextRendererNEWT10 extends UITestCase {
forceES2 = true;
} else if(args[i].equals("-gl3")) {
forceGL3 = true;
+ } else if(args[i].equals("-font")) {
+ i++;
+ font = FontFactory.get(IOUtil.getResource(TestTextRendererNEWT10.class, args[i]));
+ } else if(args[i].equals("-fontSize")) {
+ i++;
+ fontSize = MiscUtils.atof(args[i], fontSize);
+ } else if(args[i].equals("-text")) {
+ i++;
+ customStr = args[i];
}
}
final String tstname = TestTextRendererNEWT10.class.getName();
@@ -104,17 +122,22 @@ public class TestTextRendererNEWT10 extends UITestCase {
} catch (final InterruptedException ie) {}
}
- // @Test
- public void test00TextRendererNONE01() throws InterruptedException {
- testTextRendererImpl(0);
+ @Test
+ public void test00TextRendererNONE00() throws InterruptedException, GLException, IOException {
+ testTextRendererImpl(0, 0);
}
@Test
- public void testTextRendererMSAA01() throws InterruptedException {
- testTextRendererImpl(4);
+ public void test01TextRendererMSAA04() throws InterruptedException, GLException, IOException {
+ testTextRendererImpl(0, 4);
}
- void testTextRendererImpl(final int sampleCount) throws InterruptedException {
+ @Test
+ public void test02TextRendererVBAA04() throws InterruptedException, GLException, IOException {
+ testTextRendererImpl(Region.VBAA_RENDERING_BIT, 4);
+ }
+
+ void testTextRendererImpl(final int renderModes, final int sampleCount) throws InterruptedException, GLException, IOException {
final GLProfile glp;
if(forceGL3) {
glp = GLProfile.get(GLProfile.GL3);
@@ -123,15 +146,17 @@ public class TestTextRendererNEWT10 extends UITestCase {
} else {
glp = GLProfile.getGL2ES2();
}
+
final GLCapabilities caps = new GLCapabilities( glp );
caps.setAlphaBits(4);
- if( 0 < sampleCount ) {
+ if( 0 < sampleCount && !Region.isVBAA(renderModes) ) {
caps.setSampleBuffers(true);
caps.setNumSamples(sampleCount);
}
System.err.println("Requested: "+caps);
+ System.err.println("Requested: "+Region.getRenderModeString(renderModes));
- final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(caps, 800, 400, true);
+ final NEWTGLContext.WindowContext winctx = NEWTGLContext.createWindow(caps, 800, 400, true);
final GLDrawable drawable = winctx.context.getGLDrawable();
final GL2ES2 gl = winctx.context.getGL().getGL2ES2();
@@ -142,12 +167,13 @@ public class TestTextRendererNEWT10 extends UITestCase {
final RenderState rs = RenderState.createRenderState(SVertex.factory());
final RegionRenderer renderer = RegionRenderer.create(rs, RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable);
rs.setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED);
- final TextRegionUtil textRenderUtil = new TextRegionUtil(0);
+ final TextRegionUtil textRenderUtil = new TextRegionUtil(renderModes);
// init
gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
renderer.init(gl, 0);
rs.setColorStatic(0.1f, 0.1f, 0.1f, 1.0f);
+ screenshot = new GLReadBufferUtil(false, false);
// reshape
gl.glViewport(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
@@ -155,32 +181,40 @@ public class TestTextRendererNEWT10 extends UITestCase {
// renderer.reshapePerspective(gl, 45.0f, drawable.getWidth(), drawable.getHeight(), 0.1f, 1000.0f);
renderer.reshapeOrtho(drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), 0.1f, 1000.0f);
+ final int[] sampleCountIO = { sampleCount };
// display
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
- renderString(drawable, gl, renderer, textRenderUtil, "012345678901234567890123456789", 0, 0, -1000);
- renderString(drawable, gl, renderer, textRenderUtil, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", 0, -1, -1000);
- renderString(drawable, gl, renderer, textRenderUtil, "Hello World", 0, -1, -1000);
- renderString(drawable, gl, renderer, textRenderUtil, "4567890123456", 4, -1, -1000);
- renderString(drawable, gl, renderer, textRenderUtil, "I like JogAmp", 4, -1, -1000);
-
- int c = 0;
- renderString(drawable, gl, renderer, textRenderUtil, "GlueGen", c++, -1, -1000);
- renderString(drawable, gl, renderer, textRenderUtil, "JOAL", c++, -1, -1000);
- renderString(drawable, gl, renderer, textRenderUtil, "JOGL", c++, -1, -1000);
- renderString(drawable, gl, renderer, textRenderUtil, "JOCL", c++, -1, -1000);
-
+ if( null == customStr ) {
+ renderString(drawable, gl, renderer, textRenderUtil, "012345678901234567890123456789", 0, 0, -1000, sampleCountIO);
+ renderString(drawable, gl, renderer, textRenderUtil, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", 0, -1, -1000, sampleCountIO);
+ renderString(drawable, gl, renderer, textRenderUtil, "Hello World", 0, -1, -1000, sampleCountIO);
+ renderString(drawable, gl, renderer, textRenderUtil, "4567890123456", 4, -1, -1000,sampleCountIO);
+ renderString(drawable, gl, renderer, textRenderUtil, "I like JogAmp", 4, -1, -1000, sampleCountIO);
+
+ int c = 0;
+ renderString(drawable, gl, renderer, textRenderUtil, "GlueGen", c++, -1, -1000, sampleCountIO);
+ renderString(drawable, gl, renderer, textRenderUtil, "JOAL", c++, -1, -1000, sampleCountIO);
+ renderString(drawable, gl, renderer, textRenderUtil, "JOGL", c++, -1, -1000, sampleCountIO);
+ renderString(drawable, gl, renderer, textRenderUtil, "JOCL", c++, -1, -1000, sampleCountIO);
+ } else {
+ renderString(drawable, gl, renderer, textRenderUtil, customStr, 0, 0, -1000, sampleCountIO);
+ }
drawable.swapBuffers();
+ printScreen(renderModes, drawable, gl, false, sampleCount);
+
sleep();
// dispose
+ screenshot.dispose(gl);
renderer.destroy(gl);
NEWTGLContext.destroyWindow(winctx);
}
+ private GLReadBufferUtil screenshot;
int lastRow = -1;
- void renderString(final GLDrawable drawable, final GL2ES2 gl, final RegionRenderer renderer, final TextRegionUtil textRenderUtil, final String text, final int column, int row, final int z0) {
+ void renderString(final GLDrawable drawable, final GL2ES2 gl, final RegionRenderer renderer, final TextRegionUtil textRenderUtil, final String text, final int column, int row, final int z0, final int[] sampleCount) {
final int height = drawable.getSurfaceHeight();
int dx = 0;
@@ -196,8 +230,25 @@ public class TestTextRendererNEWT10 extends UITestCase {
pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
pmv.glLoadIdentity();
pmv.glTranslatef(dx, dy, z0);
- textRenderUtil.drawString3D(gl, renderer, font, fontSize, text, null, texSize);
+ textRenderUtil.drawString3D(gl, renderer, font, fontSize, text, null, sampleCount);
lastRow = row;
}
+
+ private int screenshot_num = 0;
+
+ public void printScreen(final int renderModes, final GLDrawable drawable, final GL gl, final boolean exportAlpha, final int sampleCount) throws GLException, IOException {
+ final String dir = "./";
+ final String objName = getSimpleTestName(".")+"-snap"+screenshot_num;
+ screenshot_num++;
+ final String modeS = Region.getRenderModeString(renderModes);
+ final String bname = String.format("%s-msaa%02d-fontsz%02.1f-%03dx%03d-%s%04d", objName,
+ drawable.getChosenGLCapabilities().getNumSamples(),
+ TestTextRendererNEWT10.fontSize, drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), modeS, sampleCount);
+ final String filename = dir + bname +".png";
+ if(screenshot.readPixels(gl, false)) {
+ screenshot.write(new File(filename));
+ }
+ }
+
}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWTBugXXXX.java b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWTBugXXXX.java
new file mode 100644
index 000000000..d6affd7e2
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWTBugXXXX.java
@@ -0,0 +1,224 @@
+/**
+ * Copyright 2012 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.opengl.test.junit.graph;
+
+import java.io.File;
+import java.io.IOException;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2ES2;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLDrawable;
+import javax.media.opengl.GLException;
+import javax.media.opengl.GLProfile;
+import javax.media.opengl.fixedfunc.GLMatrixFunc;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.FixMethodOrder;
+import org.junit.runners.MethodSorters;
+
+import com.jogamp.graph.curve.Region;
+import com.jogamp.graph.curve.opengl.RenderState;
+import com.jogamp.graph.curve.opengl.RegionRenderer;
+import com.jogamp.graph.curve.opengl.TextRegionUtil;
+import com.jogamp.graph.font.Font;
+import com.jogamp.graph.geom.SVertex;
+import com.jogamp.opengl.math.geom.AABBox;
+import com.jogamp.opengl.test.junit.util.NEWTGLContext;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.GLReadBufferUtil;
+import com.jogamp.opengl.util.PMVMatrix;
+
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestTextRendererNEWTBugXXXX extends UITestCase {
+ static long duration = 100; // ms
+ static boolean forceES2 = false;
+ static boolean forceGL3 = false;
+ static boolean mainRun = false;
+ static boolean useMSAA = true;
+ static boolean onlyIssues = false;
+
+ static final float fontSize = 24;
+
+ static int atoi(final String a) {
+ try {
+ return Integer.parseInt(a);
+ } catch (final Exception ex) { throw new RuntimeException(ex); }
+ }
+
+ public static void main(final String args[]) throws IOException {
+ mainRun = true;
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ duration = atoi(args[i]);
+ } else if(args[i].equals("-noMSAA")) {
+ useMSAA = false;
+ } else if(args[i].equals("-es2")) {
+ forceES2 = true;
+ } else if(args[i].equals("-gl3")) {
+ forceGL3 = true;
+ }
+ }
+ final String tstname = TestTextRendererNEWTBugXXXX.class.getName();
+ org.junit.runner.JUnitCore.main(tstname);
+ }
+
+ static void sleep() {
+ try {
+ System.err.println("** new frame ** (sleep: "+duration+"ms)");
+ Thread.sleep(duration);
+ } catch (final InterruptedException ie) {}
+ }
+
+ @Test
+ public void test00All() throws InterruptedException, GLException, IOException {
+ testTextRendererImpl(FontSet01.getSet01(), Region.VBAA_RENDERING_BIT, 4, false);
+ }
+ @Test
+ public void test01OnlyIssues() throws InterruptedException, GLException, IOException {
+ testTextRendererImpl(FontSet01.getSet01(), Region.VBAA_RENDERING_BIT, 4, true);
+ }
+ void testTextRendererImpl(final Font[] fonts, final int renderModes, final int sampleCount, final boolean onlyIssues) throws InterruptedException, GLException, IOException {
+ final GLProfile glp;
+ if(forceGL3) {
+ glp = GLProfile.get(GLProfile.GL3);
+ } else if(forceES2) {
+ glp = GLProfile.get(GLProfile.GLES2);
+ } else {
+ glp = GLProfile.getGL2ES2();
+ }
+
+ final GLCapabilities caps = new GLCapabilities( glp );
+ caps.setAlphaBits(4);
+ if( 0 < sampleCount && !Region.isVBAA(renderModes) ) {
+ caps.setSampleBuffers(true);
+ caps.setNumSamples(sampleCount);
+ }
+ caps.setOnscreen(false);
+ System.err.println("Requested: "+caps);
+ System.err.println("Requested: "+Region.getRenderModeString(renderModes));
+
+ final int totalHeight = ( (int)fontSize + 1 ) * ( onlyIssues ? 3 : 6 ) * fonts.length;
+ final NEWTGLContext.WindowContext winctx =
+ NEWTGLContext.createWindow(caps, 800, totalHeight, true);
+ final GLDrawable drawable = winctx.context.getGLDrawable();
+ final GL2ES2 gl = winctx.context.getGL().getGL2ES2();
+
+ Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
+
+ System.err.println("Chosen: "+winctx.window.getChosenCapabilities());
+
+ final RenderState rs = RenderState.createRenderState(SVertex.factory());
+ final RegionRenderer renderer = RegionRenderer.create(rs, RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable);
+ rs.setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED);
+ final TextRegionUtil textRenderUtil = new TextRegionUtil(renderModes);
+
+ // init
+ gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
+ renderer.init(gl, 0);
+ rs.setColorStatic(0.1f, 0.1f, 0.1f, 1.0f);
+ screenshot = new GLReadBufferUtil(false, false);
+
+ // reshape
+ gl.glViewport(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
+
+ // renderer.reshapePerspective(gl, 45.0f, drawable.getWidth(), drawable.getHeight(), 0.1f, 1000.0f);
+ renderer.reshapeOrtho(drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), 0.1f, 1000.0f);
+
+ final int[] sampleCountIO = { sampleCount };
+ // display
+ gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
+ for(int i=0; i<fonts.length; i++) {
+ final Font font = fonts[i];
+ renderString(drawable, gl, renderer, font, textRenderUtil, font.getFullFamilyName(null).toString()+": "+issues, 0, 0==i?0:-1, -1000, sampleCountIO);
+ if(!onlyIssues) {
+ renderString(drawable, gl, renderer, font, textRenderUtil, "012345678901234567890123456789", 0, -1, -1000, sampleCountIO);
+ renderString(drawable, gl, renderer, font, textRenderUtil, "abcdefghijklmnopqrstuvwxyz", 0, -1, -1000, sampleCountIO);
+ renderString(drawable, gl, renderer, font, textRenderUtil, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 0, -1, -1000, sampleCountIO);
+ }
+ renderString(drawable, gl, renderer, font, textRenderUtil, "", 0, -1, -1000, sampleCountIO);
+ renderString(drawable, gl, renderer, font, textRenderUtil, "", 0, -1, -1000, sampleCountIO);
+ }
+
+ drawable.swapBuffers();
+ printScreen(renderModes, drawable, gl, false, sampleCount);
+
+ sleep();
+
+ // dispose
+ screenshot.dispose(gl);
+ renderer.destroy(gl);
+
+ NEWTGLContext.destroyWindow(winctx);
+ }
+
+ private static final String issues = "m M n u 8 g q Q";
+ private GLReadBufferUtil screenshot;
+ int lastRow = -1;
+
+ void renderString(final GLDrawable drawable, final GL2ES2 gl, final RegionRenderer renderer, final Font font, final TextRegionUtil textRenderUtil, final String text, final int column, int row, final int z0, final int[] sampleCount) {
+ final int height = drawable.getSurfaceHeight();
+
+ int dx = 0;
+ int dy = height;
+ if(0>row) {
+ row = lastRow + 1;
+ }
+ final AABBox textBox = font.getMetricBounds(text, fontSize);
+ dx += font.getAdvanceWidth('X', fontSize) * column;
+ dy -= (int)textBox.getHeight() * ( row + 1 );
+
+ final PMVMatrix pmv = renderer.getMatrix();
+ pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
+ pmv.glLoadIdentity();
+ pmv.glTranslatef(dx, dy, z0);
+ textRenderUtil.drawString3D(gl, renderer, font, fontSize, text, null, sampleCount);
+
+ lastRow = row;
+ }
+
+ private int screenshot_num = 0;
+
+ public void printScreen(final int renderModes, final GLDrawable drawable, final GL gl, final boolean exportAlpha, final int sampleCount) throws GLException, IOException {
+ final String dir = "./";
+ final String objName = getSimpleTestName(".")+"-snap"+screenshot_num;
+ screenshot_num++;
+ final String modeS = Region.getRenderModeString(renderModes);
+ final String bname = String.format("%s-msaa%02d-fontsz%02.1f-%03dx%03d-%s%04d", objName,
+ drawable.getChosenGLCapabilities().getNumSamples(),
+ TestTextRendererNEWTBugXXXX.fontSize, drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), modeS, sampleCount);
+ final String filename = dir + bname +".png";
+ if(screenshot.readPixels(gl, false)) {
+ screenshot.write(new File(filename));
+ }
+ }
+
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java
index 784fe1009..b10a89a8f 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java
@@ -2,7 +2,6 @@ package com.jogamp.opengl.test.junit.graph.demos;
import java.io.File;
import java.io.IOException;
-import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
@@ -17,6 +16,7 @@ import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLPipelineFactory;
import javax.media.opengl.GLRunnable;
+import com.jogamp.common.net.Uri;
import com.jogamp.graph.curve.Region;
import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.graph.curve.opengl.RenderState;
@@ -536,7 +536,7 @@ public class GPUUISceneGLListener0A implements GLEventListener {
} } );
buttons.add(mPlayerButton);
try {
- final URI streamLoc = new URI("http://archive.org/download/BigBuckBunny_328/BigBuckBunny_512kb.mp4");
+ final Uri streamLoc = Uri.cast("http://archive.org/download/BigBuckBunny_328/BigBuckBunny_512kb.mp4");
mPlayer.initStream(streamLoc, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.TEXTURE_COUNT_DEFAULT);
} catch (final URISyntaxException e1) {
e1.printStackTrace();
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/GLEventListenerButton.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/GLEventListenerButton.java
index bdbb77f2d..a8cd32035 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/GLEventListenerButton.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/GLEventListenerButton.java
@@ -89,8 +89,8 @@ public class GLEventListenerButton extends TextureSeqButton {
final GLContext ctx = gl.getContext();
final GLDrawable drawable = ctx.getGLDrawable();
- final GLCapabilitiesImmutable capsHas = drawable.getChosenGLCapabilities();
- final GLCapabilities caps = (GLCapabilities) capsHas.cloneMutable();
+ final GLCapabilitiesImmutable reqCaps = drawable.getRequestedGLCapabilities();
+ final GLCapabilities caps = (GLCapabilities) reqCaps.cloneMutable();
caps.setFBO(true);
caps.setDoubleBuffered(false);
if( !useAlpha ) {
@@ -108,7 +108,7 @@ public class GLEventListenerButton extends TextureSeqButton {
fboGLAD.addGLEventListener(glel);
fboGLAD.display(); // 1st init!
- final FBObject.TextureAttachment texA01 = fboGLAD.getTextureBuffer(GL.GL_FRONT);
+ final FBObject.TextureAttachment texA01 = fboGLAD.getColorbuffer(GL.GL_FRONT).getTextureAttachment();
final Texture tex = new Texture(texA01.getName(), imgSeq.getTextureTarget(),
fboGLAD.getSurfaceWidth(), fboGLAD.getSurfaceHeight(), fboGLAD.getSurfaceWidth(), fboGLAD.getSurfaceHeight(),
false /* mustFlipVertically */);
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeMono.ttf b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeMono.ttf
new file mode 100644
index 000000000..c4200565a
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeMono.ttf
Binary files differ
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeMonoBold.ttf b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeMonoBold.ttf
new file mode 100644
index 000000000..0bee057ec
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeMonoBold.ttf
Binary files differ
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeMonoBoldOblique.ttf b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeMonoBoldOblique.ttf
new file mode 100644
index 000000000..91bbc0e8a
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeMonoBoldOblique.ttf
Binary files differ
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeMonoOblique.ttf b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeMonoOblique.ttf
new file mode 100644
index 000000000..3252bdda6
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeMonoOblique.ttf
Binary files differ
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSans.ttf b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSans.ttf
new file mode 100644
index 000000000..e56dc6e90
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSans.ttf
Binary files differ
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSansBold.ttf b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSansBold.ttf
new file mode 100644
index 000000000..66e19ecb0
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSansBold.ttf
Binary files differ
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSansBoldOblique.ttf b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSansBoldOblique.ttf
new file mode 100644
index 000000000..de8a9e153
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSansBoldOblique.ttf
Binary files differ
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSansOblique.ttf b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSansOblique.ttf
new file mode 100644
index 000000000..b0357eabb
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSansOblique.ttf
Binary files differ
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSerif.ttf b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSerif.ttf
new file mode 100644
index 000000000..dffa1aedb
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSerif.ttf
Binary files differ
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSerifBold.ttf b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSerifBold.ttf
new file mode 100644
index 000000000..e2393ad22
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSerifBold.ttf
Binary files differ
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSerifBoldItalic.ttf b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSerifBoldItalic.ttf
new file mode 100644
index 000000000..46bc4695f
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSerifBoldItalic.ttf
Binary files differ
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSerifItalic.ttf b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSerifItalic.ttf
new file mode 100644
index 000000000..d173e3566
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSerifItalic.ttf
Binary files differ
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/GLReadBuffer00Base.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/GLReadBuffer00Base.java
index 26974eb30..710f53f92 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/GLReadBuffer00Base.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/GLReadBuffer00Base.java
@@ -48,7 +48,18 @@ import com.jogamp.opengl.test.junit.graph.TextRendererGLELBase;
import com.jogamp.opengl.test.junit.util.UITestCase;
/**
- * Multiple GLJPanels in a JFrame
+ * Test synchronous GLAutoDrawable display, swap-buffer and read-pixels
+ * including non-MSAA and MSAA framebuffer.
+ * <p>
+ * Analyzes behavior of reported bugs
+ * <ul>
+ * <li>Bug 841 - GLJPanel "lagging" by one frame, https://jogamp.org/bugzilla/show_bug.cgi?id=841</li>
+ * <li>Bug 975 - GLJPanel's OffscreenDrawable shall not double swap (custom swap by GLEventListener using [AWT]GLReadBufferUtil),
+ * https://jogamp.org/bugzilla/show_bug.cgi?id=975</li>
+ * <li>Bug 1020 - First frame on a mac nvidia card not antialiased, https://jogamp.org/bugzilla/show_bug.cgi?id=841</li>
+ * </ul>
+ * </p>
+ *
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public abstract class GLReadBuffer00Base extends UITestCase {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/GLReadBuffer00BaseAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/GLReadBuffer00BaseAWT.java
new file mode 100644
index 000000000..be0d38357
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/GLReadBuffer00BaseAWT.java
@@ -0,0 +1,120 @@
+/**
+ * Copyright 2014 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.opengl.test.junit.jogl.acore;
+
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+
+import javax.imageio.ImageIO;
+import javax.media.opengl.GL;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLDrawable;
+import javax.media.opengl.GLEventListener;
+
+import com.jogamp.opengl.util.GLDrawableUtil;
+import com.jogamp.opengl.util.awt.AWTGLReadBufferUtil;
+import com.jogamp.opengl.util.texture.TextureIO;
+
+/**
+ * Test synchronous GLAutoDrawable display, swap-buffer and read-pixels
+ * including non-MSAA and MSAA framebuffer.
+ * <p>
+ * See {@link GLReadBuffer00Base} for related bugs and further details.
+ * </p>
+ */
+public abstract class GLReadBuffer00BaseAWT extends GLReadBuffer00Base {
+
+ protected class SnapshotGLELAWT implements GLEventListener {
+ final TextRendererGLEL textRendererGLEL;
+ final AWTGLReadBufferUtil glReadBufferUtil;
+ final boolean skipGLOrientationVerticalFlip;
+ boolean defAutoSwapMode;
+ boolean swapBuffersBeforeRead;
+ int i;
+
+ SnapshotGLELAWT(final TextRendererGLEL textRendererGLEL, final AWTGLReadBufferUtil glReadBufferUtil, final boolean skipGLOrientationVerticalFlip) {
+ this.textRendererGLEL = textRendererGLEL;
+ this.glReadBufferUtil = glReadBufferUtil;
+ this.skipGLOrientationVerticalFlip = skipGLOrientationVerticalFlip;
+ this.defAutoSwapMode = true;
+ this.swapBuffersBeforeRead = false;
+ i = 0;
+ }
+
+ @Override
+ public void init(final GLAutoDrawable drawable) {
+ defAutoSwapMode = drawable.getAutoSwapBufferMode();
+ swapBuffersBeforeRead = GLDrawableUtil.swapBuffersBeforeRead(drawable.getChosenGLCapabilities());
+ drawable.setAutoSwapBufferMode( !swapBuffersBeforeRead );
+ }
+ @Override
+ public void dispose(final GLAutoDrawable drawable) {
+ drawable.setAutoSwapBufferMode( defAutoSwapMode );
+ }
+ @Override
+ public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) { }
+ @Override
+ public void display(final GLAutoDrawable drawable) {
+ snapshot(i++, drawable.getGL(), TextureIO.PNG, null);
+ }
+ public void snapshot(final int sn, final GL gl, final String fileSuffix, final String destPath) {
+ final GLDrawable drawable = gl.getContext().getGLReadDrawable();
+ final String postSNDetail = String.format("awt-usr%03d", textRendererGLEL.userCounter);
+ final String filenameAWT = getSnapshotFilename(sn, postSNDetail,
+ drawable.getChosenGLCapabilities(), drawable.getSurfaceWidth(), drawable.getSurfaceHeight(),
+ glReadBufferUtil.hasAlpha(), fileSuffix, destPath);
+ if( swapBuffersBeforeRead ) {
+ drawable.swapBuffers();
+ // Just to test whether we use the right buffer,
+ // i.e. back-buffer shall no more be required ..
+ gl.glClear(GL.GL_COLOR_BUFFER_BIT);
+ } else {
+ gl.glFinish(); // just make sure rendering finished ..
+ }
+
+ final boolean awtOrientation = !( drawable.isGLOriented() && skipGLOrientationVerticalFlip );
+ System.err.println(Thread.currentThread().getName()+": ** screenshot: awtOrient/v-flip "+awtOrientation+", swapBuffersBeforeRead "+swapBuffersBeforeRead+", "+filenameAWT);
+
+ final BufferedImage image = glReadBufferUtil.readPixelsToBufferedImage(gl, awtOrientation);
+ final File fout = new File(filenameAWT);
+ try {
+ ImageIO.write(image, "png", fout);
+ } catch (final IOException e) {
+ e.printStackTrace();
+ }
+ /**
+ final String filenameJGL = getSnapshotFilename(sn, "jgl",
+ drawable.getChosenGLCapabilities(), drawable.getWidth(), drawable.getHeight(),
+ glReadBufferUtil.hasAlpha(), fileSuffix, destPath);
+ glReadBufferUtil.write(new File(filenameJGL));
+ */
+ }
+ };
+
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/InitConcurrentBaseNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/InitConcurrentBaseNEWT.java
index eb9203b75..6bfe73e95 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/InitConcurrentBaseNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/InitConcurrentBaseNEWT.java
@@ -52,6 +52,10 @@ import com.jogamp.opengl.util.Animator;
* <p>
* Rendering is always lock-free and independent of the EDT.
* </p>
+ * <p>
+ * Each test is decorated w/ {@link GLProfile#shutdown()} to ensure that
+ * implicit {@link GLProfile#initSingleton()} is also being tested.
+ * </p>
*/
public abstract class InitConcurrentBaseNEWT extends UITestCase {
@@ -185,6 +189,7 @@ public abstract class InitConcurrentBaseNEWT extends UITestCase {
}
protected void runJOGLTasks(final int num, final boolean reuse) throws InterruptedException {
+ GLProfile.shutdown();
System.err.println("InitConcurrentBaseNEWT "+num+" threads, reuse display: "+reuse);
final String currentThreadName = Thread.currentThread().getName();
final Object syncDone = new Object();
@@ -222,5 +227,6 @@ public abstract class InitConcurrentBaseNEWT extends UITestCase {
i++;
}
Assert.assertTrue("Threads are still alive after 3s. Alive: "+isAliveDump(threads), isDead(threads));
+ GLProfile.shutdown();
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableFactoryNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableFactoryNEWT.java
index a0a5e8969..327fecd25 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableFactoryNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableFactoryNEWT.java
@@ -34,6 +34,7 @@ import javax.media.opengl.GLCapabilitiesImmutable;
import javax.media.opengl.GLContext;
import javax.media.opengl.GLDrawableFactory;
import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLFBODrawable;
import javax.media.opengl.GLOffscreenAutoDrawable;
import javax.media.opengl.GLProfile;
@@ -71,86 +72,120 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
}
@Test
- public void test01_GL2ES2_Demo1_SingleBuffer_Normal() throws InterruptedException {
+ public void test01a_GL2ES2_Demo1_SingleBuffer_Normal() throws InterruptedException {
final GLProfile glp = GLProfile.getGL2ES2();
final GLCapabilities caps = new GLCapabilities(glp);
caps.setDoubleBuffered(false);
- testGLFBODrawableImpl(caps, new GearsES2(0));
+ testGLFBODrawableImpl(caps, GLFBODrawable.FBOMODE_USE_TEXTURE, new GearsES2(0));
+ }
+ @Test
+ public void test01b_GL2ES2_Demo1_SingleBuffer_NoTex() throws InterruptedException {
+ final GLProfile glp = GLProfile.getGL2ES2();
+ final GLCapabilities caps = new GLCapabilities(glp);
+ caps.setDoubleBuffered(false);
+ testGLFBODrawableImpl(caps, 0, new GearsES2(0));
+ }
+ @Test
+ public void test01c_GL2ES2_Demo1_SingleBuffer_NoTexNoDepth() throws InterruptedException {
+ final GLProfile glp = GLProfile.getGL2ES2();
+ final GLCapabilities caps = new GLCapabilities(glp);
+ caps.setDoubleBuffered(false);
+ caps.setDepthBits(0);
+ testGLFBODrawableImpl(caps, 0, new GearsES2(0));
}
@Test
- public void test02_GL2ES2_Demo1_DoubleBuffer_Normal() throws InterruptedException {
+ public void test02a_GL2ES2_Demo1_DoubleBuffer_Normal() throws InterruptedException {
final GLProfile glp = GLProfile.getGL2ES2();
final GLCapabilities caps = new GLCapabilities(glp);
caps.setDoubleBuffered(true); // default
- testGLFBODrawableImpl(caps, new GearsES2(0));
+ testGLFBODrawableImpl(caps, GLFBODrawable.FBOMODE_USE_TEXTURE, new GearsES2(0));
}
@Test
- public void test03_GL2ES2_Demo2MSAA4() throws InterruptedException {
+ public void test03a_GL2ES2_Demo2MSAA4_Normal() throws InterruptedException {
final GLProfile glp = GLProfile.getGL2ES2();
final GLCapabilities caps = new GLCapabilities(glp);
caps.setSampleBuffers(true);
caps.setNumSamples(4);
- testGLFBODrawableImpl(caps, new MultisampleDemoES2(true));
+ testGLFBODrawableImpl(caps, GLFBODrawable.FBOMODE_USE_TEXTURE, new MultisampleDemoES2(true));
+ }
+ @Test
+ public void test03b_GL2ES2_Demo2MSAA4_NoTex() throws InterruptedException {
+ final GLProfile glp = GLProfile.getGL2ES2();
+ final GLCapabilities caps = new GLCapabilities(glp);
+ caps.setSampleBuffers(true);
+ caps.setNumSamples(4);
+ testGLFBODrawableImpl(caps, 0, new MultisampleDemoES2(true));
+ }
+ @Test
+ public void test03c_GL2ES2_Demo2MSAA4_NoTexNoDepth() throws InterruptedException {
+ final GLProfile glp = GLProfile.getGL2ES2();
+ final GLCapabilities caps = new GLCapabilities(glp);
+ caps.setSampleBuffers(true);
+ caps.setNumSamples(4);
+ caps.setDepthBits(0);
+ testGLFBODrawableImpl(caps, 0, new MultisampleDemoES2(true));
}
@Test
- public void test04_GL2ES2_FBODemoMSAA4() throws InterruptedException {
+ public void test04_GL2ES2_FBODemoMSAA4_Normal() throws InterruptedException {
final GLProfile glp = GLProfile.getGL2ES2();
final FBOMix2DemosES2 demo = new FBOMix2DemosES2(0);
demo.setDoRotation(false);
final GLCapabilities caps = new GLCapabilities(glp);
caps.setSampleBuffers(true);
caps.setNumSamples(4);
- testGLFBODrawableImpl(caps, demo);
+ testGLFBODrawableImpl(caps, GLFBODrawable.FBOMODE_USE_TEXTURE, demo);
}
@Test
- public void test05_EGLES2_Demo0Normal() throws InterruptedException {
+ public void test11_EGLES2_Demo0Normal() throws InterruptedException {
if( GLProfile.isAvailable(GLProfile.GLES2) ) {
final GLProfile glp = GLProfile.get(GLProfile.GLES2);
final GLCapabilities caps = new GLCapabilities(glp);
- testGLFBODrawableImpl(caps, new GearsES2(0));
+ testGLFBODrawableImpl(caps, GLFBODrawable.FBOMODE_USE_TEXTURE, new GearsES2(0));
} else {
System.err.println("EGL ES2 n/a");
}
}
@Test
- public void test06_GL3_Demo0Normal() throws InterruptedException {
- if( GLProfile.isAvailable(GLProfile.GL3) ) {
- final GLProfile glp = GLProfile.get(GLProfile.GL3);
+ public void test13_EGLES2_Demo0MSAA4() throws InterruptedException {
+ if( GLProfile.isAvailable(GLProfile.GLES2) ) {
+ final GLProfile glp = GLProfile.get(GLProfile.GLES2);
final GLCapabilities caps = new GLCapabilities(glp);
- testGLFBODrawableImpl(caps, new GearsES2(0));
+ caps.setSampleBuffers(true);
+ caps.setNumSamples(4);
+ testGLFBODrawableImpl(caps, GLFBODrawable.FBOMODE_USE_TEXTURE, new GearsES2(0));
} else {
- System.err.println("GL3 n/a");
+ System.err.println("EGL ES2 n/a");
}
}
@Test
- public void test07_EGLES2_Demo0MSAA4() throws InterruptedException {
- if( GLProfile.isAvailable(GLProfile.GLES2) ) {
- final GLProfile glp = GLProfile.get(GLProfile.GLES2);
+ public void test21_GL3_Demo0Normal() throws InterruptedException {
+ if( GLProfile.isAvailable(GLProfile.GL3) ) {
+ final GLProfile glp = GLProfile.get(GLProfile.GL3);
final GLCapabilities caps = new GLCapabilities(glp);
- caps.setSampleBuffers(true);
- caps.setNumSamples(4);
- testGLFBODrawableImpl(caps, new GearsES2(0));
+ testGLFBODrawableImpl(caps, GLFBODrawable.FBOMODE_USE_TEXTURE, new GearsES2(0));
} else {
- System.err.println("EGL ES2 n/a");
+ System.err.println("GL3 n/a");
}
}
- void testGLFBODrawableImpl(final GLCapabilities caps, final GLEventListener demo) throws InterruptedException {
+ void testGLFBODrawableImpl(final GLCapabilities caps, final int fboMode, final GLEventListener demo) throws InterruptedException {
caps.setFBO(true);
final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile());
final GLOffscreenAutoDrawable.FBO glad = (GLOffscreenAutoDrawable.FBO)
factory.createOffscreenAutoDrawable(null, caps, null, widthStep*szStep, heightStep*szStep);
Assert.assertNotNull(glad);
+ System.out.println("Requested: "+caps);
System.out.println("Realized GLAD: "+glad);
System.out.println("Realized GLAD: "+glad.getChosenGLCapabilities());
Assert.assertTrue("FBO drawable is initialized before ctx creation", !glad.isInitialized());
+ glad.setFBOMode(fboMode);
glad.display(); // initial display incl. init!
{
@@ -160,6 +195,13 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
}
Assert.assertTrue("FBO drawable is not initialized after ctx creation", glad.isInitialized());
+ final boolean expDepth = caps.getDepthBits() > 0;
+ final boolean reqDepth = glad.getRequestedGLCapabilities().getDepthBits() > 0;
+ final boolean hasDepth = glad.getChosenGLCapabilities().getDepthBits() > 0;
+ System.out.println("Depth: exp "+expDepth+", req "+reqDepth+", has "+hasDepth);
+ Assert.assertEquals("Depth: expected not passed to requested", expDepth, reqDepth);
+ Assert.assertEquals("Depth: requested not passed to chosen", reqDepth, hasDepth);
+
//
// FBO incl. MSAA is fully initialized now
//
@@ -179,20 +221,27 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
Assert.assertTrue("FBO Back is not initialized before ctx creation", fboBack.isInitialized());
if( chosenCaps.getDoubleBuffered() ) {
- Assert.assertTrue("FBO are equal: "+fboFront+" == "+fboBack, !fboFront.equals(fboBack));
+ Assert.assertNotEquals("FBO are equal: "+fboFront+" == "+fboBack, fboFront, fboBack);
Assert.assertNotSame(fboFront, fboBack);
} else {
- Assert.assertTrue("FBO are not equal: "+fboFront+" != "+fboBack, fboFront.equals(fboBack));
+ Assert.assertEquals("FBO are not equal: "+fboFront+" != "+fboBack, fboFront, fboBack);
Assert.assertSame(fboFront, fboBack);
}
- final FBObject.TextureAttachment texAttachA, texAttachB;
+ final FBObject.Colorbuffer color0, color1;
- texAttachA = glad.getTextureBuffer(GL.GL_FRONT);
+ color0 = glad.getColorbuffer(GL.GL_FRONT);
if(0==glad.getNumSamples()) {
- texAttachB = glad.getTextureBuffer(GL.GL_BACK);
+ color1 = glad.getColorbuffer(GL.GL_BACK);
} else {
- texAttachB = null;
+ color1 = null;
+ }
+
+ final boolean expTexture = 0 != ( GLFBODrawable.FBOMODE_USE_TEXTURE & glad.getFBOMode() );
+ System.out.println("Texture: exp "+expTexture+", hasFront "+color0.isTextureAttachment());
+ Assert.assertEquals("Texture: Front", expTexture, color0.isTextureAttachment());
+ if(0==glad.getNumSamples()) {
+ Assert.assertEquals("Texture: Back", expTexture, color1.isTextureAttachment());
}
final FBObject.Colorbuffer colorA, colorB;
@@ -203,19 +252,33 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
colorB = fboBack.getColorbuffer(0);
Assert.assertNotNull(colorB);
- depthA = fboFront.getDepthAttachment();
- Assert.assertNotNull(depthA);
- depthB = fboBack.getDepthAttachment();
- Assert.assertNotNull(depthB);
+ Assert.assertEquals("Texture: Front", expTexture, colorA.isTextureAttachment());
+ if(0==glad.getNumSamples()) {
+ Assert.assertEquals("Texture: Back", expTexture, colorB.isTextureAttachment());
+ } else {
+ Assert.assertEquals("Texture: MSAA Back is Texture", false, colorB.isTextureAttachment());
+ }
+
+ if( hasDepth ) {
+ depthA = fboFront.getDepthAttachment();
+ Assert.assertNotNull(depthA);
+ depthB = fboBack.getDepthAttachment();
+ Assert.assertNotNull(depthB);
+ } else {
+ depthA = null;
+ depthB = null;
+ }
glad.display(); // SWAP_ODD
if( chosenCaps.getDoubleBuffered() ) {
// double buffer or MSAA
- Assert.assertTrue("Color attachments are equal: "+colorB+" == "+colorA, !colorB.equals(colorA));
+ Assert.assertNotEquals("Color attachments are equal: "+colorB+" == "+colorA, colorA, colorB);
Assert.assertNotSame(colorB, colorA);
- Assert.assertTrue("Depth attachments are equal: "+depthB+" == "+depthA, !depthB.equals(depthA));
- Assert.assertNotSame(depthB, depthA);
+ if( hasDepth ) {
+ Assert.assertNotEquals("Depth attachments are equal: "+depthB+" == "+depthA, depthA, depthB);
+ Assert.assertNotSame(depthB, depthA);
+ }
} else {
// single buffer
Assert.assertEquals(colorA, colorB);
@@ -224,40 +287,40 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
Assert.assertSame(depthA, depthB);
}
- Assert.assertEquals(texAttachA, colorA);
- Assert.assertSame(texAttachA, colorA);
+ Assert.assertEquals(color0, colorA);
+ Assert.assertSame(color0, colorA);
if(0==glad.getNumSamples()) {
- Assert.assertEquals(texAttachB, colorB);
- Assert.assertSame(texAttachB, colorB);
+ Assert.assertEquals(color1, colorB);
+ Assert.assertSame(color1, colorB);
}
if( chosenCaps.getNumSamples() > 0 ) {
// MSAA
final FBObject _fboFront = glad.getFBObject(GL.GL_FRONT);
final FBObject _fboBack = glad.getFBObject(GL.GL_BACK);
- Assert.assertTrue("FBO are not equal: "+fboFront+" != "+_fboFront, fboFront.equals(_fboFront));
+ Assert.assertEquals("FBO are not equal: "+fboFront+" != "+_fboFront, fboFront, _fboFront);
Assert.assertSame(fboFront, _fboFront);
- Assert.assertTrue("FBO are not equal: "+fboBack+" != "+_fboBack, fboBack.equals(_fboBack));
+ Assert.assertEquals("FBO are not equal: "+fboBack+" != "+_fboBack, fboBack, _fboBack);
Assert.assertSame(fboBack, _fboBack);
} else if( chosenCaps.getDoubleBuffered() ) {
// real double buffer
final FBObject _fboFront = glad.getFBObject(GL.GL_FRONT);
final FBObject _fboBack = glad.getFBObject(GL.GL_BACK);
- Assert.assertTrue("FBO are not equal: "+fboBack+" != "+_fboFront, fboBack.equals(_fboFront));
+ Assert.assertEquals("FBO are not equal: "+fboBack+" != "+_fboFront, fboBack, _fboFront);
Assert.assertSame(fboBack, _fboFront);
- Assert.assertTrue("FBO are not equal: "+fboFront+" != "+_fboBack, fboFront.equals(_fboBack));
+ Assert.assertEquals("FBO are not equal: "+fboFront+" != "+_fboBack, fboFront, _fboBack);
Assert.assertSame(fboFront, _fboBack);
} else {
// single buffer
final FBObject _fboFront = glad.getFBObject(GL.GL_FRONT);
final FBObject _fboBack = glad.getFBObject(GL.GL_BACK);
- Assert.assertTrue("FBO are not equal: "+fboFront+" != "+_fboFront, fboFront.equals(_fboFront));
+ Assert.assertEquals("FBO are not equal: "+fboFront+" != "+_fboFront, fboFront, _fboFront);
Assert.assertSame(fboFront, _fboFront);
- Assert.assertTrue("FBO are not equal: "+fboBack+" != "+_fboFront, fboBack.equals(_fboFront));
+ Assert.assertEquals("FBO are not equal: "+fboBack+" != "+_fboFront, fboBack, _fboFront);
Assert.assertSame(fboBack, _fboFront);
- Assert.assertTrue("FBO are not equal: "+fboBack+" != "+_fboBack, fboBack.equals(_fboBack));
+ Assert.assertEquals("FBO are not equal: "+fboBack+" != "+_fboBack, fboBack, _fboBack);
Assert.assertSame(fboBack, _fboBack);
- Assert.assertTrue("FBO are not equal: "+fboFront+" != "+_fboBack, fboFront.equals(_fboBack));
+ Assert.assertEquals("FBO are not equal: "+fboFront+" != "+_fboBack, fboFront, _fboBack);
Assert.assertSame(fboFront, _fboBack);
}
@@ -301,12 +364,16 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
FBObject.RenderAttachment _depth = _fboFront.getDepthAttachment();
System.err.println("Resize1.oldDepth "+depthA);
System.err.println("Resize1.newDepth "+_depth);
- Assert.assertNotNull(_depth);
+ if( hasDepth ) {
+ Assert.assertNotNull(_depth);
+ }
Assert.assertEquals(depthA, _depth);
Assert.assertSame(depthA, _depth);
_depth = _fboBack.getDepthAttachment();
- Assert.assertNotNull(_depth);
+ if( hasDepth ) {
+ Assert.assertNotNull(_depth);
+ }
Assert.assertEquals(depthB, _depth);
Assert.assertSame(depthB, _depth);
@@ -348,12 +415,16 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
Assert.assertSame(colorB, _color);
FBObject.RenderAttachment _depth = fboBack.getDepthAttachment();
- Assert.assertNotNull(_depth); // MSAA back w/ depth
+ if( hasDepth ) {
+ Assert.assertNotNull(_depth); // MSAA back w/ depth
+ }
Assert.assertEquals(depthB, _depth);
Assert.assertSame(depthB, _depth);
_depth = fboFront.getDepthAttachment();
- Assert.assertNotNull(_depth);
+ if( hasDepth ) {
+ Assert.assertNotNull(_depth);
+ }
Assert.assertEquals(depthA, _depth);
Assert.assertSame(depthA, _depth);
@@ -364,7 +435,10 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
}
// 6 + 7 (samples + display)
- glad.setNumSamples(glad.getGL(), chosenCaps.getNumSamples() > 0 ? 0 : 4); // triggers repaint
+ final int oldSampleCount = chosenCaps.getNumSamples();
+ final int newSampleCount = oldSampleCount > 0 ? 0 : 4;
+ System.out.println("Resize3.sampleCount: "+oldSampleCount+" -> "+newSampleCount);
+ glad.setNumSamples(glad.getGL(), newSampleCount); // triggers repaint
snapshotGLEventListener.setMakeSnapshot();
glad.display(); // actual screenshot
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java
index ba57c6dbd..977ecbf03 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java
@@ -73,7 +73,7 @@ public class TestFBOMRTNEWT01 extends UITestCase {
System.err.println("Test requires GL2/GL3 profile.");
return;
}
- final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(
+ final NEWTGLContext.WindowContext winctx = NEWTGLContext.createWindow(
new GLCapabilities(GLProfile.getGL2GL3()), width/step, height/step, true);
final GLDrawable drawable = winctx.context.getGLDrawable();
final GL2GL3 gl = winctx.context.getGL().getGL2GL3();
@@ -167,7 +167,7 @@ public class TestFBOMRTNEWT01 extends UITestCase {
// FBO w/ 2 texture2D color buffers
final FBObject fbo_mrt = new FBObject();
- fbo_mrt.reset(gl, drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
+ fbo_mrt.init(gl, drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), 0);
final TextureAttachment texA0 = fbo_mrt.attachTexture2D(gl, texA0Point, true, GL.GL_NEAREST, GL.GL_NEAREST, GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE);
final TextureAttachment texA1;
if(fbo_mrt.getMaxColorAttachments() > 1) {
@@ -176,7 +176,7 @@ public class TestFBOMRTNEWT01 extends UITestCase {
texA1 = null;
System.err.println("FBO supports only one attachment, no MRT available!");
}
- fbo_mrt.attachRenderbuffer(gl, Type.DEPTH, 24);
+ fbo_mrt.attachRenderbuffer(gl, Type.DEPTH, FBObject.CHOSEN_BITS);
Assert.assertTrue( fbo_mrt.isStatusValid() ) ;
fbo_mrt.unbind(gl);
@@ -257,7 +257,7 @@ public class TestFBOMRTNEWT01 extends UITestCase {
final int w = width/step * j;
final int h = height/step * j;
System.err.println("resize: "+step_i+" -> "+j+" - "+w+"x"+h);
- fbo_mrt.reset(gl, w, h);
+ fbo_mrt.reset(gl, w, h, 0);
winctx.window.setSize(w, h);
step_i = j;
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMix2DemosES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMix2DemosES2NEWT.java
index f8feefdcf..5eebf9cdd 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMix2DemosES2NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMix2DemosES2NEWT.java
@@ -62,14 +62,14 @@ import org.junit.runners.MethodSorters;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestFBOMix2DemosES2NEWT extends UITestCase {
- static long duration = 500; // ms
+ static long duration = 1000; // ms
static int swapInterval = 1;
static boolean showFPS = false;
static boolean forceES2 = false;
static boolean doRotate = true;
static boolean demo0Only = false;
static int globalNumSamples = 0;
- static boolean mainRun = false;
+ static boolean manual = false;
@AfterClass
public static void releaseClass() {
@@ -81,7 +81,7 @@ public class TestFBOMix2DemosES2NEWT extends UITestCase {
final GLWindow glWindow = GLWindow.create(caps);
Assert.assertNotNull(glWindow);
glWindow.setTitle("Gears NEWT Test (translucent "+!caps.isBackgroundOpaque()+"), swapInterval "+swapInterval);
- if(mainRun) {
+ if(manual) {
glWindow.setSize(512, 512);
} else {
glWindow.setSize(128, 128);
@@ -100,7 +100,7 @@ public class TestFBOMix2DemosES2NEWT extends UITestCase {
}
public void dispose(final GLAutoDrawable drawable) {}
public void display(final GLAutoDrawable drawable) {
- if(mainRun) return;
+ if(manual) return;
final int dw = drawable.getSurfaceWidth();
final int dh = drawable.getSurfaceHeight();
@@ -112,18 +112,24 @@ public class TestFBOMix2DemosES2NEWT extends UITestCase {
snapshot(i++, "msaa"+demo.getMSAA(), drawable.getGL(), screenshot, TextureIO.PNG, null);
}
if( 3 == c ) {
+ demo.setMSAA(4);
+ } else if( 6 == c ) {
new Thread() {
@Override
public void run() {
- demo.setMSAA(4);
+ glWindow.setSize(dw+64, dh+64);
} }.start();
- } else if( 6 == c ) {
+ } else if( 9 == c ) {
+ demo.setMSAA(8);
+ } else if( 12 == c ) {
+ demo.setMSAA(0);
+ } else if( 15 == c ) {
new Thread() {
@Override
public void run() {
- demo.setMSAA(8);
+ glWindow.setSize(dw+128, dh+128);
} }.start();
- } else if(9 == c) {
+ } else if( 18 == c ) {
c=0;
new Thread() {
@Override
@@ -203,8 +209,8 @@ public class TestFBOMix2DemosES2NEWT extends UITestCase {
}
@Test
- public void test01_Main() throws InterruptedException {
- if( mainRun ) {
+ public void test00_Manual() throws InterruptedException {
+ if( manual ) {
final GLCapabilities caps = new GLCapabilities(forceES2 ? GLProfile.get(GLProfile.GLES2) : GLProfile.getGL2ES2());
caps.setAlphaBits(1);
runTestGL(caps, globalNumSamples);
@@ -212,17 +218,25 @@ public class TestFBOMix2DemosES2NEWT extends UITestCase {
}
@Test
- public void test01() throws InterruptedException {
- if( mainRun ) return ;
+ public void test01_startMSAA0() throws InterruptedException {
+ if( manual ) return ;
final GLCapabilities caps = new GLCapabilities(forceES2 ? GLProfile.get(GLProfile.GLES2) : GLProfile.getGL2ES2());
caps.setAlphaBits(1);
runTestGL(caps, 0);
}
+ @Test
+ public void test02_startMSAA4() throws InterruptedException {
+ if( manual ) return ;
+ final GLCapabilities caps = new GLCapabilities(forceES2 ? GLProfile.get(GLProfile.GLES2) : GLProfile.getGL2ES2());
+ caps.setAlphaBits(1);
+ runTestGL(caps, 4);
+ }
+
public static void main(final String args[]) throws IOException {
boolean waitForKey = false;
- mainRun = true;
+ manual = false;
for(int i=0; i<args.length; i++) {
if(args[i].equals("-time")) {
@@ -244,13 +258,14 @@ public class TestFBOMix2DemosES2NEWT extends UITestCase {
demo0Only = true;
} else if(args[i].equals("-wait")) {
waitForKey = true;
- } else if(args[i].equals("-nomain")) {
- mainRun = false;
+ } else if(args[i].equals("-manual")) {
+ manual = true;
}
}
System.err.println("swapInterval "+swapInterval);
System.err.println("forceES2 "+forceES2);
+ System.err.println("manual "+manual);
if(waitForKey) {
final BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java
index e1e1c3fbc..13feb2372 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java
@@ -147,7 +147,7 @@ public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase {
fbod1.getNativeSurface().addSurfaceUpdatedListener(new SurfaceUpdatedListener() {
@Override
public void surfaceUpdated(final Object updater, final NativeSurface ns, final long when) {
- mixerDemo.setTexID0(fbod1.getTextureBuffer(GL.GL_FRONT).getName());
+ mixerDemo.setTexID0(fbod1.getColorbuffer(GL.GL_FRONT).getName());
} });
fbod1.display(); // init
System.err.println("FBOD1 "+fbod1);
@@ -163,15 +163,15 @@ public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase {
fbod2.getNativeSurface().addSurfaceUpdatedListener(new SurfaceUpdatedListener() {
@Override
public void surfaceUpdated(final Object updater, final NativeSurface ns, final long when) {
- mixerDemo.setTexID1(fbod2.getTextureBuffer(GL.GL_FRONT).getName());
+ mixerDemo.setTexID1(fbod2.getColorbuffer(GL.GL_FRONT).getName());
} });
fbod2.display(); // init
System.err.println("FBOD2 "+fbod2);
Assert.assertTrue(fbod2.isInitialized());
// preinit texIDs
- mixerDemo.setTexID0(fbod1.getTextureBuffer(GL.GL_FRONT).getName());
- mixerDemo.setTexID1(fbod2.getTextureBuffer(GL.GL_FRONT).getName());
+ mixerDemo.setTexID0(fbod1.getColorbuffer(GL.GL_FRONT).getName());
+ mixerDemo.setTexID1(fbod2.getColorbuffer(GL.GL_FRONT).getName());
glWindow.addGLEventListener(mixerDemo);
glWindow.addGLEventListener(new GLEventListener() {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOnThreadSharedContext1DemoES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOnThreadSharedContext1DemoES2NEWT.java
index c9c156218..4ed762a4e 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOnThreadSharedContext1DemoES2NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOnThreadSharedContext1DemoES2NEWT.java
@@ -144,14 +144,14 @@ public class TestFBOOnThreadSharedContext1DemoES2NEWT extends UITestCase {
fbod1.getNativeSurface().addSurfaceUpdatedListener(new SurfaceUpdatedListener() {
@Override
public void surfaceUpdated(final Object updater, final NativeSurface ns, final long when) {
- mixerDemo.setTexID0(fbod1.getTextureBuffer(GL.GL_FRONT).getName());
+ mixerDemo.setTexID0(fbod1.getColorbuffer(GL.GL_FRONT).getName());
} });
fbod1.display(); // init
System.err.println("FBOD1 "+fbod1);
Assert.assertTrue(fbod1.isInitialized());
// preinit texIDs
- mixerDemo.setTexID0(fbod1.getTextureBuffer(GL.GL_FRONT).getName());
+ mixerDemo.setTexID0(fbod1.getColorbuffer(GL.GL_FRONT).getName());
glWindow.addWindowListener(new WindowAdapter() {
@Override
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLException01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLException01NEWT.java
new file mode 100644
index 000000000..cdbe3af94
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLException01NEWT.java
@@ -0,0 +1,412 @@
+/**
+ * Copyright 2011 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.opengl.test.junit.jogl.acore;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+
+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.util.Animator;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+
+import javax.media.opengl.GLAnimatorControl;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLProfile;
+import javax.media.opengl.GLRunnable;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.FixMethodOrder;
+import org.junit.runners.MethodSorters;
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestGLException01NEWT extends UITestCase {
+ static GLProfile glp;
+ static int width, height;
+
+ @SuppressWarnings("serial")
+ static class AnimException extends RuntimeException {
+ final Thread thread;
+ final GLAnimatorControl animator;
+ final GLAutoDrawable drawable;
+ public AnimException(final Thread thread, final GLAnimatorControl animator, final GLAutoDrawable drawable, final Throwable cause) {
+ super(cause);
+ this.thread = thread;
+ this.animator = animator;
+ this.drawable = drawable;
+ }
+ }
+
+ @BeforeClass
+ public static void initClass() {
+ glp = GLProfile.getGL2ES2();
+ Assert.assertNotNull(glp);
+ width = 512;
+ height = 512;
+ }
+
+ public static void dumpThrowable(final Throwable t) {
+ System.err.println("User caught exception "+t.getClass().getSimpleName()+": "+t.getMessage()+" on thread "+Thread.currentThread().getName());
+ t.printStackTrace();
+ }
+
+ protected void runTestGL(final GLCapabilities caps, final boolean onThread,
+ final boolean throwInInit, final boolean throwInDisplay,
+ final boolean throwInReshape, final boolean throwInInvoke,
+ final boolean throwInDispose) throws InterruptedException {
+ final GLWindow glWindow = GLWindow.create(caps);
+ Assert.assertNotNull(glWindow);
+ glWindow.setTitle(getTestMethodName());
+ final GearsES2 demo1 = new GearsES2();
+ demo1.setVerbose(false);
+ glWindow.addGLEventListener(demo1);
+ final AtomicInteger cleanInitCount = new AtomicInteger();
+ final AtomicInteger cleanDisposeCount = new AtomicInteger();
+ final AtomicInteger cleanDisplayCount = new AtomicInteger();
+ final AtomicInteger cleanReshapeCount = new AtomicInteger();
+ final AtomicInteger cleanInvokeCount = new AtomicInteger();
+ final AtomicInteger allInitCount = new AtomicInteger();
+ final AtomicInteger allDisposeCount = new AtomicInteger();
+ final AtomicInteger allDisplayCount = new AtomicInteger();
+ final AtomicInteger allReshapeCount = new AtomicInteger();
+ final AtomicInteger allInvokeCount = new AtomicInteger();
+ final AtomicInteger exceptionSent = new AtomicInteger();
+
+ glWindow.addGLEventListener(new GLEventListener() {
+ @Override
+ public void init(final GLAutoDrawable drawable) {
+ if( throwInInit ) {
+ exceptionSent.incrementAndGet();
+ throw new RuntimeException("<Injected GLEventListener exception in init: #"+exceptionSent.get()+" on thread "+Thread.currentThread().getName()+">");
+ }
+ }
+ @Override
+ public void dispose(final GLAutoDrawable drawable) {
+ if( throwInDispose ) {
+ exceptionSent.incrementAndGet();
+ throw new RuntimeException("<Injected GLEventListener exception in dispose: #"+exceptionSent.get()+" on thread "+Thread.currentThread().getName()+">");
+ }
+ }
+ @Override
+ public void display(final GLAutoDrawable drawable) {
+ if( throwInDisplay ) {
+ exceptionSent.incrementAndGet();
+ throw new RuntimeException("<Injected GLEventListener exception in display: #"+exceptionSent.get()+" on thread "+Thread.currentThread().getName()+">");
+ }
+ }
+ @Override
+ public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {
+ if( throwInReshape ) {
+ exceptionSent.incrementAndGet();
+ throw new RuntimeException("<Injected GLEventListener exception in reshape: #"+exceptionSent.get()+" on thread "+Thread.currentThread().getName()+">");
+ }
+ }
+ });
+ final GLRunnable glRunnableInject = new GLRunnable() {
+ @Override
+ public boolean run(final GLAutoDrawable drawable) {
+ if( throwInInvoke ) {
+ exceptionSent.incrementAndGet();
+ throw new RuntimeException("<Injected GLEventListener exception in invoke: #"+exceptionSent.get()+" on thread "+Thread.currentThread().getName()+">");
+ }
+ return true;
+ }
+ };
+ final GLRunnable glRunnableCount = new GLRunnable() {
+ @Override
+ public boolean run(final GLAutoDrawable drawable) {
+ if( 0 == exceptionSent.get() ) {
+ cleanInvokeCount.incrementAndGet();
+ }
+ allInvokeCount.incrementAndGet();
+ return true;
+ }
+ };
+
+ glWindow.addGLEventListener(new GLEventListener() {
+ @Override
+ public void init(final GLAutoDrawable drawable) {
+ if( 0 == exceptionSent.get() ) {
+ cleanInitCount.incrementAndGet();
+ }
+ allInitCount.incrementAndGet();
+ }
+ @Override
+ public void dispose(final GLAutoDrawable drawable) {
+ if( 0 == exceptionSent.get() ) {
+ cleanDisposeCount.incrementAndGet();
+ }
+ allDisposeCount.incrementAndGet();
+ }
+ @Override
+ public void display(final GLAutoDrawable drawable) {
+ if( 0 == exceptionSent.get() ) {
+ cleanDisplayCount.incrementAndGet();
+ }
+ allDisplayCount.incrementAndGet();
+ }
+ @Override
+ public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {
+ if( 0 == exceptionSent.get() ) {
+ cleanReshapeCount.incrementAndGet();
+ }
+ allReshapeCount.incrementAndGet();
+ }
+ });
+
+ RuntimeException exceptionAtInitReshapeDisplay = null;
+ RuntimeException exceptionAtInvoke = null;
+ RuntimeException exceptionAtDispose = null;
+ final List<AnimException> exceptionsAtGLAnimatorControl = new ArrayList<AnimException>();
+ final GLAnimatorControl.UncaughtExceptionHandler uncaughtExceptionHandler;
+
+ final Animator animator;
+ if( onThread ) {
+ animator = null;
+ uncaughtExceptionHandler = null;
+ } else {
+ animator = new Animator(glWindow);
+ uncaughtExceptionHandler = new GLAnimatorControl.UncaughtExceptionHandler() {
+ @Override
+ public void uncaughtException(final GLAnimatorControl animator, final GLAutoDrawable drawable, final Throwable cause) {
+ final AnimException ae = new AnimException(animator.getThread(), animator, drawable, cause);
+ exceptionsAtGLAnimatorControl.add(ae);
+ dumpThrowable(ae);
+ } };
+ animator.setUncaughtExceptionHandler(uncaughtExceptionHandler);
+ }
+
+ glWindow.setSize(width, height);
+
+ if( !onThread ) {
+ animator.setUpdateFPSFrames(1, null);
+ animator.start();
+ }
+ try {
+ glWindow.setVisible(true);
+ } catch (final RuntimeException re) {
+ exceptionAtInitReshapeDisplay = re;
+ dumpThrowable(re);
+ }
+
+ try {
+ glWindow.invoke(true, glRunnableInject);
+ glWindow.invoke(true, glRunnableCount);
+ } catch (final RuntimeException re) {
+ exceptionAtInvoke = re;
+ dumpThrowable(re);
+ }
+
+ final long t0 = System.currentTimeMillis();
+ long t1 = t0;
+ while(0 == exceptionSent.get() && ( onThread || animator.isAnimating() ) && t1-t0<duration ) {
+ if( onThread ) {
+ try {
+ glWindow.display();
+ } catch (final RuntimeException re) {
+ exceptionAtInitReshapeDisplay = re;
+ dumpThrowable(re);
+ }
+ }
+ Thread.sleep(100);
+ t1 = System.currentTimeMillis();
+ }
+
+ if( !onThread ) {
+ animator.stop();
+ }
+ try {
+ glWindow.destroy();
+ } catch (final RuntimeException re) {
+ exceptionAtDispose = re;
+ dumpThrowable(re);
+ }
+
+ final boolean onAnimThread = !onThread && !throwInDispose; /** dispose happens on [AWT|NEWT] EDT, not on animator thread! */
+
+ System.err.println("This-Thread : "+onThread);
+ System.err.println("Anim-Thread : "+onAnimThread);
+ System.err.println("ExceptionSent : "+exceptionSent.get());
+ System.err.println("Exception @ Init/Reshape/Display: "+(null != exceptionAtInitReshapeDisplay));
+ System.err.println("Exception @ Invoke : "+(null != exceptionAtInvoke));
+ System.err.println("Exception @ Dispose : "+(null != exceptionAtDispose));
+ System.err.println("Exception @ GLAnimatorControl : "+exceptionsAtGLAnimatorControl.size());
+ System.err.println("Init Count : "+cleanInitCount.get()+" / "+allInitCount.get());
+ System.err.println("Reshape Count : "+cleanReshapeCount.get()+" / "+allReshapeCount.get());
+ System.err.println("Display Count : "+cleanDisplayCount.get()+" / "+allDisplayCount.get());
+ System.err.println("Invoke Count : "+cleanInvokeCount.get()+" / "+allInvokeCount.get());
+ System.err.println("Dispose Count : "+cleanDisposeCount.get()+" / "+allDisposeCount.get());
+
+ if( throwInInit || throwInReshape || throwInDisplay || throwInDispose || throwInInvoke ) {
+ Assert.assertTrue("Not one exception sent, but "+exceptionSent.get(), 0 < exceptionSent.get());
+ if( onAnimThread ) {
+ Assert.assertEquals("No exception forwarded from init to animator-handler", 1, exceptionsAtGLAnimatorControl.size());
+ Assert.assertNull("Exception forwarded from init, on-thread", exceptionAtInitReshapeDisplay);
+ }
+ if( throwInInit ) {
+ if( !onAnimThread ) {
+ Assert.assertNotNull("No exception forwarded from init, on-thread", exceptionAtInitReshapeDisplay);
+ Assert.assertEquals("Exception forwarded from init to animator-handler", 0, exceptionsAtGLAnimatorControl.size());
+ }
+ Assert.assertEquals("Init Count", 0, cleanInitCount.get());
+ Assert.assertEquals("Reshape Count", 0, cleanReshapeCount.get());
+ Assert.assertEquals("Display Count", 0, cleanDisplayCount.get());
+ Assert.assertEquals("Invoke Count", 0, cleanInvokeCount.get());
+ Assert.assertEquals("Dispose Count", 0, cleanDisposeCount.get());
+ } else if( throwInReshape ) {
+ if( !onAnimThread ) {
+ Assert.assertNotNull("No exception forwarded from reshape, on-thread", exceptionAtInitReshapeDisplay);
+ Assert.assertEquals("Exception forwarded from init to animator-handler", 0, exceptionsAtGLAnimatorControl.size());
+ }
+ Assert.assertEquals("Init Count", 1, cleanInitCount.get());
+ Assert.assertEquals("Reshape Count", 0, cleanReshapeCount.get());
+ Assert.assertEquals("Display Count", 0, cleanDisplayCount.get());
+ Assert.assertEquals("Invoke Count", 0, cleanInvokeCount.get());
+ Assert.assertEquals("Dispose Count", 0, cleanDisposeCount.get());
+ } else if( throwInDisplay ) {
+ if( !onAnimThread ) {
+ Assert.assertNotNull("No exception forwarded from display, on-thread", exceptionAtInitReshapeDisplay);
+ Assert.assertEquals("Exception forwarded from init to animator-handler", 0, exceptionsAtGLAnimatorControl.size());
+ }
+ Assert.assertEquals("Init Count", 1, cleanInitCount.get());
+ Assert.assertEquals("Reshape Count", 1, cleanReshapeCount.get());
+ Assert.assertEquals("Display Count", 0, cleanDisplayCount.get());
+ Assert.assertEquals("Invoke Count", 0, cleanInvokeCount.get());
+ Assert.assertEquals("Dispose Count", 0, cleanDisposeCount.get());
+ } else if( throwInInvoke ) {
+ if( !onAnimThread ) {
+ Assert.assertNotNull("No exception forwarded from invoke, on-thread", exceptionAtInvoke);
+ Assert.assertEquals("Exception forwarded from init to animator-handler", 0, exceptionsAtGLAnimatorControl.size());
+ }
+ Assert.assertEquals("Init Count", 1, cleanInitCount.get());
+ Assert.assertEquals("Reshape Count", 1, cleanReshapeCount.get());
+ Assert.assertTrue ("Display count not greater-equal 1, but "+cleanDisplayCount.get(), 1 <= cleanDisplayCount.get());
+ Assert.assertEquals("Invoke Count", 0, cleanInvokeCount.get());
+ Assert.assertEquals("Dispose Count", 0, cleanDisposeCount.get());
+ } else if( throwInDispose ) {
+ if( !onAnimThread ) {
+ Assert.assertNotNull("No exception forwarded from dispose, on-thread", exceptionAtDispose);
+ Assert.assertEquals("Exception forwarded from init to animator-handler", 0, exceptionsAtGLAnimatorControl.size());
+ }
+ Assert.assertEquals("Init Count", 1, cleanInitCount.get());
+ Assert.assertEquals("Reshape Count", 1, cleanReshapeCount.get());
+ Assert.assertTrue ("Display count not greater-equal 1, but "+cleanDisplayCount.get(), 1 <= cleanDisplayCount.get());
+ Assert.assertEquals("Invoke Count", 1, cleanInvokeCount.get());
+ Assert.assertEquals("Dispose Count", 0, cleanDisposeCount.get());
+ }
+ }
+ }
+
+ @Test
+ public void test01OnThreadAtInit() throws InterruptedException {
+ final GLCapabilities caps = new GLCapabilities(glp);
+ caps.setBackgroundOpaque(true); // default
+ runTestGL(caps, true /* onThread */, true /* init */, false /* display */, false /* reshape */, false /* invoke */, false /* dispose */);
+ }
+ @Test
+ public void test02OnThreadAtReshape() throws InterruptedException {
+ final GLCapabilities caps = new GLCapabilities(glp);
+ caps.setBackgroundOpaque(true); // default
+ runTestGL(caps, true /* onThread */, false /* init */, false /* display */, true /* reshape */, false /* invoke */, false /* dispose */);
+ }
+ @Test
+ public void test03OnThreadAtDisplay() throws InterruptedException {
+ final GLCapabilities caps = new GLCapabilities(glp);
+ caps.setBackgroundOpaque(true); // default
+ runTestGL(caps, true /* onThread */, false /* init */, true /* display */, false /* reshape */, false /* invoke */, false /* dispose */);
+ }
+ @Test
+ public void test04OnThreadAtInvoke() throws InterruptedException {
+ final GLCapabilities caps = new GLCapabilities(glp);
+ caps.setBackgroundOpaque(true); // default
+ runTestGL(caps, true /* onThread */, false /* init */, true /* display */, false /* reshape */, true /* invoke */, false /* dispose */);
+ }
+ @Test
+ public void test05OnThreadAtDispose() throws InterruptedException {
+ final GLCapabilities caps = new GLCapabilities(glp);
+ caps.setBackgroundOpaque(true); // default
+ runTestGL(caps, true /* onThread */, false /* init */, false /* display */, false /* reshape */, false /* invoke */, true /* dispose */);
+ }
+
+ @Test
+ public void test11OffThreadAtInit() throws InterruptedException {
+ final GLCapabilities caps = new GLCapabilities(glp);
+ caps.setBackgroundOpaque(true); // default
+ runTestGL(caps, false /* onThread */, true /* init */, false /* display */, false /* reshape */, false /* invoke */, false /* dispose */);
+ }
+ @Test
+ public void test12OffThreadAtReshape() throws InterruptedException {
+ final GLCapabilities caps = new GLCapabilities(glp);
+ caps.setBackgroundOpaque(true); // default
+ runTestGL(caps, false /* onThread */, false /* init */, false /* display */, true /* reshape */, false /* invoke */, false /* dispose */);
+ }
+ @Test
+ public void test13OffThreadAtDisplay() throws InterruptedException {
+ final GLCapabilities caps = new GLCapabilities(glp);
+ caps.setBackgroundOpaque(true); // default
+ runTestGL(caps, false /* onThread */, false /* init */, true /* display */, false /* reshape */, false /* invoke */, false /* dispose */);
+ }
+ @Test
+ public void test14OffThreadAtInvoke() throws InterruptedException {
+ final GLCapabilities caps = new GLCapabilities(glp);
+ caps.setBackgroundOpaque(true); // default
+ runTestGL(caps, false /* onThread */, false /* init */, true /* display */, false /* reshape */, true /* invoke */, false /* dispose */);
+ }
+ @Test
+ public void test15OffThreadAtDispose() throws InterruptedException {
+ final GLCapabilities caps = new GLCapabilities(glp);
+ caps.setBackgroundOpaque(true); // default
+ runTestGL(caps, false /* onThread */, false /* init */, false /* display */, false /* reshape */, false /* invoke */, true /* dispose */);
+ }
+
+ static long duration = 500; // ms
+
+ public static void main(final String args[]) {
+ boolean waitForKey = false;
+
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ duration = MiscUtils.atol(args[i], duration);
+ } else if(args[i].equals("-wait")) {
+ waitForKey = true;
+ }
+ }
+ if( waitForKey ) {
+ UITestCase.waitForKey("main");
+ }
+ org.junit.runner.JUnitCore.main(TestGLException01NEWT.class.getName());
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLOffscreenAutoDrawableBug1044AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLOffscreenAutoDrawableBug1044AWT.java
new file mode 100644
index 000000000..18ac7abc2
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLOffscreenAutoDrawableBug1044AWT.java
@@ -0,0 +1,106 @@
+/**
+ * Copyright 2014 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.opengl.test.junit.jogl.acore;
+
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+
+import javax.imageio.ImageIO;
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLDrawable;
+import javax.media.opengl.GLDrawableFactory;
+import javax.media.opengl.GLProfile;
+import javax.media.opengl.fixedfunc.GLLightingFunc;
+
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.GLReadBufferUtil;
+import com.jogamp.opengl.util.awt.AWTGLReadBufferUtil;
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestGLOffscreenAutoDrawableBug1044AWT extends UITestCase {
+
+ @Test
+ public void test01GLOffscreenDrawable() throws InterruptedException {
+ final GLReadBufferUtil readBufferUtilRGB888 = new GLReadBufferUtil(false, false);
+ final GLReadBufferUtil readBufferUtilRGBA8888 = new GLReadBufferUtil(true, false);
+ final GLDrawableFactory fac = GLDrawableFactory.getFactory(GLProfile.getDefault());
+ final GLCapabilities glCap = new GLCapabilities(GLProfile.getMaxFixedFunc(true));
+ // Without line below, there is an error on Windows.
+ glCap.setDoubleBuffered(false);
+ //makes a new buffer 100x100
+ final GLDrawable glad = fac.createOffscreenDrawable(null, glCap, null, 100, 100);
+ glad.setRealized(true);
+ final GLContext context = glad.createContext(null);
+ context.makeCurrent();
+
+ System.err.println("Chosen: "+glad.getChosenGLCapabilities());
+
+ final GL2 gl2 = context.getGL().getGL2();
+ gl2.glViewport(0, 0, 100, 100);
+
+ gl2.glShadeModel(GLLightingFunc.GL_SMOOTH);
+ gl2.glClearColor(1.0f, 0.80f, 0.80f, 1); // This Will Clear The Background Color
+ gl2.glClearDepth(1.0); // Enables Clearing Of The Depth Buffer
+ gl2.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
+ gl2.glLoadIdentity(); // Reset The Projection Matrix
+
+ final AWTGLReadBufferUtil agb = new AWTGLReadBufferUtil(glad.getGLProfile(), true);
+ final BufferedImage image = agb.readPixelsToBufferedImage(context.getGL(), true);
+ try {
+ ImageIO.write(image, "PNG", new File(getSimpleTestName(".")+"-AWTImageIO.png"));
+ } catch (final IOException e) {
+ e.printStackTrace();
+ }
+
+ if(readBufferUtilRGB888.readPixels(gl2, false)) {
+ readBufferUtilRGB888.write(new File(getSimpleTestName(".")+"-PNGJ-rgb_.png"));
+ }
+ readBufferUtilRGB888.dispose(gl2);
+ if(readBufferUtilRGBA8888.readPixels(gl2, false)) {
+ readBufferUtilRGBA8888.write(new File(getSimpleTestName(".")+"-PNGJ-rgba.png"));
+ }
+ readBufferUtilRGBA8888.dispose(gl2);
+
+ context.destroy();
+ glad.setRealized(false);
+ System.out.println("Done!");
+ }
+
+ public static void main(final String[] args) {
+ org.junit.runner.JUnitCore.main(TestGLOffscreenAutoDrawableBug1044AWT.class.getName());
+ }
+}
+
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile00NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile00NEWT.java
index 5861d4233..69ddb7771 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile00NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile00NEWT.java
@@ -30,6 +30,7 @@ package com.jogamp.opengl.test.junit.jogl.acore;
import java.io.IOException;
+import org.junit.Assert;
import org.junit.Test;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
@@ -44,8 +45,27 @@ import com.jogamp.opengl.test.junit.util.UITestCase;
public class TestGLProfile00NEWT extends UITestCase {
@Test
- public void testInitSingleton() throws InterruptedException {
+ public void test01InternedString() {
+ final String s1 = "GL2";
+ final String s2 = "GL2";
+ Assert.assertEquals(s1, s2);
+ Assert.assertTrue("s1-ref != s2-ref", s1 == s2);
+ Assert.assertTrue("s1-ref != 'GL2'-ref", s1 == "GL2");
+
+ Assert.assertEquals("GL2", GLProfile.GL2);
+ Assert.assertTrue("GLProfile-ref != 'GL2'-ref", GLProfile.GL2 == "GL2");
+ }
+
+ @Test
+ public void test02InitSingleton() throws InterruptedException {
+ Assert.assertFalse("JOGL is initialized before usage", GLProfile.isInitialized());
GLProfile.initSingleton();
+ Assert.assertTrue("JOGL is not initialized after enforced initialization", GLProfile.isInitialized());
+ }
+
+ @Test
+ public void test11DumpDesktopGLInfo() throws InterruptedException {
+ Assert.assertTrue("JOGL is not initialized ...", GLProfile.isInitialized());
System.err.println("Desktop");
final GLDrawableFactory desktopFactory = GLDrawableFactory.getDesktopFactory();
if( null != desktopFactory ) {
@@ -54,7 +74,11 @@ public class TestGLProfile00NEWT extends UITestCase {
} else {
System.err.println("\tNULL");
}
+ }
+ @Test
+ public void test12DumpEGLGLInfo() throws InterruptedException {
+ Assert.assertTrue("JOGL is not initialized ...", GLProfile.isInitialized());
System.err.println("EGL");
final GLDrawableFactory eglFactory = GLDrawableFactory.getEGLFactory();
if( null != eglFactory ) {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile01NEWT.java
index 633a2822e..3262ff996 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile01NEWT.java
@@ -36,6 +36,7 @@ import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLContext;
import javax.media.opengl.GLDrawableFactory;
import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
import org.junit.Assert;
@@ -72,12 +73,562 @@ public class TestGLProfile01NEWT extends UITestCase {
}
}
- static void validate(final GLProfile glp) {
+ //
+ // GL4bc, GL4, GL3bc, GL3, GL2, GL2GL3, GL4ES3, GL3ES3, GL2ES2, GL2ES1, GLES3, GLES2, GLES1
+ //
+ // Real: GL4bc, GL4, GL3bc, GL3, GL2, GLES3, GLES2, GLES1
+ // Maps: GL2GL3, GL4ES3, GL3ES3, GL2ES2, GL2ES1
+ //
+
+ private static void validateGLProfileGL4bc(final GLProfile glp) {
+ Assert.assertTrue(glp.isGL4bc());
+ Assert.assertTrue(glp.isGL4());
+ Assert.assertTrue(glp.isGL3bc());
+ Assert.assertTrue(glp.isGL3());
+ Assert.assertTrue(glp.isGL2());
+ Assert.assertFalse(glp.isGLES3());
+ Assert.assertFalse(glp.isGLES2());
+ Assert.assertFalse(glp.isGLES1());
+ Assert.assertTrue(glp.isGL2GL3());
+ Assert.assertTrue(glp.isGL4ES3());
+ Assert.assertTrue(glp.isGL3ES3());
+ Assert.assertTrue(glp.isGL2ES2());
+ Assert.assertTrue(glp.isGL2ES1());
+ }
+ private static void validateGL4bc(final GL gl) {
+ final GLContext ctx = gl.getContext();
+ final boolean gles3CompatAvail = ctx.isGLES3Compatible();
+
+ Assert.assertTrue(gl.isGL4bc());
+ Assert.assertTrue(gl.isGL4());
+ Assert.assertTrue(gl.isGL3bc());
+ Assert.assertTrue(gl.isGL3());
+ Assert.assertTrue(gl.isGL2());
+ Assert.assertTrue(gl.isGL2GL3());
+ if( gles3CompatAvail ) {
+ Assert.assertTrue(gl.isGL4ES3());
+ } else {
+ Assert.assertFalse(gl.isGL4ES3());
+ }
+ Assert.assertTrue(gl.isGL3ES3());
+ Assert.assertTrue(gl.isGL2ES2());
+ Assert.assertTrue(gl.isGL2ES1());
+ Assert.assertFalse(gl.isGLES3());
+ Assert.assertFalse(gl.isGLES2());
+ Assert.assertFalse(gl.isGLES1());
+
+ Assert.assertTrue(ctx.isGL4bc());
+ Assert.assertTrue(ctx.isGL4());
+ Assert.assertTrue(ctx.isGL3bc());
+ Assert.assertTrue(ctx.isGL3());
+ Assert.assertTrue(ctx.isGL2());
+ Assert.assertTrue(ctx.isGL2GL3());
+ if( gles3CompatAvail ) {
+ Assert.assertTrue(ctx.isGL4ES3());
+ } else {
+ Assert.assertFalse(ctx.isGL4ES3());
+ }
+ Assert.assertTrue(ctx.isGL3ES3());
+ Assert.assertTrue(ctx.isGL2ES2());
+ Assert.assertTrue(ctx.isGL2ES1());
+ Assert.assertFalse(ctx.isGLES3());
+ Assert.assertFalse(ctx.isGLES2());
+ Assert.assertFalse(ctx.isGLES1());
+ }
+
+ private static void validateGLProfileGL4(final GLProfile glp) {
+ Assert.assertFalse(glp.isGL4bc());
+ Assert.assertTrue(glp.isGL4());
+ Assert.assertFalse(glp.isGL3bc());
+ Assert.assertTrue(glp.isGL3());
+ Assert.assertFalse(glp.isGL2());
+ Assert.assertFalse(glp.isGLES3());
+ Assert.assertFalse(glp.isGLES2());
+ Assert.assertFalse(glp.isGLES1());
+ Assert.assertTrue(glp.isGL2GL3());
+ Assert.assertTrue(glp.isGL4ES3());
+ Assert.assertTrue(glp.isGL3ES3());
+ Assert.assertTrue(glp.isGL2ES2());
+ Assert.assertFalse(glp.isGL2ES1());
+ }
+ private static void validateGL4(final GL gl) {
+ final GLContext ctx = gl.getContext();
+ final boolean gles3CompatAvail = ctx.isGLES3Compatible();
+
+ Assert.assertFalse(gl.isGL4bc());
+ Assert.assertTrue(gl.isGL4());
+ Assert.assertFalse(gl.isGL3bc());
+ Assert.assertTrue(gl.isGL3());
+ Assert.assertFalse(gl.isGL2());
+ Assert.assertTrue(gl.isGL2GL3());
+ if( gles3CompatAvail ) {
+ Assert.assertTrue(gl.isGL4ES3());
+ } else {
+ Assert.assertFalse(gl.isGL4ES3());
+ }
+ Assert.assertTrue(gl.isGL3ES3());
+ Assert.assertTrue(gl.isGL2ES2());
+ Assert.assertFalse(gl.isGL2ES1());
+ Assert.assertFalse(gl.isGLES3());
+ Assert.assertFalse(gl.isGLES2());
+ Assert.assertFalse(gl.isGLES1());
+
+ Assert.assertFalse(ctx.isGL4bc());
+ Assert.assertTrue(ctx.isGL4());
+ Assert.assertFalse(ctx.isGL3bc());
+ Assert.assertTrue(ctx.isGL3());
+ Assert.assertFalse(ctx.isGL2());
+ Assert.assertTrue(ctx.isGL2GL3());
+ if( gles3CompatAvail ) {
+ Assert.assertTrue(ctx.isGL4ES3());
+ } else {
+ Assert.assertFalse(ctx.isGL4ES3());
+ }
+ Assert.assertTrue(ctx.isGL3ES3());
+ Assert.assertTrue(ctx.isGL2ES2());
+ Assert.assertFalse(ctx.isGL2ES1());
+ Assert.assertFalse(ctx.isGLES3());
+ Assert.assertFalse(ctx.isGLES2());
+ Assert.assertFalse(ctx.isGLES1());
+ }
+
+ private static void validateGLProfileGL3bc(final GLProfile glp) {
+ Assert.assertFalse(glp.isGL4bc());
+ Assert.assertFalse(glp.isGL4());
+ Assert.assertTrue(glp.isGL3bc());
+ Assert.assertTrue(glp.isGL3());
+ Assert.assertTrue(glp.isGL2());
+ Assert.assertFalse(glp.isGLES3());
+ Assert.assertFalse(glp.isGLES2());
+ Assert.assertFalse(glp.isGLES1());
+ Assert.assertTrue(glp.isGL2GL3());
+ Assert.assertFalse(glp.isGL4ES3());
+ Assert.assertTrue(glp.isGL3ES3());
+ Assert.assertTrue(glp.isGL2ES2());
+ Assert.assertTrue(glp.isGL2ES1());
+ }
+ private static void validateGL3bc(final GL gl) {
+ final GLContext ctx = gl.getContext();
+ final boolean gles3CompatAvail = ctx.isGLES3Compatible();
+
+ Assert.assertFalse(gl.isGL4bc());
+ Assert.assertFalse(gl.isGL4());
+ Assert.assertTrue(gl.isGL3bc());
+ Assert.assertTrue(gl.isGL3());
+ Assert.assertTrue(gl.isGL2());
+ Assert.assertTrue(gl.isGL2GL3());
+ if( gles3CompatAvail ) { // possible w/ GL3 implementations!
+ Assert.assertTrue(gl.isGL4ES3());
+ } else {
+ Assert.assertFalse(gl.isGL4ES3());
+ }
+ Assert.assertTrue(gl.isGL3ES3());
+ Assert.assertTrue(gl.isGL2ES2());
+ Assert.assertTrue(gl.isGL2ES1());
+ Assert.assertFalse(gl.isGLES3());
+ Assert.assertFalse(gl.isGLES2());
+ Assert.assertFalse(gl.isGLES1());
+
+ Assert.assertFalse(ctx.isGL4bc());
+ Assert.assertFalse(ctx.isGL4());
+ Assert.assertTrue(ctx.isGL3bc());
+ Assert.assertTrue(ctx.isGL3());
+ Assert.assertTrue(ctx.isGL2());
+ Assert.assertTrue(ctx.isGL2GL3());
+ if( gles3CompatAvail ) { // possible w/ GL3 implementations!
+ Assert.assertTrue(ctx.isGL4ES3());
+ } else {
+ Assert.assertFalse(ctx.isGL4ES3());
+ }
+ Assert.assertTrue(ctx.isGL3ES3());
+ Assert.assertTrue(ctx.isGL2ES2());
+ Assert.assertTrue(ctx.isGL2ES1());
+ Assert.assertFalse(ctx.isGLES3());
+ Assert.assertFalse(ctx.isGLES2());
+ Assert.assertFalse(ctx.isGLES1());
+ }
+
+ private static void validateGLProfileGL3(final GLProfile glp) {
+ Assert.assertFalse(glp.isGL4bc());
+ Assert.assertFalse(glp.isGL4());
+ Assert.assertFalse(glp.isGL3bc());
+ Assert.assertTrue(glp.isGL3());
+ Assert.assertFalse(glp.isGL2());
+ Assert.assertFalse(glp.isGLES3());
+ Assert.assertFalse(glp.isGLES2());
+ Assert.assertFalse(glp.isGLES1());
+ Assert.assertTrue(glp.isGL2GL3());
+ Assert.assertFalse(glp.isGL4ES3());
+ Assert.assertTrue(glp.isGL3ES3());
+ Assert.assertTrue(glp.isGL2ES2());
+ Assert.assertFalse(glp.isGL2ES1());
+ }
+ private static void validateGL3(final GL gl) {
+ final GLContext ctx = gl.getContext();
+ final boolean gles3CompatAvail = ctx.isGLES3Compatible();
+
+ Assert.assertFalse(gl.isGL4bc());
+ Assert.assertFalse(gl.isGL4());
+ Assert.assertFalse(gl.isGL3bc());
+ Assert.assertTrue(gl.isGL3());
+ Assert.assertFalse(gl.isGL2());
+ Assert.assertTrue(gl.isGL2GL3());
+ if( gles3CompatAvail ) { // possible w/ GL3 implementations!
+ Assert.assertTrue(gl.isGL4ES3());
+ } else {
+ Assert.assertFalse(gl.isGL4ES3());
+ }
+ Assert.assertTrue(gl.isGL3ES3());
+ Assert.assertTrue(gl.isGL2ES2());
+ Assert.assertFalse(gl.isGL2ES1());
+ Assert.assertFalse(gl.isGLES3());
+ Assert.assertFalse(gl.isGLES2());
+ Assert.assertFalse(gl.isGLES1());
+
+ Assert.assertFalse(ctx.isGL4bc());
+ Assert.assertFalse(ctx.isGL4());
+ Assert.assertFalse(ctx.isGL3bc());
+ Assert.assertTrue(ctx.isGL3());
+ Assert.assertFalse(ctx.isGL2());
+ Assert.assertTrue(ctx.isGL2GL3());
+ if( gles3CompatAvail ) { // possible w/ GL3 implementations!
+ Assert.assertTrue(ctx.isGL4ES3());
+ } else {
+ Assert.assertFalse(ctx.isGL4ES3());
+ }
+ Assert.assertTrue(ctx.isGL3ES3());
+ Assert.assertTrue(ctx.isGL2ES2());
+ Assert.assertFalse(ctx.isGL2ES1());
+ Assert.assertFalse(ctx.isGLES3());
+ Assert.assertFalse(ctx.isGLES2());
+ Assert.assertFalse(ctx.isGLES1());
+ }
+
+ private static void validateGLProfileGL2(final GLProfile glp) {
+ Assert.assertFalse(glp.isGL4bc());
+ Assert.assertFalse(glp.isGL4());
+ Assert.assertFalse(glp.isGL3bc());
+ Assert.assertFalse(glp.isGL3());
+ Assert.assertTrue(glp.isGL2());
+ Assert.assertFalse(glp.isGLES3());
+ Assert.assertFalse(glp.isGLES2());
+ Assert.assertFalse(glp.isGLES1());
+ Assert.assertTrue(glp.isGL2GL3());
+ Assert.assertFalse(glp.isGL4ES3());
+ Assert.assertFalse(glp.isGL3ES3());
+ Assert.assertTrue(glp.isGL2ES2());
+ Assert.assertTrue(glp.isGL2ES1());
+ }
+ private static void validateGL2(final GL gl) {
+ final GLContext ctx = gl.getContext();
+ final boolean gles3CompatAvail = ctx.isGLES3Compatible();
+
+ Assert.assertFalse(gl.isGL4bc());
+ Assert.assertFalse(gl.isGL4());
+ Assert.assertFalse(gl.isGL3bc());
+ Assert.assertFalse(gl.isGL3());
+ Assert.assertTrue(gl.isGL2());
+ Assert.assertTrue(gl.isGL2GL3());
+ Assert.assertFalse(gl.isGL4ES3());
+ Assert.assertFalse(gl.isGL3ES3());
+ Assert.assertTrue(gl.isGL2ES2());
+ Assert.assertTrue(gl.isGL2ES1());
+ Assert.assertFalse(gl.isGLES3());
+ Assert.assertFalse(gl.isGLES2());
+ Assert.assertFalse(gl.isGLES1());
+
+ Assert.assertFalse(ctx.isGL4bc());
+ Assert.assertFalse(ctx.isGL4());
+ Assert.assertFalse(ctx.isGL3bc());
+ Assert.assertFalse(ctx.isGL3());
+ Assert.assertTrue(ctx.isGL2());
+ Assert.assertTrue(ctx.isGL2GL3());
+ Assert.assertFalse(ctx.isGL4ES3());
+ Assert.assertFalse(ctx.isGL3ES3());
+ Assert.assertFalse(gles3CompatAvail);
+ Assert.assertTrue(ctx.isGL2ES2());
+ Assert.assertTrue(ctx.isGL2ES1());
+ Assert.assertFalse(ctx.isGLES3());
+ Assert.assertFalse(ctx.isGLES2());
+ Assert.assertFalse(ctx.isGLES1());
+ }
+
+ private static void validateGLProfileGLES3(final GLProfile glp) {
+ Assert.assertFalse(glp.isGL4bc());
+ Assert.assertFalse(glp.isGL4());
+ Assert.assertFalse(glp.isGL3bc());
+ Assert.assertFalse(glp.isGL3());
+ Assert.assertFalse(glp.isGL2());
+ Assert.assertTrue(glp.isGLES3());
+ Assert.assertTrue(glp.isGLES2());
+ Assert.assertFalse(glp.isGLES1());
+ Assert.assertFalse(glp.isGL2GL3());
+ Assert.assertTrue(glp.isGL4ES3());
+ Assert.assertTrue(glp.isGL3ES3());
+ Assert.assertTrue(glp.isGL2ES2());
+ Assert.assertFalse(glp.isGL2ES1());
+ }
+ private static void validateGLES3(final GL gl) {
+ final GLContext ctx = gl.getContext();
+ final boolean gles3CompatAvail = ctx.isGLES3Compatible();
+
+ Assert.assertFalse(gl.isGL4bc());
+ Assert.assertFalse(gl.isGL4());
+ Assert.assertFalse(gl.isGL3bc());
+ Assert.assertFalse(gl.isGL3());
+ Assert.assertFalse(gl.isGL2());
+ Assert.assertFalse(gl.isGL2GL3());
+ Assert.assertTrue(gl.isGL4ES3());
+ Assert.assertTrue(gl.isGL3ES3());
+ Assert.assertTrue(gl.isGL2ES2());
+ Assert.assertFalse(gl.isGL2ES1());
+ Assert.assertTrue(gl.isGLES3());
+ Assert.assertTrue(gl.isGLES2());
+ Assert.assertFalse(gl.isGLES1());
+
+ Assert.assertFalse(ctx.isGL4bc());
+ Assert.assertFalse(ctx.isGL4());
+ Assert.assertFalse(ctx.isGL3bc());
+ Assert.assertFalse(ctx.isGL3());
+ Assert.assertFalse(ctx.isGL2());
+ Assert.assertFalse(ctx.isGL2GL3());
+ Assert.assertTrue(ctx.isGL4ES3());
+ Assert.assertTrue(ctx.isGL3ES3());
+ Assert.assertTrue(gles3CompatAvail);
+ Assert.assertTrue(ctx.isGL2ES2());
+ Assert.assertFalse(ctx.isGL2ES1());
+ Assert.assertTrue(ctx.isGLES3());
+ Assert.assertTrue(ctx.isGLES2());
+ Assert.assertFalse(ctx.isGLES1());
+ }
+
+ private static void validateGLProfileGLES2(final GLProfile glp) {
+ Assert.assertFalse(glp.isGL4bc());
+ Assert.assertFalse(glp.isGL4());
+ Assert.assertFalse(glp.isGL3bc());
+ Assert.assertFalse(glp.isGL3());
+ Assert.assertFalse(glp.isGL2());
+ Assert.assertFalse(glp.isGLES3());
+ Assert.assertTrue(glp.isGLES2());
+ Assert.assertFalse(glp.isGLES1());
+ Assert.assertFalse(glp.isGL2GL3());
+ Assert.assertFalse(glp.isGL4ES3());
+ Assert.assertFalse(glp.isGL3ES3());
+ Assert.assertTrue(glp.isGL2ES2());
+ Assert.assertFalse(glp.isGL2ES1());
+ }
+ private static void validateGLES2(final GL gl) {
+ final GLContext ctx = gl.getContext();
+ final boolean gles3CompatAvail = ctx.isGLES3Compatible();
+
+ Assert.assertFalse(gl.isGL4bc());
+ Assert.assertFalse(gl.isGL4());
+ Assert.assertFalse(gl.isGL3bc());
+ Assert.assertFalse(gl.isGL3());
+ Assert.assertFalse(gl.isGL2());
+ Assert.assertFalse(gl.isGL2GL3());
+ Assert.assertFalse(gl.isGL4ES3());
+ Assert.assertFalse(gl.isGL3ES3());
+ Assert.assertTrue(gl.isGL2ES2());
+ Assert.assertFalse(gl.isGL2ES1());
+ Assert.assertFalse(gl.isGLES3());
+ Assert.assertTrue(gl.isGLES2());
+ Assert.assertFalse(gl.isGLES1());
+
+ Assert.assertFalse(ctx.isGL4bc());
+ Assert.assertFalse(ctx.isGL4());
+ Assert.assertFalse(ctx.isGL3bc());
+ Assert.assertFalse(ctx.isGL3());
+ Assert.assertFalse(ctx.isGL2());
+ Assert.assertFalse(ctx.isGL2GL3());
+ Assert.assertFalse(ctx.isGL4ES3());
+ Assert.assertFalse(ctx.isGL3ES3());
+ Assert.assertFalse(gles3CompatAvail);
+ Assert.assertTrue(ctx.isGL2ES2());
+ Assert.assertFalse(ctx.isGL2ES1());
+ Assert.assertFalse(ctx.isGLES3());
+ Assert.assertTrue(ctx.isGLES2());
+ Assert.assertFalse(ctx.isGLES1());
+ }
+
+ private static void validateGLProfileGLES1(final GLProfile glp) {
+ Assert.assertFalse(glp.isGL4bc());
+ Assert.assertFalse(glp.isGL4());
+ Assert.assertFalse(glp.isGL3bc());
+ Assert.assertFalse(glp.isGL3());
+ Assert.assertFalse(glp.isGL2());
+ Assert.assertFalse(glp.isGLES3());
+ Assert.assertFalse(glp.isGLES2());
+ Assert.assertTrue(glp.isGLES1());
+ Assert.assertFalse(glp.isGL2GL3());
+ Assert.assertFalse(glp.isGL4ES3());
+ Assert.assertFalse(glp.isGL3ES3());
+ Assert.assertFalse(glp.isGL2ES2());
+ Assert.assertTrue(glp.isGL2ES1());
+ }
+ private static void validateGLES1(final GL gl) {
+ final GLContext ctx = gl.getContext();
+ final boolean gles3CompatAvail = ctx.isGLES3Compatible();
+
+ Assert.assertFalse(gl.isGL4bc());
+ Assert.assertFalse(gl.isGL4());
+ Assert.assertFalse(gl.isGL3bc());
+ Assert.assertFalse(gl.isGL3());
+ Assert.assertFalse(gl.isGL2());
+ Assert.assertFalse(gl.isGL2GL3());
+ Assert.assertFalse(gl.isGL4ES3());
+ Assert.assertFalse(gl.isGL3ES3());
+ Assert.assertFalse(gl.isGL2ES2());
+ Assert.assertTrue(gl.isGL2ES1());
+ Assert.assertFalse(gl.isGLES3());
+ Assert.assertFalse(gl.isGLES2());
+ Assert.assertTrue(gl.isGLES1());
+
+ Assert.assertFalse(ctx.isGL4bc());
+ Assert.assertFalse(ctx.isGL4());
+ Assert.assertFalse(ctx.isGL3bc());
+ Assert.assertFalse(ctx.isGL3());
+ Assert.assertFalse(ctx.isGL2());
+ Assert.assertFalse(ctx.isGL2GL3());
+ Assert.assertFalse(ctx.isGL4ES3());
+ Assert.assertFalse(ctx.isGL3ES3());
+ Assert.assertFalse(gles3CompatAvail);
+ Assert.assertFalse(ctx.isGL2ES2());
+ Assert.assertTrue(ctx.isGL2ES1());
+ Assert.assertFalse(ctx.isGLES3());
+ Assert.assertFalse(ctx.isGLES2());
+ Assert.assertTrue(ctx.isGLES1());
+ }
+
+ private static void validateGLProfileGL2GL3(final GLProfile glp) {
+ if( glp.isGL4bc() ) {
+ validateGLProfileGL4bc(glp);
+ } else if(glp.isGL3bc()) {
+ validateGLProfileGL3bc(glp);
+ } else if(glp.isGL2()) {
+ validateGLProfileGL2(glp);
+ } else if(glp.isGL4()) {
+ validateGLProfileGL4(glp);
+ } else if(glp.isGL3()) {
+ validateGLProfileGL3(glp);
+ } else {
+ throw new GLException("GL2GL3 is neither GL4bc, GL3bc, GL2, GL4 nor GL3");
+ }
+ }
+ private static void validateGL2GL3(final GL gl) {
+ if( gl.isGL4bc() ) {
+ validateGL4bc(gl);
+ } else if(gl.isGL3bc()) {
+ validateGL3bc(gl);
+ } else if(gl.isGL2()) {
+ validateGL2(gl);
+ } else if(gl.isGL4()) {
+ validateGL4(gl);
+ } else if(gl.isGL3()) {
+ validateGL3(gl);
+ } else {
+ throw new GLException("GL2GL3 is neither GL4bc, GL3bc, GL2, GL4 nor GL3");
+ }
+ }
+
+ private static void validateGLProfileGL4ES3(final GLProfile glp) {
+ if( glp.isGL4bc() ) {
+ validateGLProfileGL4bc(glp);
+ } else if( glp.isGL4() ) {
+ validateGLProfileGL4(glp);
+ } else if( glp.isGLES3() ) {
+ validateGLProfileGLES3(glp);
+ } else {
+ throw new GLException("GL4ES3 is neither GL4bc, GL4 nor GLES3");
+ }
+ }
+ private static void validateGL4ES3(final GL gl) {
+ if( gl.isGL4bc() ) {
+ validateGL4bc(gl);
+ } else if( gl.isGL4() ) {
+ validateGL4(gl);
+ } else if( gl.isGLES3() ) {
+ validateGLES3(gl);
+ } else {
+ throw new GLException("GL4ES3 is neither GL4bc, GL4 nor GLES3");
+ }
+ }
+
+ private static void validateGLProfileGL2ES2(final GLProfile glp) {
+ if( glp.isGL4bc() ) {
+ validateGLProfileGL4bc(glp);
+ } else if(glp.isGL3bc()) {
+ validateGLProfileGL3bc(glp);
+ } else if(glp.isGL2()) {
+ validateGLProfileGL2(glp);
+ } else if(glp.isGL4()) {
+ validateGLProfileGL4(glp);
+ } else if(glp.isGL3()) {
+ validateGLProfileGL3(glp);
+ } else if(glp.isGLES3()) {
+ validateGLProfileGLES3(glp);
+ } else if(glp.isGLES2()) {
+ validateGLProfileGLES2(glp);
+ } else {
+ throw new GLException("GL2ES2 is neither GL4bc, GL3bc, GL2, GL4, GL3, GLES3 nor GLES2");
+ }
+ }
+ private static void validateGL2ES2(final GL gl) {
+ if( gl.isGL4bc() ) {
+ validateGL4bc(gl);
+ } else if(gl.isGL3bc()) {
+ validateGL3bc(gl);
+ } else if(gl.isGL2()) {
+ validateGL2(gl);
+ } else if(gl.isGL4()) {
+ validateGL4(gl);
+ } else if(gl.isGL3()) {
+ validateGL3(gl);
+ } else if(gl.isGLES3()) {
+ validateGLES3(gl);
+ } else if(gl.isGLES2()) {
+ validateGLES2(gl);
+ } else {
+ throw new GLException("GL2ES2 is neither GL4bc, GL3bc, GL2, GL4, GL3, GLES3 nor GLES2");
+ }
+ }
+
+ private static void validateGLProfileGL2ES1(final GLProfile glp) {
+ if( glp.isGL4bc() ) {
+ validateGLProfileGL4bc(glp);
+ } else if(glp.isGL3bc()) {
+ validateGLProfileGL3bc(glp);
+ } else if(glp.isGL2()) {
+ validateGLProfileGL2(glp);
+ } else if(glp.isGLES1()) {
+ validateGLProfileGLES1(glp);
+ } else {
+ throw new GLException("GL2ES1 is neither GL4bc, GL3bc, GL2 nor GLES1");
+ }
+ }
+ private static void validateGL2ES1(final GL gl) {
+ if( gl.isGL4bc() ) {
+ validateGL4bc(gl);
+ } else if(gl.isGL3bc()) {
+ validateGL3bc(gl);
+ } else if(gl.isGL2()) {
+ validateGL2(gl);
+ } else if(gl.isGLES1()) {
+ validateGLES1(gl);
+ } else {
+ throw new GLException("GL2ES1 is neither GL4bc, GL3bc, GL2 nor GLES1");
+ }
+ }
+
+ private static void validateOffline(final String requestedProfile, final GLProfile glp) {
+ System.err.println("GLProfile Mapping "+requestedProfile+" -> "+glp);
+
final boolean gles3CompatAvail = GLContext.isGLES3CompatibleAvailable(GLProfile.getDefaultDevice());
if( glp.getImplName().equals(GLProfile.GL4bc) ) {
Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL4bc));
Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL4));
Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL3bc));
+ Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL3));
Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL2));
Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL2GL3));
if( gles3CompatAvail ) {
@@ -129,163 +680,233 @@ public class TestGLProfile01NEWT extends UITestCase {
Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL2ES1));
}
if( glp.isGL4bc() ) {
- Assert.assertTrue(glp.isGL4());
- Assert.assertTrue(glp.isGL3bc());
- Assert.assertTrue(glp.isGL3());
- Assert.assertTrue(glp.isGL2());
- Assert.assertTrue(glp.isGL2GL3());
- Assert.assertTrue(glp.isGL4ES3());
- Assert.assertTrue(glp.isGL3ES3());
- Assert.assertTrue(glp.isGL2ES1());
- Assert.assertTrue(glp.isGL2ES2());
+ validateGLProfileGL4bc(glp);
} else if(glp.isGL3bc()) {
- Assert.assertTrue(glp.isGL3());
- Assert.assertTrue(glp.isGL2());
- Assert.assertTrue(glp.isGL2GL3());
- Assert.assertTrue(glp.isGL2ES1());
- Assert.assertTrue(glp.isGL2ES2());
+ validateGLProfileGL3bc(glp);
} else if(glp.isGL2()) {
- Assert.assertTrue(glp.isGL2GL3());
- Assert.assertTrue(glp.isGL2ES1());
- Assert.assertTrue(glp.isGL2ES2());
+ validateGLProfileGL2(glp);
} else if(glp.isGL4()) {
- Assert.assertTrue(glp.isGL3());
- Assert.assertTrue(glp.isGL2GL3());
- Assert.assertTrue(glp.isGL4ES3());
- Assert.assertTrue(glp.isGL3ES3());
- Assert.assertTrue(glp.isGL2ES2());
+ validateGLProfileGL4(glp);
} else if(glp.isGL3()) {
- Assert.assertTrue(glp.isGL2GL3());
- Assert.assertTrue(glp.isGL3ES3());
- Assert.assertTrue(glp.isGL2ES2());
+ validateGLProfileGL3(glp);
} else if(glp.isGLES3()) {
- Assert.assertTrue(glp.isGL4ES3());
- Assert.assertTrue(glp.isGL3ES3());
- Assert.assertTrue(glp.isGL2ES2());
+ validateGLProfileGLES3(glp);
} else if(glp.isGLES2()) {
- Assert.assertTrue(glp.isGL2ES2());
+ validateGLProfileGLES2(glp);
} else if(glp.isGLES1()) {
- Assert.assertTrue(glp.isGL2ES1());
+ validateGLProfileGLES1(glp);
}
+
+ if( requestedProfile == GLProfile.GL4bc ) {
+ validateGLProfileGL4bc(glp);
+ } else if( requestedProfile == GLProfile.GL3bc ) {
+ validateGLProfileGL3bc(glp);
+ } else if( requestedProfile == GLProfile.GL2 ) {
+ validateGLProfileGL2(glp);
+ } else if( requestedProfile == GLProfile.GL4 ) {
+ validateGLProfileGL4(glp);
+ } else if( requestedProfile == GLProfile.GL3 ) {
+ validateGLProfileGL3(glp);
+ } else if( requestedProfile == GLProfile.GLES3 ) {
+ validateGLProfileGLES3(glp);
+ } else if( requestedProfile == GLProfile.GLES2 ) {
+ validateGLProfileGLES2(glp);
+ } else if( requestedProfile == GLProfile.GLES1 ) {
+ validateGLProfileGLES1(glp);
+ } else if( requestedProfile == GLProfile.GL2GL3 ) {
+ validateGLProfileGL2GL3(glp);
+ } else if( requestedProfile == GLProfile.GL4ES3 ) {
+ validateGLProfileGL4ES3(glp);
+ } else if( requestedProfile == GLProfile.GL2ES2 ) {
+ validateGLProfileGL2ES2(glp);
+ } else if( requestedProfile == GLProfile.GL2ES1 ) {
+ validateGLProfileGL2ES1(glp);
+ }
+
}
- static void validate(final GL gl) {
+ static void validateOnline(final String requestedProfile, final GLProfile glpReq, final GL gl) {
final GLContext ctx = gl.getContext();
- final boolean gles3CompatAvail = ctx.isGLES3Compatible();
+ final GLProfile glp = gl.getGLProfile();
+ System.err.println("GLContext Mapping "+requestedProfile+" -> "+glpReq+" -> "+glp+" -> "+ctx.getGLVersion());
+
+ System.err.println("GL impl. class "+gl.getClass().getName());
+ if( gl.isGL4() ) {
+ Assert.assertNotNull( gl.getGL4() );
+ System.err.println("GL Mapping "+glp+" -> GL4");
+ }
if( gl.isGL4bc() ) {
- Assert.assertTrue(gl.isGL4());
- Assert.assertTrue(gl.isGL3bc());
- Assert.assertTrue(gl.isGL3());
- Assert.assertTrue(gl.isGL2());
- Assert.assertTrue(gl.isGL2GL3());
- if( gles3CompatAvail ) {
- Assert.assertTrue(gl.isGL4ES3());
- } else {
- Assert.assertFalse(gl.isGL4ES3());
- }
- Assert.assertTrue(gl.isGL3ES3());
- Assert.assertTrue(gl.isGL2ES1());
- Assert.assertTrue(gl.isGL2ES2());
+ Assert.assertNotNull( gl.getGL4bc() );
+ System.err.println("GL Mapping "+glp+" -> GL4bc");
+ }
+ if( gl.isGL3() ) {
+ Assert.assertNotNull( gl.getGL3() );
+ System.err.println("GL Mapping "+glp+" -> GL3");
+ }
+ if( gl.isGL3bc() ) {
+ Assert.assertNotNull( gl.getGL3bc() );
+ System.err.println("GL Mapping "+glp+" -> GL3bc");
+ }
+ if( gl.isGL2() ) {
+ Assert.assertNotNull( gl.getGL2() );
+ System.err.println("GL Mapping "+glp+" -> GL2");
+ }
+ if( gl.isGLES3() ) {
+ Assert.assertNotNull( gl.getGLES3() );
+ System.err.println("GL Mapping "+glp+" -> GLES3");
+ }
+ if( gl.isGLES2() ) {
+ Assert.assertNotNull( gl.getGLES2() );
+ System.err.println("GL Mapping "+glp+" -> GLES2");
+ }
+ if( gl.isGLES1() ) {
+ Assert.assertNotNull( gl.getGLES1() );
+ System.err.println("GL Mapping "+glp+" -> GLES1");
+ }
+ if( gl.isGL4ES3() ) {
+ Assert.assertNotNull( gl.getGL4ES3() );
+ System.err.println("GL Mapping "+glp+" -> GL4ES3");
+ }
+ if( gl.isGL3ES3() ) {
+ Assert.assertNotNull( gl.getGL3ES3() );
+ System.err.println("GL Mapping "+glp+" -> GL3ES3");
+ }
+ if( gl.isGL2GL3() ) {
+ Assert.assertNotNull( gl.getGL2GL3() );
+ System.err.println("GL Mapping "+glp+" -> GL2GL3");
+ }
+ if( gl.isGL2ES2() ) {
+ Assert.assertNotNull( gl.getGL2ES2() );
+ System.err.println("GL Mapping "+glp+" -> GL2ES2");
+ }
+ if( gl.isGL2ES1() ) {
+ Assert.assertNotNull( gl.getGL2ES1() );
+ System.err.println("GL Mapping "+glp+" -> GL2ES1");
+ }
+
+ if( gl.isGL4bc() ) {
+ validateGL4bc(gl);
} else if(gl.isGL3bc()) {
- Assert.assertTrue(gl.isGL3());
- Assert.assertTrue(gl.isGL2());
- Assert.assertTrue(gl.isGL2GL3());
- Assert.assertTrue(gl.isGL2ES1());
- Assert.assertTrue(gl.isGL2ES2());
+ validateGL3bc(gl);
} else if(gl.isGL2()) {
- Assert.assertTrue(gl.isGL2GL3());
- Assert.assertTrue(gl.isGL2ES1());
- Assert.assertTrue(gl.isGL2ES2());
+ validateGL2(gl);
} else if(gl.isGL4()) {
- Assert.assertTrue(gl.isGL3());
- Assert.assertTrue(gl.isGL2GL3());
- if( gles3CompatAvail ) {
- Assert.assertTrue(gl.isGL4ES3());
- } else {
- Assert.assertFalse(gl.isGL4ES3());
- }
- Assert.assertTrue(gl.isGL3ES3());
- Assert.assertTrue(gl.isGL2ES2());
+ validateGL4(gl);
} else if(gl.isGL3()) {
- Assert.assertTrue(gl.isGL2GL3());
- Assert.assertTrue(gl.isGL3ES3());
- Assert.assertTrue(gl.isGL2ES2());
+ validateGL3(gl);
} else if(gl.isGLES3()) {
- if( gles3CompatAvail ) {
- Assert.assertTrue(gl.isGL4ES3());
- } else {
- Assert.assertFalse(gl.isGL4ES3());
- }
- Assert.assertTrue(gl.isGL3ES3());
- Assert.assertTrue(gl.isGL2ES2());
+ validateGLES3(gl);
} else if(gl.isGLES2()) {
- Assert.assertTrue(gl.isGL2ES2());
+ validateGLES2(gl);
} else if(gl.isGLES1()) {
- Assert.assertTrue(gl.isGL2ES1());
+ validateGLES1(gl);
}
- if( ctx.isGL4bc() ) {
- Assert.assertTrue(ctx.isGL4());
- Assert.assertTrue(ctx.isGL3bc());
- Assert.assertTrue(ctx.isGL3());
- Assert.assertTrue(ctx.isGL2());
- Assert.assertTrue(ctx.isGL2GL3());
- if( gles3CompatAvail ) {
- Assert.assertTrue(ctx.isGL4ES3());
+ if( requestedProfile == GLProfile.GL4bc ) {
+ validateGL4bc(gl);
+ } else if( requestedProfile == GLProfile.GL3bc ) {
+ if( gl.isGL4bc() ) {
+ validateGL4bc(gl);
+ } else if( gl.isGL3bc() ) {
+ validateGL3bc(gl);
} else {
- Assert.assertFalse(ctx.isGL4ES3());
+ throw new GLException("GL3bc is neither GL4bc nor GL3bc");
}
- Assert.assertTrue(ctx.isGL3ES3());
- Assert.assertTrue(ctx.isGL2ES1());
- Assert.assertTrue(ctx.isGL2ES2());
- } else if(ctx.isGL3bc()) {
- Assert.assertTrue(ctx.isGL3());
- Assert.assertTrue(ctx.isGL2());
- Assert.assertTrue(ctx.isGL2GL3());
- Assert.assertTrue(ctx.isGL2ES1());
- Assert.assertTrue(ctx.isGL2ES2());
- } else if(ctx.isGL2()) {
- Assert.assertTrue(ctx.isGL2GL3());
- Assert.assertTrue(ctx.isGL2ES1());
- Assert.assertTrue(ctx.isGL2ES2());
- } else if(ctx.isGL4()) {
- Assert.assertTrue(ctx.isGL3());
- Assert.assertTrue(ctx.isGL2GL3());
- if( gles3CompatAvail ) {
- Assert.assertTrue(ctx.isGL4ES3());
+ } else if( requestedProfile == GLProfile.GL2 ) {
+ if( gl.isGL4bc() ) {
+ validateGL4bc(gl);
+ } else if( gl.isGL3bc() ) {
+ validateGL3bc(gl);
+ } else if( gl.isGL2() ) {
+ validateGL2(gl);
} else {
- Assert.assertFalse(ctx.isGL4ES3());
+ throw new GLException("GL2 is neither GL4bc, GL3bc, GL2");
}
- Assert.assertTrue(ctx.isGL3ES3());
- Assert.assertTrue(ctx.isGL2ES2());
- } else if(ctx.isGL3()) {
- Assert.assertTrue(ctx.isGL2GL3());
- Assert.assertTrue(ctx.isGL3ES3());
- Assert.assertTrue(ctx.isGL2ES2());
- } else if(ctx.isGLES3()) {
- if( gles3CompatAvail ) {
- Assert.assertTrue(ctx.isGL4ES3());
+ } else if( requestedProfile == GLProfile.GL4 ) {
+ if( gl.isGL4bc() ) {
+ validateGL4bc(gl);
+ } else if( gl.isGL4() ) {
+ validateGL4(gl);
+ } else {
+ throw new GLException("GL4 is neither GL4bc, nor GL4");
+ }
+ } else if( requestedProfile == GLProfile.GL3 ) {
+ if( gl.isGL4bc() ) {
+ validateGL4bc(gl);
+ } else if( gl.isGL3bc() ) {
+ validateGL3bc(gl);
+ } else if( gl.isGL4() ) {
+ validateGL4(gl);
+ } else if( gl.isGL3() ) {
+ validateGL3(gl);
+ } else {
+ throw new GLException("GL3 is neither GL4bc, GL3bc, GL4 nor GL3");
+ }
+ } else if( requestedProfile == GLProfile.GLES3 ) {
+ validateGLES3(gl);
+ } else if( requestedProfile == GLProfile.GLES2 ) {
+ if( gl.isGLES3() ) {
+ validateGLES3(gl);
+ } else if( gl.isGLES2() ) {
+ validateGLES2(gl);
} else {
- Assert.assertFalse(ctx.isGL4ES3());
+ throw new GLException("GLES2 is neither GLES3 nor GLES2");
}
- Assert.assertTrue(ctx.isGL3ES3());
- Assert.assertTrue(ctx.isGL2ES2());
- } else if(ctx.isGLES2()) {
- Assert.assertTrue(ctx.isGL2ES2());
- } else if(ctx.isGLES1()) {
- Assert.assertTrue(ctx.isGL2ES1());
+ } else if( requestedProfile == GLProfile.GLES1 ) {
+ validateGLES1(gl);
+ } else if( requestedProfile == GLProfile.GL2GL3 ) {
+ validateGL2GL3(gl);
+ } else if( requestedProfile == GLProfile.GL4ES3 ) {
+ validateGL4ES3(gl);
+ } else if( requestedProfile == GLProfile.GL2ES2 ) {
+ validateGL2ES2(gl);
+ } else if( requestedProfile == GLProfile.GL2ES1 ) {
+ validateGL2ES1(gl);
}
}
+ void validateOnline(final String requestedProfile, final GLProfile glp) throws InterruptedException {
+ final GLCapabilities caps = new GLCapabilities(glp);
+ final GLWindow glWindow = GLWindow.create(caps);
+ Assert.assertNotNull(glWindow);
+ glWindow.setTitle(getSimpleTestName("."));
+
+ glWindow.addGLEventListener(new GLEventListener() {
+
+ public void init(final GLAutoDrawable drawable) {
+ final GL gl = drawable.getGL();
+ System.err.println(JoglVersion.getGLStrings(gl, null, false));
+
+ validateOnline(requestedProfile, glp, gl);
+ }
+
+ public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {
+ }
+
+ public void display(final GLAutoDrawable drawable) {
+ }
+
+ public void dispose(final GLAutoDrawable drawable) {
+ }
+ });
+
+ glWindow.setSize(128, 128);
+ glWindow.setVisible(true);
+
+ glWindow.display();
+ Thread.sleep(100);
+ glWindow.destroy();
+ }
+
@Test
public void test01GLProfileDefault() throws InterruptedException {
System.out.println("GLProfile "+GLProfile.glAvailabilityToString());
System.out.println("GLProfile.getDefaultDevice(): "+GLProfile.getDefaultDevice());
final GLProfile glp = GLProfile.getDefault();
System.out.println("GLProfile.getDefault(): "+glp);
- validate(glp);
- dumpVersion(glp);
+ validateOffline("default", glp);
+ validateOnline("default", glp);
}
@Test
@@ -293,8 +914,8 @@ public class TestGLProfile01NEWT extends UITestCase {
// Assuming at least one programmable profile is available
final GLProfile glp = GLProfile.getMaxProgrammable(true);
System.out.println("GLProfile.getMaxProgrammable(): "+glp);
- validate(glp);
- dumpVersion(glp);
+ validateOffline("maxProgrammable", glp);
+ validateOnline("maxProgrammable", glp);
}
@Test
@@ -302,8 +923,8 @@ public class TestGLProfile01NEWT extends UITestCase {
// Assuming at least one fixed function profile is available
final GLProfile glp = GLProfile.getMaxFixedFunc(true);
System.out.println("GLProfile.getMaxFixedFunc(): "+glp);
- validate(glp);
- dumpVersion(glp);
+ validateOffline("maxFixedFunc", glp);
+ validateOnline("maxFixedFunc", glp);
}
@Test
@@ -313,9 +934,8 @@ public class TestGLProfile01NEWT extends UITestCase {
return;
}
final GLProfile glp = GLProfile.getGL2ES1();
- System.out.println("GLProfile GL2ES1: "+glp);
- validate(glp);
- dumpVersion(glp);
+ validateOffline(GLProfile.GL2ES1, glp);
+ validateOnline(GLProfile.GL2ES1, glp);
}
@Test
@@ -325,9 +945,8 @@ public class TestGLProfile01NEWT extends UITestCase {
return;
}
final GLProfile glp = GLProfile.getGL2ES2();
- System.out.println("GLProfile GL2ES2: "+glp);
- validate(glp);
- dumpVersion(glp);
+ validateOffline(GLProfile.GL2ES2, glp);
+ validateOnline(GLProfile.GL2ES2, glp);
}
@Test
@@ -337,16 +956,26 @@ public class TestGLProfile01NEWT extends UITestCase {
return;
}
final GLProfile glp = GLProfile.getGL4ES3();
- System.out.println("GLProfile GL4ES3: "+glp);
- validate(glp);
- dumpVersion(glp);
+ validateOffline(GLProfile.GL4ES3, glp);
+ validateOnline(GLProfile.GL4ES3, glp);
+ }
+
+ @Test
+ public void test07GLProfileGL2GL3() throws InterruptedException {
+ if(!GLProfile.isAvailable(GLProfile.GL2GL3)) {
+ System.out.println("GLProfile GL2GL3 n/a");
+ return;
+ }
+ final GLProfile glp = GLProfile.getGL2GL3();
+ validateOffline(GLProfile.GL2GL3, glp);
+ validateOnline(GLProfile.GL2GL3, glp);
}
void testSpecificProfile(final String glps) throws InterruptedException {
if(GLProfile.isAvailable(glps)) {
final GLProfile glp = GLProfile.get(glps);
- validate(glp);
- dumpVersion(glp);
+ validateOffline(glps, glp);
+ validateOnline(glps, glp);
} else {
System.err.println("Profile "+glps+" n/a");
}
@@ -392,78 +1021,6 @@ public class TestGLProfile01NEWT extends UITestCase {
testSpecificProfile(GLProfile.GLES3);
}
- protected void dumpVersion(final GLProfile glp) throws InterruptedException {
- final GLCapabilities caps = new GLCapabilities(glp);
- final GLWindow glWindow = GLWindow.create(caps);
- Assert.assertNotNull(glWindow);
- glWindow.setTitle("TestGLProfile01NEWT");
-
- glWindow.addGLEventListener(new GLEventListener() {
-
- public void init(final GLAutoDrawable drawable) {
- final GL gl = drawable.getGL();
- System.err.println(JoglVersion.getGLStrings(gl, null, true));
-
- validate(gl);
-
- final GLProfile glp = gl.getGLProfile();
- System.err.println("GL impl. class "+gl.getClass().getName());
- if( gl.isGL4() ) {
- Assert.assertNotNull( gl.getGL4() );
- System.err.println("GL Mapping "+glp+" -> GL4");
- }
- if( gl.isGL4bc() ) {
- Assert.assertNotNull( gl.getGL4bc() );
- System.err.println("GL Mapping "+glp+" -> GL4bc");
- }
- if( gl.isGL3() ) {
- Assert.assertNotNull( gl.getGL3() );
- System.err.println("GL Mapping "+glp+" -> GL3");
- }
- if( gl.isGL3bc() ) {
- Assert.assertNotNull( gl.getGL3bc() );
- System.err.println("GL Mapping "+glp+" -> GL3bc");
- }
- if( gl.isGLES3() ) {
- Assert.assertNotNull( gl.getGLES3() );
- System.err.println("GL Mapping "+glp+" -> GLES3");
- }
- if( gl.isGLES2() ) {
- Assert.assertNotNull( gl.getGLES2() );
- System.err.println("GL Mapping "+glp+" -> GLES2");
- }
- if( gl.isGL4ES3() ) {
- Assert.assertNotNull( gl.getGL4ES3() );
- System.err.println("GL Mapping "+glp+" -> GL4ES3");
- }
- if( gl.isGL2ES2() ) {
- Assert.assertNotNull( gl.getGL2ES2() );
- System.err.println("GL Mapping "+glp+" -> GL2ES2");
- }
- if( gl.isGL2ES1() ) {
- Assert.assertNotNull( gl.getGL2ES1() );
- System.err.println("GL Mapping "+glp+" -> GL2ES1");
- }
- }
-
- public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {
- }
-
- public void display(final GLAutoDrawable drawable) {
- }
-
- public void dispose(final GLAutoDrawable drawable) {
- }
- });
-
- glWindow.setSize(128, 128);
- glWindow.setVisible(true);
-
- glWindow.display();
- Thread.sleep(100);
- glWindow.destroy();
- }
-
public static void main(final String args[]) throws IOException {
final String tstname = TestGLProfile01NEWT.class.getName();
org.junit.runner.JUnitCore.main(tstname);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLCanvasAWT.java
index 2b6c84bf3..37f1c7555 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLCanvasAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLCanvasAWT.java
@@ -30,15 +30,10 @@ package com.jogamp.opengl.test.junit.jogl.acore;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Frame;
-import java.awt.image.BufferedImage;
-import java.io.File;
-import java.io.IOException;
-import javax.imageio.ImageIO;
import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilitiesImmutable;
-import javax.media.opengl.GLDrawable;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLProfile;
import javax.media.opengl.awt.GLCanvas;
@@ -49,18 +44,23 @@ import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
+import com.jogamp.common.util.VersionUtil;
+import com.jogamp.opengl.JoglVersion;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.MultisampleDemoES2;
import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.util.Animator;
-import com.jogamp.opengl.util.GLDrawableUtil;
import com.jogamp.opengl.util.awt.AWTGLReadBufferUtil;
-import com.jogamp.opengl.util.texture.TextureIO;
/**
- * Multiple GLJPanels in a JFrame
+ * Test synchronous GLAutoDrawable display, swap-buffer and read-pixels with AWT GLCanvas
+ * including non-MSAA and MSAA framebuffer.
+ * <p>
+ * See {@link GLReadBuffer00Base} for related bugs and further details.
+ * </p>
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestGLReadBuffer01GLCanvasAWT extends GLReadBuffer00Base {
+public class TestGLReadBuffer01GLCanvasAWT extends GLReadBuffer00BaseAWT {
@BeforeClass
public static void initClass() {
@@ -77,7 +77,7 @@ public class TestGLReadBuffer01GLCanvasAWT extends GLReadBuffer00Base {
final Dimension d = new Dimension(320, 240);
final GLCanvas glad = createGLCanvas(caps, d);
final TextRendererGLEL textRendererGLEL = new TextRendererGLEL();
- final SnapshotGLELAWT snapshotGLEL = doSnapshot ? new SnapshotGLELAWT(textRendererGLEL, awtGLReadBufferUtil) : null;
+ final SnapshotGLELAWT snapshotGLEL = doSnapshot ? new SnapshotGLELAWT(textRendererGLEL, awtGLReadBufferUtil, false) : null;
try {
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
@@ -88,9 +88,34 @@ public class TestGLReadBuffer01GLCanvasAWT extends GLReadBuffer00Base {
// panel.setDoubleBuffered(useSwingDoubleBuffer);
// frame.getContentPane().add(panel);
- final GearsES2 gears = new GearsES2(1);
- gears.setVerbose(false);
- glad.addGLEventListener(gears);
+ glad.addGLEventListener(new GLEventListener() {
+ @Override
+ public void init(final GLAutoDrawable drawable) {
+ final GL gl = drawable.getGL();
+ System.err.println(VersionUtil.getPlatformInfo());
+ System.err.println("GLEventListener init on "+Thread.currentThread());
+ System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities());
+ System.err.println("INIT GL IS: " + gl.getClass().getName());
+ System.err.println(JoglVersion.getGLStrings(gl, null, false).toString());
+ }
+ @Override
+ public void dispose(final GLAutoDrawable drawable) {}
+ @Override
+ public void display(final GLAutoDrawable drawable) {}
+ @Override
+ public void reshape(final GLAutoDrawable drawable, final int x,final int y, final int width, final int height) {}
+ });
+ {
+ final GearsES2 gears = new GearsES2(1);
+ gears.setVerbose(false);
+ glad.addGLEventListener(gears);
+ }
+ {
+ final MultisampleDemoES2 demo = new MultisampleDemoES2(caps.getSampleBuffers());
+ demo.setClearBuffers(false);;
+ glad.addGLEventListener(demo);
+ }
+
glad.addGLEventListener(textRendererGLEL);
if( doSnapshot ) {
glad.addGLEventListener(snapshotGLEL);
@@ -166,71 +191,6 @@ public class TestGLReadBuffer01GLCanvasAWT extends GLReadBuffer00Base {
return canvas;
}
- private class SnapshotGLELAWT implements GLEventListener {
- final TextRendererGLEL textRendererGLEL;
- final AWTGLReadBufferUtil glReadBufferUtil;
- boolean defAutoSwapMode;
- boolean swapBuffersBeforeRead;
- int i;
-
- SnapshotGLELAWT(final TextRendererGLEL textRendererGLEL, final AWTGLReadBufferUtil glReadBufferUtil) {
- this.textRendererGLEL = textRendererGLEL;
- this.glReadBufferUtil = glReadBufferUtil;
- this.defAutoSwapMode = true;
- this.swapBuffersBeforeRead = false;
- i = 0;
- }
-
- @Override
- public void init(final GLAutoDrawable drawable) {
- defAutoSwapMode = drawable.getAutoSwapBufferMode();
- swapBuffersBeforeRead = GLDrawableUtil.swapBuffersBeforeRead(drawable.getChosenGLCapabilities());
- drawable.setAutoSwapBufferMode( !swapBuffersBeforeRead );
- }
- @Override
- public void dispose(final GLAutoDrawable drawable) {
- drawable.setAutoSwapBufferMode( defAutoSwapMode );
- }
- @Override
- public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) { }
- @Override
- public void display(final GLAutoDrawable drawable) {
- snapshot(i++, drawable.getGL(), TextureIO.PNG, null);
- }
- public void snapshot(final int sn, final GL gl, final String fileSuffix, final String destPath) {
- final GLDrawable drawable = gl.getContext().getGLReadDrawable();
- final String postSNDetail = String.format("awt-usr%03d", textRendererGLEL.userCounter);
- final String filenameAWT = getSnapshotFilename(sn, postSNDetail,
- drawable.getChosenGLCapabilities(), drawable.getSurfaceWidth(), drawable.getSurfaceHeight(),
- glReadBufferUtil.hasAlpha(), fileSuffix, destPath);
- if( swapBuffersBeforeRead ) {
- drawable.swapBuffers();
- // Just to test whether we use the right buffer,
- // i.e. back-buffer shall no more be required ..
- gl.glClear(GL.GL_COLOR_BUFFER_BIT);
- } else {
- gl.glFinish(); // just make sure rendering finished ..
- }
-
- final boolean awtOrientation = drawable.isGLOriented();
- System.err.println(Thread.currentThread().getName()+": ** screenshot: awtOrient/v-flip "+awtOrientation+", swapBuffersBeforeRead "+swapBuffersBeforeRead+", "+filenameAWT);
-
- final BufferedImage image = glReadBufferUtil.readPixelsToBufferedImage(gl, awtOrientation);
- final File fout = new File(filenameAWT);
- try {
- ImageIO.write(image, "png", fout);
- } catch (final IOException e) {
- e.printStackTrace();
- }
- /**
- final String filenameJGL = getSnapshotFilename(sn, "jgl",
- drawable.getChosenGLCapabilities(), drawable.getWidth(), drawable.getHeight(),
- glReadBufferUtil.hasAlpha(), fileSuffix, destPath);
- glReadBufferUtil.write(new File(filenameJGL));
- */
- }
- };
-
static GLCapabilitiesImmutable caps = null;
static boolean doSnapshot = true;
static boolean keyFrame = false;
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLJPanelAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLJPanelAWT.java
index 7f5755fc7..599392d0c 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLJPanelAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLJPanelAWT.java
@@ -29,15 +29,10 @@ package com.jogamp.opengl.test.junit.jogl.acore;
import java.awt.BorderLayout;
import java.awt.Dimension;
-import java.awt.image.BufferedImage;
-import java.io.File;
-import java.io.IOException;
-import javax.imageio.ImageIO;
import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilitiesImmutable;
-import javax.media.opengl.GLDrawable;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLProfile;
import javax.media.opengl.awt.GLJPanel;
@@ -50,18 +45,24 @@ import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
+import com.jogamp.common.GlueGenVersion;
+import com.jogamp.common.util.VersionUtil;
+import com.jogamp.opengl.JoglVersion;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.MultisampleDemoES2;
import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.util.Animator;
-import com.jogamp.opengl.util.GLDrawableUtil;
import com.jogamp.opengl.util.awt.AWTGLReadBufferUtil;
-import com.jogamp.opengl.util.texture.TextureIO;
/**
- * Multiple GLJPanels in a JFrame
+ * Test synchronous GLAutoDrawable display, swap-buffer and read-pixels with AWT GLJPanel
+ * including non-MSAA and MSAA framebuffer.
+ * <p>
+ * See {@link GLReadBuffer00Base} for related bugs and further details.
+ * </p>
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestGLReadBuffer01GLJPanelAWT extends GLReadBuffer00Base {
+public class TestGLReadBuffer01GLJPanelAWT extends GLReadBuffer00BaseAWT {
@BeforeClass
public static void initClass() {
@@ -85,10 +86,34 @@ public class TestGLReadBuffer01GLJPanelAWT extends GLReadBuffer00Base {
panel.setDoubleBuffered(useSwingDoubleBuffer);
frame.getContentPane().add(panel);
- final GearsES2 gears = new GearsES2(1);
- gears.setFlipVerticalInGLOrientation(skipGLOrientationVerticalFlip);
- gears.setVerbose(false);
- glad.addGLEventListener(gears);
+ glad.addGLEventListener(new GLEventListener() {
+ @Override
+ public void init(final GLAutoDrawable drawable) {
+ final GL gl = drawable.getGL();
+ System.err.println(VersionUtil.getPlatformInfo());
+ System.err.println("GLEventListener init on "+Thread.currentThread());
+ System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities());
+ System.err.println("INIT GL IS: " + gl.getClass().getName());
+ System.err.println(JoglVersion.getGLStrings(gl, null, false).toString());
+ }
+ @Override
+ public void dispose(final GLAutoDrawable drawable) {}
+ @Override
+ public void display(final GLAutoDrawable drawable) {}
+ @Override
+ public void reshape(final GLAutoDrawable drawable, final int x,final int y, final int width, final int height) {}
+ });
+ {
+ final GearsES2 gears = new GearsES2(1);
+ gears.setFlipVerticalInGLOrientation(skipGLOrientationVerticalFlip);
+ gears.setVerbose(false);
+ glad.addGLEventListener(gears);
+ }
+ {
+ final MultisampleDemoES2 demo = new MultisampleDemoES2(caps.getSampleBuffers());
+ demo.setClearBuffers(false);;
+ glad.addGLEventListener(demo);
+ }
textRendererGLEL.setFlipVerticalInGLOrientation(skipGLOrientationVerticalFlip);
glad.addGLEventListener(textRendererGLEL);
if( doSnapshot ) {
@@ -102,6 +127,9 @@ public class TestGLReadBuffer01GLJPanelAWT extends GLReadBuffer00Base {
throwable.printStackTrace();
Assume.assumeNoException( throwable );
}
+ if( keyFrame ) {
+ waitForKey("Post init: Frame# "+textRendererGLEL.frameNo);
+ }
glad.display(); // trigger initialization to get chosen-caps!
final Dimension size0 = frame.getSize();
final Dimension size1 = new Dimension(size0.width+100, size0.height+100);
@@ -166,73 +194,6 @@ public class TestGLReadBuffer01GLJPanelAWT extends GLReadBuffer00Base {
return canvas;
}
- private class SnapshotGLELAWT implements GLEventListener {
- final TextRendererGLEL textRendererGLEL;
- final AWTGLReadBufferUtil glReadBufferUtil;
- final boolean skipGLOrientationVerticalFlip;
- boolean defAutoSwapMode;
- boolean swapBuffersBeforeRead;
- int i;
-
- SnapshotGLELAWT(final TextRendererGLEL textRendererGLEL, final AWTGLReadBufferUtil glReadBufferUtil, final boolean skipGLOrientationVerticalFlip) {
- this.textRendererGLEL = textRendererGLEL;
- this.glReadBufferUtil = glReadBufferUtil;
- this.skipGLOrientationVerticalFlip = skipGLOrientationVerticalFlip;
- this.defAutoSwapMode = true;
- this.swapBuffersBeforeRead = false;
- i = 0;
- }
-
- @Override
- public void init(final GLAutoDrawable drawable) {
- defAutoSwapMode = drawable.getAutoSwapBufferMode();
- swapBuffersBeforeRead = GLDrawableUtil.swapBuffersBeforeRead(drawable.getChosenGLCapabilities());
- drawable.setAutoSwapBufferMode( !swapBuffersBeforeRead );
- }
- @Override
- public void dispose(final GLAutoDrawable drawable) {
- drawable.setAutoSwapBufferMode( defAutoSwapMode );
- }
- @Override
- public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) { }
- @Override
- public void display(final GLAutoDrawable drawable) {
- snapshot(i++, drawable.getGL(), TextureIO.PNG, null);
- }
- public void snapshot(final int sn, final GL gl, final String fileSuffix, final String destPath) {
- final GLDrawable drawable = gl.getContext().getGLReadDrawable();
- final String postSNDetail = String.format("awt-usr%03d", textRendererGLEL.userCounter);
- final String filenameAWT = getSnapshotFilename(sn, postSNDetail,
- drawable.getChosenGLCapabilities(), drawable.getSurfaceWidth(), drawable.getSurfaceHeight(),
- glReadBufferUtil.hasAlpha(), fileSuffix, destPath);
- if( swapBuffersBeforeRead ) {
- drawable.swapBuffers();
- // Just to test whether we use the right buffer,
- // i.e. back-buffer shall no more be required ..
- gl.glClear(GL.GL_COLOR_BUFFER_BIT);
- } else {
- gl.glFinish(); // just make sure rendering finished ..
- }
-
- final boolean awtOrientation = !( drawable.isGLOriented() && skipGLOrientationVerticalFlip );
- System.err.println(Thread.currentThread().getName()+": ** screenshot: awtOrient/v-flip "+awtOrientation+", swapBuffersBeforeRead "+swapBuffersBeforeRead+", "+filenameAWT);
-
- final BufferedImage image = glReadBufferUtil.readPixelsToBufferedImage(gl, awtOrientation);
- final File fout = new File(filenameAWT);
- try {
- ImageIO.write(image, "png", fout);
- } catch (final IOException e) {
- e.printStackTrace();
- }
- /**
- final String filenameJGL = getSnapshotFilename(sn, "jgl",
- drawable.getChosenGLCapabilities(), drawable.getWidth(), drawable.getHeight(),
- glReadBufferUtil.hasAlpha(), fileSuffix, destPath);
- glReadBufferUtil.write(new File(filenameJGL));
- */
- }
- };
-
static GLCapabilitiesImmutable caps = null;
static boolean doSnapshot = true;
static boolean keyFrame = false;
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLWindowNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLWindowNEWT.java
index 8e0e6bfb9..4da73dbca 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLWindowNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLWindowNEWT.java
@@ -42,8 +42,11 @@ import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
+import com.jogamp.common.util.VersionUtil;
import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.JoglVersion;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.MultisampleDemoES2;
import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.util.GLDrawableUtil;
@@ -51,7 +54,11 @@ import com.jogamp.opengl.util.GLReadBufferUtil;
import com.jogamp.opengl.util.texture.TextureIO;
/**
- * Multiple GLJPanels in a JFrame
+ * Test synchronous GLAutoDrawable display, swap-buffer and read-pixels with NEWT
+ * including non-MSAA and MSAA framebuffer.
+ * <p>
+ * See {@link GLReadBuffer00Base} for related bugs and further details.
+ * </p>
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestGLReadBuffer01GLWindowNEWT extends GLReadBuffer00Base {
@@ -73,9 +80,33 @@ public class TestGLReadBuffer01GLWindowNEWT extends GLReadBuffer00Base {
try {
glad.setPosition(64, 64);
glad.setSize(320, 240);
- final GearsES2 gears = new GearsES2(1);
- gears.setVerbose(false);
- glad.addGLEventListener(gears);
+ glad.addGLEventListener(new GLEventListener() {
+ @Override
+ public void init(final GLAutoDrawable drawable) {
+ final GL gl = drawable.getGL();
+ System.err.println(VersionUtil.getPlatformInfo());
+ System.err.println("GLEventListener init on "+Thread.currentThread());
+ System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities());
+ System.err.println("INIT GL IS: " + gl.getClass().getName());
+ System.err.println(JoglVersion.getGLStrings(gl, null, false).toString());
+ }
+ @Override
+ public void dispose(final GLAutoDrawable drawable) {}
+ @Override
+ public void display(final GLAutoDrawable drawable) {}
+ @Override
+ public void reshape(final GLAutoDrawable drawable, final int x,final int y, final int width, final int height) {}
+ });
+ {
+ final GearsES2 gears = new GearsES2(1);
+ gears.setVerbose(false);
+ glad.addGLEventListener(gears);
+ }
+ {
+ final MultisampleDemoES2 demo = new MultisampleDemoES2(caps.getSampleBuffers());
+ demo.setClearBuffers(false);;
+ glad.addGLEventListener(demo);
+ }
textRendererGLEL.setFlipVerticalInGLOrientation(skipGLOrientationVerticalFlip);
glad.addGLEventListener(textRendererGLEL);
if( doSnapshot ) {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGPUMemSec01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGPUMemSec01NEWT.java
index 1f9e6e877..aabd4821d 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGPUMemSec01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGPUMemSec01NEWT.java
@@ -61,8 +61,10 @@ public class TestGPUMemSec01NEWT extends UITestCase {
}
static NEWTGLContext.WindowContext createCurrentGLOffscreenWindow(final GLProfile glp, final int width, final int height) throws GLException, InterruptedException {
- final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOffscreenWindow(
- new GLCapabilities(glp), width, height, true);
+ final GLCapabilities caps = new GLCapabilities(glp);
+ caps.setOnscreen(false);
+ final NEWTGLContext.WindowContext winctx = NEWTGLContext.createWindow(
+ caps, width, height, true);
final GL gl = winctx.context.getGL();
// System.err.println("Pre GL Error: 0x"+Integer.toHexString(gl.glGetError()));
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestInitConcurrent01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestInitConcurrent01NEWT.java
index 2fc3071c6..a3c5d44cd 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestInitConcurrent01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestInitConcurrent01NEWT.java
@@ -30,6 +30,8 @@ package com.jogamp.opengl.test.junit.jogl.acore;
import java.io.IOException;
+import javax.media.opengl.GLProfile;
+
import org.junit.Test;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
@@ -42,6 +44,10 @@ import com.jogamp.common.os.Platform;
* Rendering is always lock-free and independent of the EDT, however shared NEWT Display instances
* perform lifecycle actions (window creation etc) with locking.
* </p>
+ * <p>
+ * Each test is decorated w/ {@link GLProfile#shutdown()} to ensure that
+ * implicit {@link GLProfile#initSingleton()} is also being tested.
+ * </p>
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestInitConcurrent01NEWT extends InitConcurrentBaseNEWT {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestInitConcurrent02NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestInitConcurrent02NEWT.java
index 71796e5c2..5cbf15b57 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestInitConcurrent02NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestInitConcurrent02NEWT.java
@@ -30,6 +30,8 @@ package com.jogamp.opengl.test.junit.jogl.acore;
import java.io.IOException;
+import javax.media.opengl.GLProfile;
+
import org.junit.Test;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
@@ -39,9 +41,13 @@ import com.jogamp.common.os.Platform;
/**
* Concurrent and lock-free initialization and rendering using exclusive NEWT Display EDT instances.
* <p>
- * Rendering is always lock-free and independent of the EDT, however exclusive NEWT Display instances
+ * Rendering is always lock-free and independent of the EDT, using exclusive NEWT Display instances
* perform lifecycle actions (window creation etc) w/o locking.
* </p>
+ * <p>
+ * Each test is decorated w/ {@link GLProfile#shutdown()} to ensure that
+ * implicit {@link GLProfile#initSingleton()} is also being tested.
+ * </p>
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestInitConcurrent02NEWT extends InitConcurrentBaseNEWT {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMapBufferRead01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMapBufferRead01NEWT.java
index d94c24af0..5ba0c7794 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMapBufferRead01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMapBufferRead01NEWT.java
@@ -99,8 +99,10 @@ public class TestMapBufferRead01NEWT extends UITestCase {
private void testWriteRead01(final ByteBuffer verticiesBB, final boolean useRange) throws InterruptedException {
final GLProfile glp = GLProfile.getMaxProgrammable(true);
- final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOffscreenWindow(
- new GLCapabilities(glp), 800, 600, true);
+ final GLCapabilities caps = new GLCapabilities(glp);
+ caps.setOnscreen(false);
+ final NEWTGLContext.WindowContext winctx = NEWTGLContext.createWindow(
+ caps, 800, 600, true);
try {
final GL gl = winctx.context.getGL();
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextNewtAWTBug523.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextNewtAWTBug523.java
index 11ca64258..d3cdf5e95 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextNewtAWTBug523.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextNewtAWTBug523.java
@@ -79,7 +79,6 @@ import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.test.junit.util.AWTRobotUtil.WindowClosingListener;
import com.jogamp.opengl.util.Animator;
-import com.jogamp.opengl.util.GLBuffers;
/**
@@ -819,19 +818,7 @@ public class TestSharedContextNewtAWTBug523 extends UITestCase {
}
}
}
-
- final String testname = TestSharedContextNewtAWTBug523.class.getName();
- org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(new String[] {
- testname,
- "filtertrace=true",
- "haltOnError=false",
- "haltOnFailure=false",
- "showoutput=true",
- "outputtoformatters=true",
- "logfailedtests=true",
- "logtestlistenerevents=true",
- "formatter=org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter",
- "formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,TEST-"+testname+".xml" } );
+ org.junit.runner.JUnitCore.main(TestSharedContextNewtAWTBug523.class.getName());
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java
index 8f84e293d..f1c72cf57 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java
@@ -138,12 +138,13 @@ public class TestSharedContextVBOES1NEWT extends UITestCase {
Assert.assertTrue(AWTRobotUtil.waitForVisible(glWindow, true));
Assert.assertTrue(AWTRobotUtil.waitForContextCreated(glWindow, true));
- System.err.println("Master Context: ");
- MiscUtils.dumpSharedGLContext(sharedDrawable.getContext());
- System.err.println("New Context: ");
- MiscUtils.dumpSharedGLContext(glWindow.getContext());
+ MiscUtils.dumpSharedGLContext("Master Context", sharedDrawable.getContext());
+ MiscUtils.dumpSharedGLContext("New Context", glWindow.getContext());
if( useShared ) {
Assert.assertEquals("Master Context not shared as expected", true, sharedDrawable.getContext().isShared());
+ Assert.assertEquals("Master Context is different", sharedDrawable.getContext(), glWindow.getContext().getSharedMaster());
+ } else {
+
}
Assert.assertEquals("New Context not shared as expected", useShared, glWindow.getContext().isShared());
Assert.assertEquals("Gears is not shared as expected", useShared, gears.usesSharedGears());
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java
index a5b5653c0..fcbfcb19b 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java
@@ -157,12 +157,9 @@ public class TestSharedContextVBOES2AWT3 extends UITestCase {
final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
- System.err.println("XXX-C-3.1:");
- MiscUtils.dumpSharedGLContext(ctx1);
- System.err.println("XXX-C-3.2:");
- MiscUtils.dumpSharedGLContext(ctx2);
- System.err.println("XXX-C-3.3:");
- MiscUtils.dumpSharedGLContext(ctx3);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.1", ctx1);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.2", ctx2);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.3", ctx3);
Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
@@ -307,12 +304,9 @@ public class TestSharedContextVBOES2AWT3 extends UITestCase {
final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
- System.err.println("XXX-C-3.1:");
- MiscUtils.dumpSharedGLContext(ctx1);
- System.err.println("XXX-C-3.2:");
- MiscUtils.dumpSharedGLContext(ctx2);
- System.err.println("XXX-C-3.3:");
- MiscUtils.dumpSharedGLContext(ctx3);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.1", ctx1);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.2", ctx2);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.3", ctx3);
Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3b.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3b.java
index 4c9cb7253..bac84d4fb 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3b.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3b.java
@@ -148,12 +148,9 @@ public class TestSharedContextVBOES2AWT3b extends UITestCase {
final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
- System.err.println("XXX-C-3.1:");
- MiscUtils.dumpSharedGLContext(ctx1);
- System.err.println("XXX-C-3.2:");
- MiscUtils.dumpSharedGLContext(ctx2);
- System.err.println("XXX-C-3.3:");
- MiscUtils.dumpSharedGLContext(ctx3);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.1", ctx1);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.2", ctx2);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.3", ctx3);
Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
@@ -260,12 +257,9 @@ public class TestSharedContextVBOES2AWT3b extends UITestCase {
final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
- System.err.println("XXX-C-3.1:");
- MiscUtils.dumpSharedGLContext(ctx1);
- System.err.println("XXX-C-3.2:");
- MiscUtils.dumpSharedGLContext(ctx2);
- System.err.println("XXX-C-3.3:");
- MiscUtils.dumpSharedGLContext(ctx3);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.1", ctx1);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.2", ctx2);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.3", ctx3);
Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT0.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT0.java
index d2d1384e4..eeab0869a 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT0.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT0.java
@@ -122,8 +122,7 @@ public class TestSharedContextVBOES2NEWT0 extends UITestCase {
Assert.assertTrue("Ctx is shared before shared creation", !ctx1.isShared());
final InsetsImmutable insets = f1.getInsets();
- System.err.println("XXX-C-2.1:");
- MiscUtils.dumpSharedGLContext(ctx1);
+ MiscUtils.dumpSharedGLContext("XXX-C-1.1", ctx1);
//
// 2nd
@@ -139,10 +138,8 @@ public class TestSharedContextVBOES2NEWT0 extends UITestCase {
{
final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
- System.err.println("XXX-C-2.1:");
- MiscUtils.dumpSharedGLContext(ctx1);
- System.err.println("XXX-C-2.2:");
- MiscUtils.dumpSharedGLContext(ctx2);
+ MiscUtils.dumpSharedGLContext("XXX-C-2.1", ctx1);
+ MiscUtils.dumpSharedGLContext("XXX-C-2.2", ctx2);
Assert.assertEquals("Ctx1 has unexpected number of created shares", 1, ctx1Shares.size());
Assert.assertEquals("Ctx2 has unexpected number of created shares", 1, ctx2Shares.size());
@@ -165,12 +162,9 @@ public class TestSharedContextVBOES2NEWT0 extends UITestCase {
final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
- System.err.println("XXX-C-3.1:");
- MiscUtils.dumpSharedGLContext(ctx1);
- System.err.println("XXX-C-3.2:");
- MiscUtils.dumpSharedGLContext(ctx2);
- System.err.println("XXX-C-3.3:");
- MiscUtils.dumpSharedGLContext(ctx3);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.1", ctx1);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.2", ctx2);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.3", ctx3);
Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size());
Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size());
@@ -197,12 +191,9 @@ public class TestSharedContextVBOES2NEWT0 extends UITestCase {
final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
- System.err.println("XXX-D-0.1:");
- MiscUtils.dumpSharedGLContext(ctx1);
- System.err.println("XXX-D-0.2:");
- MiscUtils.dumpSharedGLContext(ctx2);
- System.err.println("XXX-D-0.3:");
- MiscUtils.dumpSharedGLContext(ctx3);
+ MiscUtils.dumpSharedGLContext("XXX-D-0.1", ctx1);
+ MiscUtils.dumpSharedGLContext("XXX-D-0.2", ctx2);
+ MiscUtils.dumpSharedGLContext("XXX-D-0.3", ctx3);
Assert.assertTrue("Ctx1 is shared", ctx1.isShared());
Assert.assertTrue("Ctx2 is shared", ctx2.isShared());
@@ -221,12 +212,9 @@ public class TestSharedContextVBOES2NEWT0 extends UITestCase {
final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
- System.err.println("XXX-D-1.1:");
- MiscUtils.dumpSharedGLContext(ctx1);
- System.err.println("XXX-D-1.2:");
- MiscUtils.dumpSharedGLContext(ctx2);
- System.err.println("XXX-D-1.3:");
- MiscUtils.dumpSharedGLContext(ctx3);
+ MiscUtils.dumpSharedGLContext("XXX-D-1.1", ctx1);
+ MiscUtils.dumpSharedGLContext("XXX-D-1.2", ctx2);
+ MiscUtils.dumpSharedGLContext("XXX-D-1.3", ctx3);
Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
@@ -245,12 +233,9 @@ public class TestSharedContextVBOES2NEWT0 extends UITestCase {
final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
- System.err.println("XXX-D-2.1:");
- MiscUtils.dumpSharedGLContext(ctx1);
- System.err.println("XXX-D-2.2:");
- MiscUtils.dumpSharedGLContext(ctx2);
- System.err.println("XXX-D-2.3:");
- MiscUtils.dumpSharedGLContext(ctx3);
+ MiscUtils.dumpSharedGLContext("XXX-D-2.1", ctx1);
+ MiscUtils.dumpSharedGLContext("XXX-D-2.2", ctx2);
+ MiscUtils.dumpSharedGLContext("XXX-D-2.3", ctx3);
Assert.assertTrue("Ctx1 is not shared", !ctx1.isShared());
Assert.assertTrue("Ctx2 is not shared", !ctx2.isShared());
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT1.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT1.java
index fb15509d0..e98957464 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT1.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT1.java
@@ -153,12 +153,14 @@ public class TestSharedContextVBOES2NEWT1 extends UITestCase {
Assert.assertTrue(AWTRobotUtil.waitForVisible(glWindow, true));
Assert.assertTrue(AWTRobotUtil.waitForContextCreated(glWindow, true));
- System.err.println("Master Context: ");
- MiscUtils.dumpSharedGLContext(sharedDrawable.getContext());
- System.err.println("New Context: ");
- MiscUtils.dumpSharedGLContext(glWindow.getContext());
+ final GLContext sharedMasterContext = sharedDrawable.getContext();
+ MiscUtils.dumpSharedGLContext("Master Context", sharedMasterContext);
+ MiscUtils.dumpSharedGLContext("New Context", glWindow.getContext());
if( useShared ) {
- Assert.assertEquals("Master Context not shared as expected", true, sharedDrawable.getContext().isShared());
+ Assert.assertEquals("Master Context not shared as expected", true, sharedMasterContext.isShared());
+ Assert.assertEquals("Master Context is different", sharedMasterContext, glWindow.getContext().getSharedMaster());
+ } else {
+ Assert.assertEquals("Master Context is not null", null, glWindow.getContext().getSharedMaster());
}
Assert.assertEquals("New Context not shared as expected", useShared, glWindow.getContext().isShared());
@@ -169,7 +171,7 @@ public class TestSharedContextVBOES2NEWT1 extends UITestCase {
return glWindow;
}
- @Test
+ // @Test
public void test01CommonAnimatorSharedOnscreen() throws InterruptedException {
initShared(true);
final Animator animator = new Animator();
@@ -202,7 +204,7 @@ public class TestSharedContextVBOES2NEWT1 extends UITestCase {
releaseShared();
}
- @Test
+ // @Test
public void test02CommonAnimatorSharedOffscreen() throws InterruptedException {
initShared(false);
final Animator animator = new Animator();
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java
index a101c05d0..fb09e86ef 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java
@@ -55,9 +55,8 @@ import org.junit.runners.MethodSorters;
* Sharing the VBO of 3 GearsES2 instances, each in their own GLWindow.
* <p>
* This is achieved by using the 1st GLWindow's GLContext as the <i>master</i>
- * and manually triggering creation of the 2nd and 3rd GLWindow when the 1st GLWindow's
- * GLContext becomes created. The trigger is performed by simply
- * inserting a GLRunnable in the 1st GLWindow, which makes the other visible.
+ * and synchronizing via GLSharedContextSetter to postpone creation
+ * of the 2nd and 3rd GLWindow until the 1st GLWindow's GLContext becomes created.
* </p>
* <p>
* Above method allows random creation of the 1st GLWindow, which triggers
@@ -107,6 +106,8 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase {
public void syncedOneAnimator(final boolean destroyCleanOrder) throws InterruptedException {
final Animator animator = new Animator();
+ animator.start();
+
final GearsES2 g1 = new GearsES2(0);
final GLWindow f1 = createGLWindow(0, 0, g1);
animator.add(f1);
@@ -116,31 +117,31 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase {
g2.setSharedGears(g1);
final GLWindow f2 = createGLWindow(f1.getX()+width+insets.getTotalWidth(),
f1.getY()+0, g2);
+ f2.setSharedAutoDrawable(f1);
animator.add(f2);
+ f2.setVisible(true);
final GearsES2 g3 = new GearsES2(0);
g3.setSharedGears(g1);
final GLWindow f3 = createGLWindow(f1.getX()+0,
f1.getY()+height+insets.getTotalHeight(), g3);
+ f3.setSharedAutoDrawable(f1);
animator.add(f3);
+ f3.setVisible(true);
- // f1's shared GLContext is ready !
- f1.invoke(false, new GLRunnable() {
- @Override
- public boolean run(final GLAutoDrawable drawable) {
- Assert.assertTrue("Ctx is shared before shared creation", !f1.getContext().isShared());
- f2.setSharedAutoDrawable(f1);
- f2.setVisible(true);
- f2.display(); // kick off GLContext ..
- f3.setSharedAutoDrawable(f1);
- f3.setVisible(true);
- f3.display(); // kick off GLContext ..
- return true;
- }
- });
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f1, false));
- f1.setVisible(true);
- f1.display(); // kick off GLContext .. and hence f2 + f3 creation
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f2, false));
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, true));
+ Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f3, false));
+
+ f1.setVisible(true); // kick off f1 GLContext .. and hence allow f2 + f3 creation
Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, true));
Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, true));
@@ -157,8 +158,6 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase {
Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f3, true));
Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true));
- animator.start(); // post start animator, otherwise display will be suppressed
-
final GLContext ctx1 = f1.getContext();
final GLContext ctx2 = f2.getContext();
final GLContext ctx3 = f3.getContext();
@@ -166,12 +165,9 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase {
final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
- System.err.println("XXX-C-3.1:");
- MiscUtils.dumpSharedGLContext(ctx1);
- System.err.println("XXX-C-3.2:");
- MiscUtils.dumpSharedGLContext(ctx2);
- System.err.println("XXX-C-3.3:");
- MiscUtils.dumpSharedGLContext(ctx3);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.1", ctx1);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.2", ctx2);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.3", ctx3);
Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
@@ -179,6 +175,9 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase {
Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size());
Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size());
Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size());
+ Assert.assertEquals("Ctx1 Master Context is different", ctx1, ctx1.getSharedMaster());
+ Assert.assertEquals("Ctx2 Master Context is different", ctx1, ctx2.getSharedMaster());
+ Assert.assertEquals("Ctx3 Master Context is different", ctx1, ctx3.getSharedMaster());
}
Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears());
@@ -228,7 +227,6 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase {
final GLWindow f1 = createGLWindow(0, 0, g1);
a1.add(f1);
a1.start();
- f1.setVisible(true);
final InsetsImmutable insets = f1.getInsets();
@@ -237,29 +235,34 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase {
g2.setSharedGears(g1);
final GLWindow f2 = createGLWindow(f1.getX()+width+insets.getTotalWidth(),
f1.getY()+0, g2);
+ f2.setSharedAutoDrawable(f1);
a2.add(f2);
a2.start();
+ f2.setVisible(true);
final Animator a3 = new Animator();
final GearsES2 g3 = new GearsES2(0);
g3.setSharedGears(g1);
final GLWindow f3 = createGLWindow(f1.getX()+0,
f1.getY()+height+insets.getTotalHeight(), g3);
+ f3.setSharedAutoDrawable(f1);
a3.add(f3);
a3.start();
+ f3.setVisible(true);
- // f1's shared GLContext is ready !
- f1.invoke(false, new GLRunnable() {
- @Override
- public boolean run(final GLAutoDrawable drawable) {
- Assert.assertTrue("Ctx is shared before shared creation", !f1.getContext().isShared());
- f2.setSharedAutoDrawable(f1);
- f2.setVisible(true);
- f3.setSharedAutoDrawable(f1);
- f3.setVisible(true);
- return true;
- }
- });
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f1, false));
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f2, false));
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, true));
+ Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f3, false));
+
+ f1.setVisible(true); // kicks off f1 GLContext .. and hence gears of f2 + f3 completion
Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, true));
Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, true));
@@ -282,12 +285,9 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase {
final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
- System.err.println("XXX-C-3.1:");
- MiscUtils.dumpSharedGLContext(ctx1);
- System.err.println("XXX-C-3.2:");
- MiscUtils.dumpSharedGLContext(ctx2);
- System.err.println("XXX-C-3.3:");
- MiscUtils.dumpSharedGLContext(ctx3);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.1", ctx1);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.2", ctx2);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.3", ctx3);
Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
@@ -295,6 +295,9 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase {
Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size());
Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size());
Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size());
+ Assert.assertEquals("Ctx1 Master Context is different", ctx1, ctx1.getSharedMaster());
+ Assert.assertEquals("Ctx2 Master Context is different", ctx1, ctx2.getSharedMaster());
+ Assert.assertEquals("Ctx3 Master Context is different", ctx1, ctx3.getSharedMaster());
}
Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears());
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT3.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT3.java
index bfd1a92ce..852b7193e 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT3.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT3.java
@@ -53,7 +53,7 @@ import org.junit.runners.MethodSorters;
* Sharing the VBO of 3 GearsES2 instances, each in their own GLWindow.
* <p>
* This is achieved by using the 1st GLWindow as the <i>master</i>
- * and using the build-in blocking mechanism to postpone creation
+ * and synchronizing via GLSharedContextSetter to postpone creation
* of the 2nd and 3rd GLWindow until the 1st GLWindow's GLContext becomes created.
* </p>
* <p>
@@ -112,6 +112,8 @@ public class TestSharedContextVBOES2NEWT3 extends UITestCase {
public void syncedOneAnimator(final boolean destroyCleanOrder, final boolean useMappedBuffers) throws InterruptedException {
final Animator animator = new Animator();
+ animator.start();
+
final GearsES2 g1 = new GearsES2(0);
g1.setUseMappedBuffers(useMappedBuffers);
g1.setValidateBuffers(true);
@@ -125,20 +127,17 @@ public class TestSharedContextVBOES2NEWT3 extends UITestCase {
f1.getY()+0, g2);
f2.setSharedAutoDrawable(f1);
animator.add(f2);
+ f2.setVisible(true); // shall wait until f1 is ready
- final GearsES2 g3 = new GearsES2(0);
- g3.setSharedGears(g1);
- final GLWindow f3 = createGLWindow(f1.getX()+0,
- f1.getY()+height+insets.getTotalHeight(), g3);
- f3.setSharedAutoDrawable(f1);
- animator.add(f3);
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f1, false));
- f2.setVisible(true); // shall wait until f1 is ready
- f1.setVisible(true); // master ..
- f3.setVisible(true); // shall wait until f1 is ready
- animator.start(); // kicks off GLContext .. and hence gears of f2 + f3 completion
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f2, false));
- Thread.sleep(1000/60*10); // wait ~10 frames giving a chance to create (blocking until master share is valid)
+ f1.setVisible(true); // kicks off f1 GLContext .. and hence gears of f2 + f3 completion
Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, true));
Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, true));
@@ -150,6 +149,14 @@ public class TestSharedContextVBOES2NEWT3 extends UITestCase {
Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f2, true));
Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true));
+ final GearsES2 g3 = new GearsES2(0);
+ g3.setSharedGears(g1);
+ final GLWindow f3 = createGLWindow(f1.getX()+0,
+ f1.getY()+height+insets.getTotalHeight(), g3);
+ f3.setSharedAutoDrawable(f1);
+ animator.add(f3);
+ f3.setVisible(true); // shall wait until f1 is ready
+
Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, true));
Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, true));
Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f3, true));
@@ -162,12 +169,9 @@ public class TestSharedContextVBOES2NEWT3 extends UITestCase {
final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
- System.err.println("XXX-C-3.1:");
- MiscUtils.dumpSharedGLContext(ctx1);
- System.err.println("XXX-C-3.2:");
- MiscUtils.dumpSharedGLContext(ctx2);
- System.err.println("XXX-C-3.3:");
- MiscUtils.dumpSharedGLContext(ctx3);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.1", ctx1);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.2", ctx2);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.3", ctx3);
Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
@@ -175,6 +179,9 @@ public class TestSharedContextVBOES2NEWT3 extends UITestCase {
Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size());
Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size());
Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size());
+ Assert.assertEquals("Ctx1 Master Context is different", ctx1, ctx1.getSharedMaster());
+ Assert.assertEquals("Ctx2 Master Context is different", ctx1, ctx2.getSharedMaster());
+ Assert.assertEquals("Ctx3 Master Context is different", ctx1, ctx3.getSharedMaster());
}
Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears());
@@ -246,7 +253,6 @@ public class TestSharedContextVBOES2NEWT3 extends UITestCase {
final GLWindow f1 = createGLWindow(0, 0, g1);
a1.add(f1);
a1.start();
- // f1.setVisible(true); // we do this post f2 .. to test pending creation!
final InsetsImmutable insets = f1.getInsets();
@@ -260,19 +266,15 @@ public class TestSharedContextVBOES2NEWT3 extends UITestCase {
a2.start();
f2.setVisible(true);
- f1.setVisible(true); // test pending creation of f2
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f1, false));
- final Animator a3 = new Animator();
- final GearsES2 g3 = new GearsES2(0);
- g3.setSharedGears(g1);
- final GLWindow f3 = createGLWindow(f1.getX()+0,
- f1.getY()+height+insets.getTotalHeight(), g3);
- f3.setSharedAutoDrawable(f1);
- a3.add(f3);
- a3.start();
- f3.setVisible(true);
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f2, false));
- Thread.sleep(1000/60*10); // wait ~10 frames giving a chance to create (blocking until master share is valid)
+ f1.setVisible(true); // test pending creation of f2
Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, true));
Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, true));
@@ -284,6 +286,16 @@ public class TestSharedContextVBOES2NEWT3 extends UITestCase {
Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f2, true));
Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true));
+ final Animator a3 = new Animator();
+ final GearsES2 g3 = new GearsES2(0);
+ g3.setSharedGears(g1);
+ final GLWindow f3 = createGLWindow(f1.getX()+0,
+ f1.getY()+height+insets.getTotalHeight(), g3);
+ f3.setSharedAutoDrawable(f1);
+ a3.add(f3);
+ a3.start();
+ f3.setVisible(true);
+
Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, true));
Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, true));
Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f3, true));
@@ -296,12 +308,9 @@ public class TestSharedContextVBOES2NEWT3 extends UITestCase {
final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
- System.err.println("XXX-C-3.1:");
- MiscUtils.dumpSharedGLContext(ctx1);
- System.err.println("XXX-C-3.2:");
- MiscUtils.dumpSharedGLContext(ctx2);
- System.err.println("XXX-C-3.3:");
- MiscUtils.dumpSharedGLContext(ctx3);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.1", ctx1);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.2", ctx2);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.3", ctx3);
Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
@@ -309,6 +318,9 @@ public class TestSharedContextVBOES2NEWT3 extends UITestCase {
Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size());
Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size());
Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size());
+ Assert.assertEquals("Ctx1 Master Context is different", ctx1, ctx1.getSharedMaster());
+ Assert.assertEquals("Ctx2 Master Context is different", ctx1, ctx2.getSharedMaster());
+ Assert.assertEquals("Ctx3 Master Context is different", ctx1, ctx3.getSharedMaster());
}
Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears());
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT4.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT4.java
new file mode 100644
index 000000000..804badbc3
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT4.java
@@ -0,0 +1,231 @@
+/**
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.opengl.test.junit.jogl.acore;
+
+import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import com.jogamp.newt.opengl.GLWindow;
+
+import javax.media.nativewindow.util.InsetsImmutable;
+import javax.media.opengl.GLAnimatorControl;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLProfile;
+
+import com.jogamp.opengl.util.Animator;
+import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.FixMethodOrder;
+import org.junit.runners.MethodSorters;
+
+/**
+ * Test sharing w/ different shared-master context.
+ * <p>
+ * This is achieved by using the 1st GLWindow as the <i>master</i>
+ * and synchronizing via GLSharedContextSetter to postpone creation
+ * of the 2nd and 3rd GLWindow until the 1st GLWindow's GLContext becomes created.
+ * </p>
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestSharedContextVBOES2NEWT4 extends UITestCase {
+ static GLProfile glp;
+ static GLCapabilities caps;
+ static int width, height;
+
+ @BeforeClass
+ public static void initClass() {
+ if(GLProfile.isAvailable(GLProfile.GL2ES2)) {
+ glp = GLProfile.get(GLProfile.GL2ES2);
+ Assert.assertNotNull(glp);
+ caps = new GLCapabilities(glp);
+ Assert.assertNotNull(caps);
+ width = 256;
+ height = 256;
+ } else {
+ setTestSupported(false);
+ }
+ }
+
+ protected GLWindow createGLWindow(final int x, final int y, final GearsES2 gears) throws InterruptedException {
+ final GLWindow glWindow = GLWindow.create(caps);
+ Assert.assertNotNull(glWindow);
+ glWindow.setPosition(x, y);
+ glWindow.setTitle("Shared Gears NEWT Test: "+x+"/"+y+" shared true");
+ glWindow.setSize(width, height);
+ glWindow.addGLEventListener(gears);
+
+ return glWindow;
+ }
+
+ @Test
+ public void test01() throws InterruptedException {
+ final Animator animator = new Animator();
+ animator.start();
+
+ final GearsES2 g1 = new GearsES2(0);
+ final GLWindow f1 = createGLWindow(0, 0, g1);
+ animator.add(f1);
+ final InsetsImmutable insets = f1.getInsets();
+
+ final GearsES2 g2 = new GearsES2(0);
+ g2.setSharedGears(g1);
+ final GLWindow f2 = createGLWindow(f1.getX()+width+insets.getTotalWidth(),
+ f1.getY()+0, g2);
+ f2.setSharedAutoDrawable(f1);
+ animator.add(f2);
+ f2.setVisible(true);
+
+ final GearsES2 g3 = new GearsES2(0);
+ g3.setSharedGears(g1);
+ final GLWindow f3 = createGLWindow(f1.getX()+0,
+ f1.getY()+height+insets.getTotalHeight(), g3);
+ f3.setSharedAutoDrawable(f2); // Mixed master!
+ animator.add(f3);
+ final AtomicBoolean gotAnimException = new AtomicBoolean(false);
+ final AtomicBoolean gotOtherException = new AtomicBoolean(false);
+ animator.setUncaughtExceptionHandler(new GLAnimatorControl.UncaughtExceptionHandler() {
+ @Override
+ public void uncaughtException(final GLAnimatorControl _animator, final GLAutoDrawable _drawable, final Throwable _cause) {
+ if( _animator == animator && _drawable == f3 && _cause instanceof RuntimeException ) {
+ System.err.println("Caught expected exception: "+_cause.getMessage());
+ gotAnimException.set(true);
+ } else {
+ System.err.println("Caught unexpected exception: "+_cause.getMessage());
+ _cause.printStackTrace();
+ gotOtherException.set(true);
+ }
+ }
+ });
+ f3.setVisible(true);
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f1, false));
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f2, false));
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, true));
+ Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f3, false));
+
+ f1.setVisible(true); // kick off f1 GLContext .. and hence allow f2 + f3 creation
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, true));
+ Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f1, true));
+ Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true));
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f2, true));
+ Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true));
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, true));
+ Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f3, true));
+ Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true));
+
+ Assert.assertFalse("Unexpected exception (animator) caught", gotAnimException.get());
+ Assert.assertFalse("Unexpected exception (other) caught", gotOtherException.get());
+
+ final GLContext ctx1 = f1.getContext();
+ final GLContext ctx2 = f2.getContext();
+ final GLContext ctx3 = f3.getContext();
+ {
+ final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
+ final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
+ final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
+ MiscUtils.dumpSharedGLContext("XXX-C-3.1", ctx1);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.2", ctx2);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.3", ctx3);
+
+ Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
+ Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
+ Assert.assertTrue("Ctx3 is not shared", ctx3.isShared());
+ Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size());
+ Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size());
+ Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size());
+ Assert.assertEquals("Ctx1 Master Context is different", ctx1, ctx1.getSharedMaster());
+ Assert.assertEquals("Ctx2 Master Context is different", ctx1, ctx2.getSharedMaster());
+ Assert.assertEquals("Ctx3 Master Context is different", ctx2, ctx3.getSharedMaster()); // Mixed master!
+ }
+
+ Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears());
+ Assert.assertTrue("Gears2 is not shared", g2.usesSharedGears());
+ Assert.assertTrue("Gears3 is not shared", g3.usesSharedGears());
+
+ try {
+ Thread.sleep(duration);
+ } catch(final Exception e) {
+ e.printStackTrace();
+ }
+ animator.stop();
+ Assert.assertEquals(false, animator.isAnimating());
+
+ System.err.println("XXX Destroy in clean order NOW");
+ f3.destroy();
+ f2.destroy();
+ f1.destroy();
+
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false));
+ }
+
+ static long duration = 1000; // ms
+
+ public static void main(final String args[]) {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ try {
+ duration = Integer.parseInt(args[i]);
+ } catch (final Exception ex) { ex.printStackTrace(); }
+ }
+ }
+ /**
+ BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
+ System.err.println("Press enter to continue");
+ System.err.println(stdin.readLine()); */
+ org.junit.runner.JUnitCore.main(TestSharedContextVBOES2NEWT4.class.getName());
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2SWT3.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2SWT3.java
index 90cb503ce..09f4408f1 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2SWT3.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2SWT3.java
@@ -220,12 +220,9 @@ public class TestSharedContextVBOES2SWT3 extends UITestCase {
final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
- System.err.println("XXX-C-3.1:");
- MiscUtils.dumpSharedGLContext(ctx1);
- System.err.println("XXX-C-3.2:");
- MiscUtils.dumpSharedGLContext(ctx2);
- System.err.println("XXX-C-3.3:");
- MiscUtils.dumpSharedGLContext(ctx3);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.1", ctx1);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.2", ctx2);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.3", ctx3);
Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
@@ -314,12 +311,9 @@ public class TestSharedContextVBOES2SWT3 extends UITestCase {
final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
- System.err.println("XXX-C-3.1:");
- MiscUtils.dumpSharedGLContext(ctx1);
- System.err.println("XXX-C-3.2:");
- MiscUtils.dumpSharedGLContext(ctx2);
- System.err.println("XXX-C-3.3:");
- MiscUtils.dumpSharedGLContext(ctx3);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.1", ctx1);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.2", ctx2);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.2", ctx3);
Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestVersionSemanticsNOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestVersionSemanticsNOUI.java
index 6f38c4b2f..0c2a7510b 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestVersionSemanticsNOUI.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestVersionSemanticsNOUI.java
@@ -37,7 +37,6 @@ import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import org.osjava.jardiff.DiffCriteria;
-import org.osjava.jardiff.SimpleDiffCriteria;
import org.semver.Delta;
import com.jogamp.common.util.JogampVersion;
@@ -49,39 +48,48 @@ import com.jogamp.opengl.JoglVersion;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestVersionSemanticsNOUI extends JunitTracer {
static final String jarFile = "jogl-all.jar";
- static final VersionNumberString preVersionNumber = new VersionNumberString("2.1.5");
- static final Delta.CompatibilityType expectedCompatibilityType = Delta.CompatibilityType.NON_BACKWARD_COMPATIBLE;
- static final DiffCriteria diffCriteria = new SimpleDiffCriteria();
- // static final DiffCriteria diffCriteria = new PublicDiffCriteria();
+ static final DiffCriteria diffCriteria = new org.osjava.jardiff.SimpleDiffCriteria();
+ // static final DiffCriteria diffCriteria = new org.osjava.jardiff.PublicDiffCriteria();
static final JogampVersion curVersion = JoglVersion.getInstance();
static final VersionNumberString curVersionNumber = new VersionNumberString(curVersion.getImplementationVersion());
- static final Set<String> excludes;
+ static final Set<String> excludesDefault;
static {
- excludes = new HashSet<String>();
- excludes.add("^\\Qjogamp/\\E.*$");
+ excludesDefault = new HashSet<String>();
+ excludesDefault.add("^\\Qjogamp/\\E.*$");
}
// @Test
public void testVersionV212V213() throws IllegalArgumentException, IOException, URISyntaxException {
- testVersions(diffCriteria, Delta.CompatibilityType.BACKWARD_COMPATIBLE_USER, "2.1.2", "2.1.3");
+ testVersions(diffCriteria, Delta.CompatibilityType.BACKWARD_COMPATIBLE_USER, "2.1.2", "2.1.3", excludesDefault);
}
// @Test
public void testVersionV213V214() throws IllegalArgumentException, IOException, URISyntaxException {
- testVersions(diffCriteria, Delta.CompatibilityType.BACKWARD_COMPATIBLE_USER, "2.1.3", "2.1.4");
+ testVersions(diffCriteria, Delta.CompatibilityType.BACKWARD_COMPATIBLE_USER, "2.1.3", "2.1.4", excludesDefault);
}
// @Test
public void testVersionV214V215() throws IllegalArgumentException, IOException, URISyntaxException {
- testVersions(diffCriteria, Delta.CompatibilityType.BACKWARD_COMPATIBLE_USER, "2.1.4", "2.1.5");
+ testVersions(diffCriteria, Delta.CompatibilityType.BACKWARD_COMPATIBLE_USER, "2.1.4", "2.1.5", excludesDefault);
+ }
+
+ // @Test
+ public void testVersionV215V220() throws IllegalArgumentException, IOException, URISyntaxException {
+ testVersions(diffCriteria, Delta.CompatibilityType.BACKWARD_COMPATIBLE_USER, "2.1.5", "2.2.0", excludesDefault);
+ }
+
+ @Test
+ public void testVersionV220V221() throws IllegalArgumentException, IOException, URISyntaxException {
+ testVersions(diffCriteria, Delta.CompatibilityType.BACKWARD_COMPATIBLE_USER, "2.2.0", "2.2.1", excludesDefault);
}
void testVersions(final DiffCriteria diffCriteria, final Delta.CompatibilityType expectedCompatibilityType,
- final String v1, final String v2) throws IllegalArgumentException, IOException, URISyntaxException {
+ final String v1, final String v2, final Set<String> excludes)
+ throws IllegalArgumentException, IOException, URISyntaxException {
final VersionNumberString preVersionNumber = new VersionNumberString(v1);
final File previousJar = new File("lib/v"+v1+"/"+jarFile);
@@ -95,7 +103,11 @@ public class TestVersionSemanticsNOUI extends JunitTracer {
}
@Test
- public void testVersionLatest() throws IllegalArgumentException, IOException, URISyntaxException {
+ public void testVersionV221V23x() throws IllegalArgumentException, IOException, URISyntaxException {
+ final Delta.CompatibilityType expectedCompatibilityType = Delta.CompatibilityType.NON_BACKWARD_COMPATIBLE;
+ // final Delta.CompatibilityType expectedCompatibilityType = Delta.CompatibilityType.BACKWARD_COMPATIBLE_USER;
+
+ final VersionNumberString preVersionNumber = new VersionNumberString("2.2.1");
final File previousJar = new File("lib/v"+preVersionNumber.getVersionString()+"/"+jarFile);
final ClassLoader currentCL = TestVersionSemanticsNOUI.class.getClassLoader();
@@ -103,7 +115,7 @@ public class TestVersionSemanticsNOUI extends JunitTracer {
VersionSemanticsUtil.testVersion(diffCriteria, expectedCompatibilityType,
previousJar, preVersionNumber,
curVersion.getClass(), currentCL, curVersionNumber,
- excludes);
+ excludesDefault);
}
public static void main(final String args[]) throws IOException {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/GLContextDrawableSwitchBase0.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/GLContextDrawableSwitchBase0.java
new file mode 100644
index 000000000..08614f9fb
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/GLContextDrawableSwitchBase0.java
@@ -0,0 +1,264 @@
+/**
+ * Copyright 2013 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.opengl.test.junit.jogl.acore.glels;
+
+import java.lang.reflect.InvocationTargetException;
+
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLProfile;
+import javax.media.opengl.Threading;
+
+import com.jogamp.opengl.util.Animator;
+import com.jogamp.opengl.util.GLDrawableUtil;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.util.QuitAdapter;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.FixMethodOrder;
+import org.junit.runners.MethodSorters;
+
+/**
+ * Test re-association (switching) of GLWindow /GLDrawables,
+ * from GLWindow/GLOffscreenAutoDrawable to an GLOffscreenAutoDrawable and back.
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public abstract class GLContextDrawableSwitchBase0 extends UITestCase {
+ static int width, height;
+ static boolean testEvenUnsafeSwapGLContext = false;
+
+ static GLCapabilities getCaps(final String profile) {
+ if( !GLProfile.isAvailable(profile) ) {
+ System.err.println("Profile "+profile+" n/a");
+ return null;
+ }
+ return new GLCapabilities(GLProfile.get(profile));
+ }
+
+ @BeforeClass
+ public static void initClass() {
+ width = 256;
+ height = 256;
+ }
+
+ public abstract GLAutoDrawable createGLAutoDrawable(final QuitAdapter quitAdapter, final GLCapabilitiesImmutable caps, final int width, final int height) throws InterruptedException, InvocationTargetException;
+ public abstract void destroyGLAutoDrawable(final GLAutoDrawable glad) throws InterruptedException, InvocationTargetException;
+
+ @Test(timeout=30000)
+ public void test01aSwitch2Onscreen2OnscreenGL2ES2_Def() throws InterruptedException, InvocationTargetException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
+ if(null == reqGLCaps) return;
+ testImpl(reqGLCaps, true);
+ }
+
+ @Test(timeout=30000)
+ public void test01bSwitch2Onscreen2OffscreenGL2ES2_Def() throws InterruptedException, InvocationTargetException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
+ if(null == reqGLCaps) return;
+ testImpl(reqGLCaps, false);
+ }
+
+ @Test(timeout=30000)
+ public void test01cSwitch2Offscreen2OffscreenGL2ES2_Def() throws InterruptedException, InvocationTargetException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ testImpl(reqGLCaps, false);
+ }
+
+ @Test(timeout=30000)
+ public void test01dSwitch2Offscreen2OnscreenGL2ES2_Def() throws InterruptedException, InvocationTargetException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ testImpl(reqGLCaps, true);
+ }
+
+ @Test(timeout=30000)
+ public void test02aSwitch2Onscreen2OnscreenGL2ES2_MSAA() throws InterruptedException, InvocationTargetException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setNumSamples(4);
+ reqGLCaps.setSampleBuffers(true);
+ testImpl(reqGLCaps, true);
+ }
+
+ @Test(timeout=30000)
+ public void test02bSwitch2Onscreen2OffscreenGL2ES2_MSAA() throws InterruptedException, InvocationTargetException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setNumSamples(4);
+ reqGLCaps.setSampleBuffers(true);
+ testImpl(reqGLCaps, false);
+ }
+
+ @Test(timeout=30000)
+ public void test02cSwitch2Offscreen2OffscreenGL2ES2_MSAA() throws InterruptedException, InvocationTargetException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setNumSamples(4);
+ reqGLCaps.setSampleBuffers(true);
+ testImpl(reqGLCaps, false);
+ }
+
+ @Test(timeout=30000)
+ public void test02dSwitch2Offscreen2OnscreenGL2ES2_MSAA() throws InterruptedException, InvocationTargetException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setNumSamples(4);
+ reqGLCaps.setSampleBuffers(true);
+ testImpl(reqGLCaps, true);
+ }
+
+ @Test(timeout=30000)
+ public void test03aSwitch2Onscreen2OnscreenGL2ES2_Accu() throws InterruptedException, InvocationTargetException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setAccumRedBits(1);
+ reqGLCaps.setAccumGreenBits(1);
+ reqGLCaps.setAccumBlueBits(1);
+ testImpl(reqGLCaps, true);
+ }
+
+ @Test(timeout=30000)
+ public void test03bSwitch2Onscreen2OffscreenGL2ES2_Accu() throws InterruptedException, InvocationTargetException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setAccumRedBits(1);
+ reqGLCaps.setAccumGreenBits(1);
+ reqGLCaps.setAccumBlueBits(1);
+ testImpl(reqGLCaps, false);
+ }
+
+ @Test(timeout=30000)
+ public void test03cSwitch2Offscreen2OffscreenGL2ES2_Accu() throws InterruptedException, InvocationTargetException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setAccumRedBits(1);
+ reqGLCaps.setAccumGreenBits(1);
+ reqGLCaps.setAccumBlueBits(1);
+ testImpl(reqGLCaps, false);
+ }
+
+ @Test(timeout=30000)
+ public void test03dSwitch2Offscreen2OnscreenGL2ES2_Accu() throws InterruptedException, InvocationTargetException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setAccumRedBits(1);
+ reqGLCaps.setAccumGreenBits(1);
+ reqGLCaps.setAccumBlueBits(1);
+ testImpl(reqGLCaps, true);
+ }
+
+ private void testImpl(final GLCapabilitiesImmutable srcCapsRequested, final boolean dstOnscreen) throws InterruptedException, InvocationTargetException {
+ final QuitAdapter quitAdapter = new QuitAdapter();
+ final GLAutoDrawable gladSource = createGLAutoDrawable(quitAdapter, srcCapsRequested, width, height);
+
+ final GLCapabilitiesImmutable srcCapsChosen = gladSource.getChosenGLCapabilities();
+
+ final GLCapabilities dstCaps = (GLCapabilities) srcCapsChosen.cloneMutable();
+ dstCaps.setOnscreen(dstOnscreen);
+
+ final boolean isSwapGLContextSafe = GLDrawableUtil.isSwapGLContextSafe(srcCapsRequested, srcCapsChosen, dstCaps);
+ System.err.println("Source Caps Requested: "+srcCapsRequested);
+ System.err.println("Source Caps Chosen : "+srcCapsChosen);
+ System.err.println("Dest Caps Requested: "+dstCaps);
+ System.err.println("Is SwapGLContext safe: "+isSwapGLContextSafe);
+
+ if( !isSwapGLContextSafe && !testEvenUnsafeSwapGLContext ) {
+ System.err.println("Supressing unsafe tests ...");
+ destroyGLAutoDrawable(gladSource);
+ return;
+ }
+
+ final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener();
+ final GearsES2 gears = new GearsES2(1);
+ gears.setVerbose(false);
+ gladSource.addGLEventListener(gears);
+ gladSource.addGLEventListener(snapshotGLEventListener);
+ snapshotGLEventListener.setMakeSnapshot();
+
+ final Animator animator = new Animator();
+ animator.add(gladSource);
+ animator.start();
+
+ int s = 0;
+ final long t0 = System.currentTimeMillis();
+ long t1 = t0;
+
+ final GLAutoDrawable gladDest = createGLAutoDrawable(quitAdapter, dstCaps, width, height);
+ RuntimeException caught = null;
+ try {
+ while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration ) {
+ if( ( t1 - t0 ) / period > s) {
+ s++;
+ System.err.println(s+" - switch - START "+ ( t1 - t0 ));
+
+ final Runnable switchAction = new Runnable() {
+ public void run() {
+ GLDrawableUtil.swapGLContextAndAllGLEventListener(gladSource, gladDest);
+ } };
+
+ // switch context _and_ the demo synchronously
+ if( gladSource.isThreadGLCapable() && gladDest.isThreadGLCapable() ) {
+ switchAction.run();
+ } else {
+ Threading.invokeOnOpenGLThread(true, switchAction);
+ }
+ snapshotGLEventListener.setMakeSnapshot();
+
+ System.err.println(s+" - switch - END "+ ( t1 - t0 ));
+ }
+ Thread.sleep(100);
+ t1 = System.currentTimeMillis();
+ }
+ } catch (final RuntimeException t) {
+ caught = t;
+ }
+
+ animator.stop();
+ destroyGLAutoDrawable(gladDest);
+ destroyGLAutoDrawable(gladSource);
+
+ if( null != caught ) {
+ throw caught;
+ }
+ }
+
+ // default timing for 2 switches
+ static long duration = 2900; // ms
+ static long period = 1000; // ms
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/GLContextDrawableSwitchBase.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/GLContextDrawableSwitchBase1.java
index b19dc38f2..0e7ea3e83 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/GLContextDrawableSwitchBase.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/GLContextDrawableSwitchBase1.java
@@ -68,7 +68,7 @@ import org.junit.BeforeClass;
* See Bug 665 - https://jogamp.org/bugzilla/show_bug.cgi?id=665.
* </p>
*/
-public abstract class GLContextDrawableSwitchBase extends UITestCase {
+public abstract class GLContextDrawableSwitchBase1 extends UITestCase {
static protected enum GLADType { GLCanvasOnscreen, GLCanvasOffscreen, GLWindow, GLOffscreen };
// default period for 1 GLAD cycle
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestBug722GLContextDrawableSwitchNewt2AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestBug722GLContextDrawableSwitchNewt2AWT.java
index 512ebc974..e961fe32d 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestBug722GLContextDrawableSwitchNewt2AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestBug722GLContextDrawableSwitchNewt2AWT.java
@@ -54,7 +54,7 @@ import org.junit.runners.MethodSorters;
* </p>
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestBug722GLContextDrawableSwitchNewt2AWT extends GLContextDrawableSwitchBase {
+public class TestBug722GLContextDrawableSwitchNewt2AWT extends GLContextDrawableSwitchBase1 {
static int loops = 10;
static long duration2 = 100; // ms
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch02AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch02AWT.java
index d665c1a87..d9f2d0e18 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch02AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch02AWT.java
@@ -29,6 +29,7 @@
package com.jogamp.opengl.test.junit.jogl.acore.glels;
import java.awt.BorderLayout;
+import java.awt.Component;
import java.awt.Dimension;
import java.awt.Frame;
import java.io.IOException;
@@ -38,20 +39,15 @@ import com.jogamp.newt.event.TraceWindowAdapter;
import com.jogamp.newt.event.awt.AWTWindowAdapter;
import javax.media.opengl.GLAutoDrawable;
-import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLCapabilitiesImmutable;
import javax.media.opengl.GLDrawableFactory;
-import javax.media.opengl.GLProfile;
import javax.media.opengl.awt.GLCanvas;
-import com.jogamp.opengl.util.Animator;
-import com.jogamp.opengl.util.GLDrawableUtil;
-import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import jogamp.nativewindow.awt.AWTMisc;
+
import com.jogamp.opengl.test.junit.util.QuitAdapter;
-import com.jogamp.opengl.test.junit.util.UITestCase;
import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
@@ -60,26 +56,15 @@ import org.junit.runners.MethodSorters;
* from GLCanvas to an GLOffscreenAutoDrawable and back.
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestGLContextDrawableSwitch02AWT extends UITestCase {
- static int width, height;
-
- static GLCapabilities getCaps(final String profile) {
- if( !GLProfile.isAvailable(profile) ) {
- System.err.println("Profile "+profile+" n/a");
- return null;
- }
- return new GLCapabilities(GLProfile.get(profile));
- }
+public class TestGLContextDrawableSwitch02AWT extends GLContextDrawableSwitchBase0 {
- @BeforeClass
- public static void initClass() {
- width = 256;
- height = 256;
- }
-
- private GLAutoDrawable createGLAutoDrawable(final Frame frame, final GLCapabilities caps, final int width, final int height) throws InterruptedException, InvocationTargetException {
+ @Override
+ public GLAutoDrawable createGLAutoDrawable(final QuitAdapter quitAdapter, final GLCapabilitiesImmutable caps, final int width, final int height) throws InterruptedException, InvocationTargetException {
final GLAutoDrawable glad;
if( caps.isOnscreen() ) {
+ final Frame frame = new Frame("Gears AWT Test");
+ Assert.assertNotNull(frame);
+
final GLCanvas glCanvas = new GLCanvas(caps);
Assert.assertNotNull(glCanvas);
final Dimension glc_sz = new Dimension(width, height);
@@ -88,6 +73,8 @@ public class TestGLContextDrawableSwitch02AWT extends UITestCase {
glCanvas.setSize(glc_sz);
glad = glCanvas;
+ new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter), glCanvas).addTo(frame);
+
frame.setLayout(new BorderLayout());
frame.add(glCanvas, BorderLayout.CENTER);
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
@@ -95,7 +82,6 @@ public class TestGLContextDrawableSwitch02AWT extends UITestCase {
frame.pack();
frame.setVisible(true);
}});
-
} else {
final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile());
glad = factory.createOffscreenAutoDrawable(null, caps, null, width, height);
@@ -104,70 +90,20 @@ public class TestGLContextDrawableSwitch02AWT extends UITestCase {
return glad;
}
- @Test(timeout=30000)
- public void testSwitch2AWTGLCanvas2OffscreenGL2ES2() throws InterruptedException, InvocationTargetException {
- final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
- if(null == reqGLCaps) return;
- testSwitch2AWTGLCanvas2OffscreenImpl(reqGLCaps);
- }
-
- private void testSwitch2AWTGLCanvas2OffscreenImpl(final GLCapabilities capsOnscreen) throws InterruptedException, InvocationTargetException {
- final GLCapabilities capsOffscreen = (GLCapabilities) capsOnscreen.clone();
- capsOffscreen.setOnscreen(false);
-
- final Frame frame = new Frame("Gears AWT Test");
- Assert.assertNotNull(frame);
-
- final GLAutoDrawable glCanvas = createGLAutoDrawable(frame, capsOnscreen, width, height);
-
- final QuitAdapter quitAdapter = new QuitAdapter();
- new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter), glCanvas).addTo(frame);
-
- final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener();
- final GearsES2 gears = new GearsES2(1);
- glCanvas.addGLEventListener(gears);
- glCanvas.addGLEventListener(snapshotGLEventListener);
- snapshotGLEventListener.setMakeSnapshot();
-
- final Animator animator = new Animator();
- animator.add(glCanvas);
- animator.start();
-
- int s = 0;
- final long t0 = System.currentTimeMillis();
- long t1 = t0;
-
- final GLAutoDrawable glOffscreen = createGLAutoDrawable(null, capsOffscreen, width, height);
- while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration ) {
- if( ( t1 - t0 ) / period > s) {
- s++;
- System.err.println(s+" - switch - START "+ ( t1 - t0 ));
-
- // switch context _and_ the demo synchronously
- GLDrawableUtil.swapGLContextAndAllGLEventListener(glCanvas, glOffscreen);
- snapshotGLEventListener.setMakeSnapshot();
-
- System.err.println(s+" - switch - END "+ ( t1 - t0 ));
- }
- Thread.sleep(100);
- t1 = System.currentTimeMillis();
+ @Override
+ public void destroyGLAutoDrawable(final GLAutoDrawable glad) throws InterruptedException, InvocationTargetException {
+ if( glad.getChosenGLCapabilities().isOnscreen() ) {
+ final Frame frame = AWTMisc.getFrame((Component)glad);
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ final Frame _frame = frame;
+ _frame.dispose();
+ }});
+ } else {
+ glad.destroy();
}
-
- animator.stop();
- // glCanvas.destroy();
- glOffscreen.destroy();
-
- javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
- public void run() {
- final Frame _frame = frame;
- _frame.dispose();
- }});
}
- // default timing for 2 switches
- static long duration = 2900; // ms
- static long period = 1000; // ms
-
public static void main(final String args[]) throws IOException {
for(int i=0; i<args.length; i++) {
if(args[i].equals("-time")) {
@@ -180,6 +116,8 @@ public class TestGLContextDrawableSwitch02AWT extends UITestCase {
try {
period = Integer.parseInt(args[i]);
} catch (final Exception ex) { ex.printStackTrace(); }
+ } else if(args[i].equals("-testUnsafe")) {
+ testEvenUnsafeSwapGLContext = true;
}
}
/**
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch02NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch02NEWT.java
new file mode 100644
index 000000000..c8a78d05f
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch02NEWT.java
@@ -0,0 +1,100 @@
+/**
+ * Copyright 2013 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.opengl.test.junit.jogl.acore.glels;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+
+import com.jogamp.newt.opengl.GLWindow;
+
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLDrawableFactory;
+
+import com.jogamp.opengl.test.junit.util.QuitAdapter;
+
+import org.junit.Assert;
+import org.junit.FixMethodOrder;
+import org.junit.runners.MethodSorters;
+
+/**
+ * Test re-association (switching) of GLWindow /GLDrawables,
+ * from GLWindow/GLOffscreenAutoDrawable to an GLOffscreenAutoDrawable and back.
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestGLContextDrawableSwitch02NEWT extends GLContextDrawableSwitchBase0 {
+ @Override
+ public GLAutoDrawable createGLAutoDrawable(final QuitAdapter quitAdapter, final GLCapabilitiesImmutable caps, final int width, final int height) throws InterruptedException, InvocationTargetException {
+ final GLAutoDrawable glad;
+ if( caps.isOnscreen() ) {
+ final GLWindow glWindow = GLWindow.create(caps);
+ Assert.assertNotNull(glWindow);
+ glad = glWindow;
+
+ if( null != quitAdapter ) {
+ glWindow.addWindowListener(quitAdapter);
+ }
+
+ glWindow.setVisible(true);
+ } else {
+ final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile());
+ glad = factory.createOffscreenAutoDrawable(null, caps, null, width, height);
+ Assert.assertNotNull(glad);
+ }
+ return glad;
+ }
+
+ @Override
+ public void destroyGLAutoDrawable(final GLAutoDrawable glad) throws InterruptedException, InvocationTargetException {
+ glad.destroy();
+ }
+
+ public static void main(final String args[]) throws IOException {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ try {
+ duration = Integer.parseInt(args[i]);
+ } catch (final Exception ex) { ex.printStackTrace(); }
+ } else if(args[i].equals("-period")) {
+ i++;
+ try {
+ period = Integer.parseInt(args[i]);
+ } catch (final Exception ex) { ex.printStackTrace(); }
+ } else if(args[i].equals("-testUnsafe")) {
+ testEvenUnsafeSwapGLContext = true;
+ }
+ }
+ /**
+ BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
+ System.err.println("Press enter to continue");
+ System.err.println(stdin.readLine()); */
+ org.junit.runner.JUnitCore.main(TestGLContextDrawableSwitch02NEWT.class.getName());
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch11NewtAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch11NewtAWT.java
index 9697869bc..f1c08c889 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch11NewtAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch11NewtAWT.java
@@ -60,7 +60,7 @@ import org.junit.runners.MethodSorters;
* </p>
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestGLContextDrawableSwitch11NewtAWT extends GLContextDrawableSwitchBase {
+public class TestGLContextDrawableSwitch11NewtAWT extends GLContextDrawableSwitchBase1 {
@Test(timeout=30000)
public void test21GLWindowGL2ES2() throws InterruptedException {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch12AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch12AWT.java
index 4ad0b1dc5..795e53768 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch12AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch12AWT.java
@@ -61,7 +61,7 @@ import org.junit.runners.MethodSorters;
* </p>
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestGLContextDrawableSwitch12AWT extends GLContextDrawableSwitchBase {
+public class TestGLContextDrawableSwitch12AWT extends GLContextDrawableSwitchBase1 {
@Test(timeout=30000)
public void test01GLCanvasOnscreenGL2ES2() throws InterruptedException {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch21Newt2AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch13Newt2AWT.java
index eaf3d37d4..27d5ff80a 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch21Newt2AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch13Newt2AWT.java
@@ -73,7 +73,7 @@ import org.junit.runners.MethodSorters;
* </p>
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestGLContextDrawableSwitch21Newt2AWT extends GLContextDrawableSwitchBase {
+public class TestGLContextDrawableSwitch13Newt2AWT extends GLContextDrawableSwitchBase1 {
@Test(timeout=30000)
public void test01GLCanvasOnScrn2GLWindowGL2ES2() throws InterruptedException {
@@ -190,6 +190,6 @@ public class TestGLContextDrawableSwitch21Newt2AWT extends GLContextDrawableSwit
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
System.err.println("Press enter to continue");
System.err.println(stdin.readLine()); */
- org.junit.runner.JUnitCore.main(TestGLContextDrawableSwitch21Newt2AWT.class.getName());
+ org.junit.runner.JUnitCore.main(TestGLContextDrawableSwitch13Newt2AWT.class.getName());
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestTranslucencyNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestTranslucencyNEWT.java
index 8f23b57a0..10ac9417a 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestTranslucencyNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestTranslucencyNEWT.java
@@ -31,11 +31,10 @@ package com.jogamp.opengl.test.junit.jogl.caps;
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 javax.media.opengl.GLCapabilities;
@@ -147,14 +146,19 @@ public class TestTranslucencyNEWT extends UITestCase {
static long duration = 500; // ms
public static void main(final String args[]) {
+ boolean waitForKey = false;
+
for(int i=0; i<args.length; i++) {
if(args[i].equals("-time")) {
i++;
- try {
- duration = Integer.parseInt(args[i]);
- } catch (final Exception ex) { ex.printStackTrace(); }
+ duration = MiscUtils.atol(args[i], duration);
+ } else if(args[i].equals("-wait")) {
+ waitForKey = true;
}
}
+ if( waitForKey ) {
+ UITestCase.waitForKey("main");
+ }
org.junit.runner.JUnitCore.main(TestTranslucencyNEWT.class.getName());
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java
index b1df926dc..3fdafdfd8 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java
@@ -248,7 +248,7 @@ public class GearsES1 implements GLEventListener {
public void display(final GLAutoDrawable drawable) {
// Turn the gears' teeth
- angle += 2.0f;
+ angle += 0.5f;
// Get the GL corresponding to the drawable we are animating
final GL2ES1 gl = drawable.getGL().getGL2ES1();
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/FBOMix2DemosES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/FBOMix2DemosES2.java
index f00053989..42f4c5f6e 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/FBOMix2DemosES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/FBOMix2DemosES2.java
@@ -49,7 +49,7 @@ public class FBOMix2DemosES2 implements GLEventListener {
private final GearsES2 demo0;
private final RedSquareES2 demo1;
private final int swapInterval;
- private int numSamples;
+ private volatile int numSamples;
private boolean demo0Only;
@@ -156,13 +156,8 @@ public class FBOMix2DemosES2 implements GLEventListener {
}
private void initFBOs(final GL gl, final GLAutoDrawable drawable) {
- // remove all texture attachments, since MSAA uses just color-render-buffer
- // and non-MSAA uses texture2d-buffer
- fbo0.detachAllColorbuffer(gl);
- fbo1.detachAllColorbuffer(gl);
-
- fbo0.reset(gl, drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), numSamples, false);
- fbo1.reset(gl, drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), numSamples, false);
+ fbo0.init(gl, drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), numSamples);
+ fbo1.init(gl, drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), numSamples);
if(fbo0.getNumSamples() != fbo1.getNumSamples()) {
throw new InternalError("sample size mismatch: \n\t0: "+fbo0+"\n\t1: "+fbo1);
}
@@ -173,32 +168,32 @@ public class FBOMix2DemosES2 implements GLEventListener {
fbo0.resetSamplingSink(gl);
fbo1.attachColorbuffer(gl, 0, true);
fbo1.resetSamplingSink(gl);
- fbo0Tex = fbo0.getSamplingSink();
- fbo1Tex = fbo1.getSamplingSink();
+ fbo0Tex = fbo0.getSamplingSink().getTextureAttachment();
+ fbo1Tex = fbo1.getSamplingSink().getTextureAttachment();
} else {
fbo0Tex = fbo0.attachTexture2D(gl, 0, true);
fbo1Tex = fbo1.attachTexture2D(gl, 0, true);
}
numSamples=fbo0.getNumSamples();
- fbo0.attachRenderbuffer(gl, Type.DEPTH, 24);
+ fbo0.attachRenderbuffer(gl, Type.DEPTH, FBObject.CHOSEN_BITS);
fbo0.unbind(gl);
- fbo1.attachRenderbuffer(gl, Type.DEPTH, 24);
+ fbo1.attachRenderbuffer(gl, Type.DEPTH, FBObject.CHOSEN_BITS);
fbo1.unbind(gl);
}
private void resetFBOs(final GL gl, final GLAutoDrawable drawable) {
- fbo0.reset(gl, drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), numSamples, true);
- fbo1.reset(gl, drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), numSamples, true);
+ fbo0.reset(gl, drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), numSamples);
+ fbo1.reset(gl, drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), numSamples);
if(fbo0.getNumSamples() != fbo1.getNumSamples()) {
throw new InternalError("sample size mismatch: \n\t0: "+fbo0+"\n\t1: "+fbo1);
}
numSamples = fbo0.getNumSamples();
if(numSamples>0) {
- fbo0Tex = fbo0.getSamplingSink();
- fbo1Tex = fbo1.getSamplingSink();
+ fbo0Tex = fbo0.getSamplingSink().getTextureAttachment();
+ fbo1Tex = fbo1.getSamplingSink().getTextureAttachment();
} else {
- fbo0Tex = (TextureAttachment) fbo0.getColorbuffer(0);
- fbo1Tex = (TextureAttachment) fbo1.getColorbuffer(0);
+ fbo0Tex = fbo0.getColorbuffer(0).getTextureAttachment();
+ fbo1Tex = fbo1.getColorbuffer(0).getTextureAttachment();
}
}
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 84cd8936e..b3da5a53a 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
@@ -352,9 +352,15 @@ public class GearsES2 implements StereoGLEventListener, TileRendererBase.TileRen
reshapeImpl(gl, tileX, tileY, tileWidth, tileHeight, imageWidth, imageHeight);
}
- private final float zNear = 2f;
- private final float zFar = 10000f;
- private final float zViewDist = 20.0f;
+ private float zNear = 5f;
+ private float zFar = 10000f;
+ private float zViewDist = 40.0f;
+
+ public void setZ(final float zNear, final float zFar, final float zViewDist) {
+ this.zNear = zNear;
+ this.zFar = zFar;
+ this.zViewDist = zViewDist;
+ }
void reshapeImpl(final GL2ES2 gl, final int tileX, final int tileY, final int tileWidth, final int tileHeight, final int imageWidth, final int imageHeight) {
final boolean msaa = gl.getContext().getGLDrawable().getChosenGLCapabilities().getSampleBuffers();
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/MultisampleDemoES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/MultisampleDemoES2.java
index 7c4c5106b..8e4dbfefe 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/MultisampleDemoES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/MultisampleDemoES2.java
@@ -55,7 +55,7 @@ import com.jogamp.opengl.util.glsl.ShaderState;
public class MultisampleDemoES2 implements GLEventListener {
- private boolean multisample;
+ private boolean multisample, clearBuffers;
private final ShaderState st;
private final PMVMatrix pmvMatrix;
private ShaderProgram sp0;
@@ -64,11 +64,14 @@ public class MultisampleDemoES2 implements GLEventListener {
public MultisampleDemoES2(final boolean multisample) {
this.multisample = multisample;
+ this.clearBuffers = true;
st = new ShaderState();
st.setVerbose(true);
pmvMatrix = new PMVMatrix();
}
+ public void setClearBuffers(final boolean v) { clearBuffers = v; }
+
public void init(final GLAutoDrawable glad) {
final GL2ES2 gl = glad.getGL().getGL2ES2();
@@ -135,10 +138,12 @@ public class MultisampleDemoES2 implements GLEventListener {
if (multisample) {
gl.glEnable(GL.GL_MULTISAMPLE);
}
- gl.glClearColor(0, 0, 0, 0);
- // gl.glEnable(GL.GL_DEPTH_TEST);
- // gl.glDepthFunc(GL.GL_LESS);
- gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
+ if( clearBuffers ) {
+ gl.glClearColor(0, 0, 0, 0);
+ // gl.glEnable(GL.GL_DEPTH_TEST);
+ // gl.glDepthFunc(GL.GL_LESS);
+ gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
+ }
st.useProgram(gl, true);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw02ES2ListenerFBO.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw02ES2ListenerFBO.java
index 18cb35929..27395ea45 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw02ES2ListenerFBO.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw02ES2ListenerFBO.java
@@ -138,36 +138,34 @@ public class TextureDraw02ES2ListenerFBO implements GLEventListener {
st.useProgram(gl, false);
+ initFBOs(gl, drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
+
gl.glEnable(GL.GL_DEPTH_TEST);
}
private void initFBOs(final GL gl, final int width, final int height) {
- // remove all texture attachments, since MSAA uses just color-render-buffer
- // and non-MSAA uses texture2d-buffer
- fbo0.detachAllColorbuffer(gl);
-
- fbo0.reset(gl, width, height, numSamples, false);
+ fbo0.init(gl, width, height, numSamples);
numSamples = fbo0.getNumSamples();
if(numSamples>0) {
fbo0.attachColorbuffer(gl, 0, true);
fbo0.resetSamplingSink(gl);
- fbo0Tex = fbo0.getSamplingSink();
+ fbo0Tex = fbo0.getSamplingSink().getTextureAttachment();
} else {
fbo0Tex = fbo0.attachTexture2D(gl, 0, true);
}
numSamples=fbo0.getNumSamples();
- fbo0.attachRenderbuffer(gl, Type.DEPTH, 24);
+ fbo0.attachRenderbuffer(gl, Type.DEPTH, FBObject.CHOSEN_BITS);
fbo0.unbind(gl);
}
private void resetFBOs(final GL gl, final int width, final int height) {
- fbo0.reset(gl, width, height, numSamples, true);
+ fbo0.reset(gl, width, height, numSamples);
numSamples = fbo0.getNumSamples();
if(numSamples>0) {
- fbo0Tex = fbo0.getSamplingSink();
+ fbo0Tex = fbo0.getSamplingSink().getTextureAttachment();
} else {
- fbo0Tex = (TextureAttachment) fbo0.getColorbuffer(0);
+ fbo0Tex = fbo0.getColorbuffer(0).getTextureAttachment();
}
}
@@ -236,16 +234,11 @@ public class TextureDraw02ES2ListenerFBO implements GLEventListener {
gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there)
}
- if( !fbo0.isInitialized() ) {
- System.err.println("**** Reshape.Init: "+width+"x"+height);
- initFBOs(gl, width, height);
- } else {
- System.err.println("**** Reshape.Reset: "+width+"x"+height);
- if( keepTextureBound ) {
- fbo0.unuse(gl);
- }
- resetFBOs(gl, width, height);
+ System.err.println("**** Reshape.Reset: "+width+"x"+height);
+ if( keepTextureBound ) {
+ fbo0.unuse(gl);
}
+ resetFBOs(gl, width, height);
fbo0.bind(gl);
demo.reshape(drawable, x, y, width, height);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/CrossFadePlayer.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/CrossFadePlayer.java
index e5e752d96..b2ebc7068 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/CrossFadePlayer.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/CrossFadePlayer.java
@@ -28,6 +28,7 @@
package com.jogamp.opengl.test.junit.jogl.demos.es2.av;
+import com.jogamp.common.net.Uri;
import com.jogamp.opengl.util.av.AudioSink;
import com.jogamp.opengl.util.av.GLMediaPlayer;
import com.jogamp.opengl.util.av.GLMediaPlayer.GLMediaEventListener;
@@ -36,7 +37,6 @@ import com.jogamp.opengl.util.av.GLMediaPlayerFactory;
import com.jogamp.opengl.util.texture.TextureSequence.TextureFrame;
import java.io.File;
-import java.net.URI;
/**
* Parallel media player that demonstrate CrossFade of audio volume during playback.
@@ -141,7 +141,7 @@ public class CrossFadePlayer
if(!file.exists()){
System.out.println("File do not exist");
} else {
- final URI uri = file.toURI();
+ final Uri uri = Uri.valueOf(file);
System.out.println("State of player "+ i +": " + player[i].getState().toString());
System.out.println("...initializing stream "+ i +"...");
player[i].initStream(uri, GLMediaPlayer.STREAM_ID_NONE, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.TEXTURE_COUNT_DEFAULT);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java
index 607bfd1b0..428eea42c 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java
@@ -30,7 +30,6 @@ package com.jogamp.opengl.test.junit.jogl.demos.es2.av;
import java.io.File;
import java.io.IOException;
-import java.net.URI;
import java.net.URISyntaxException;
import javax.media.opengl.GL;
@@ -42,7 +41,7 @@ import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
-import com.jogamp.common.util.IOUtil;
+import com.jogamp.common.net.Uri;
import com.jogamp.graph.curve.Region;
import com.jogamp.graph.curve.opengl.GLRegion;
import com.jogamp.graph.curve.opengl.RegionRenderer;
@@ -81,13 +80,13 @@ public class MovieCube implements GLEventListener {
private volatile boolean resetGLState = false;
/** Blender's Big Buck Bunny: 24f 416p H.264, AAC 48000 Hz, 2 ch, mpeg stream. */
- public static final URI defURI;
+ public static final Uri defURI;
static {
- URI _defURI = null;
+ Uri _defURI = null;
try {
// Blender's Big Buck Bunny Trailer: 24f 640p VP8, Vorbis 44100Hz mono, WebM/Matroska Stream.
// _defURI = new URI("http://video.webmfiles.org/big-buck-bunny_trailer.webm");
- _defURI = new URI("http://archive.org/download/BigBuckBunny_328/BigBuckBunny_512kb.mp4");
+ _defURI = Uri.cast("http://archive.org/download/BigBuckBunny_328/BigBuckBunny_512kb.mp4");
} catch (final URISyntaxException e) {
e.printStackTrace();
}
@@ -151,7 +150,7 @@ public class MovieCube implements GLEventListener {
mPlayer = GLMediaPlayerFactory.createDefault();
}
- public void initStream(final URI streamLoc, final int vid, final int aid, final int textureCount) {
+ public void initStream(final Uri streamLoc, final int vid, final int aid, final int textureCount) {
mPlayer.initStream(streamLoc, vid, aid, textureCount);
System.out.println("pC.1b "+mPlayer);
}
@@ -252,7 +251,7 @@ public class MovieCube implements GLEventListener {
mPlayer.getAID(), mPlayer.getAudioBitrate()/1000, mPlayer.getAudioCodec());
final String text3 = String.format("video: id %d, kbps %d, codec %s",
mPlayer.getVID(), mPlayer.getVideoBitrate()/1000, mPlayer.getVideoCodec());
- final String text4 = mPlayer.getURI().getRawPath();
+ final String text4 = mPlayer.getUri().path.decode();
if( displayOSD && null != renderer ) {
gl.glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
if( null != regionFPS ) {
@@ -517,11 +516,11 @@ public class MovieCube implements GLEventListener {
}
origSize = _origSize;
}
- final URI streamLoc;
+ final Uri streamLoc;
if( null != url_s ) {
- streamLoc = new URI(url_s);
+ streamLoc = Uri.cast( url_s );
} else if( null != file_s ) {
- streamLoc = IOUtil.toURISimple(new File(file_s));
+ streamLoc = Uri.valueOf(new File(file_s));
} else {
streamLoc = defURI;
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSBSStereo.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSBSStereo.java
index 0c7bdc81d..7a3a1ffc7 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSBSStereo.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSBSStereo.java
@@ -28,7 +28,6 @@
package com.jogamp.opengl.test.junit.jogl.demos.es2.av;
-import java.net.URI;
import java.net.URISyntaxException;
import java.nio.FloatBuffer;
@@ -41,6 +40,7 @@ import javax.media.opengl.GLException;
import javax.media.opengl.GLUniformData;
import javax.media.opengl.fixedfunc.GLMatrixFunc;
+import com.jogamp.common.net.Uri;
import com.jogamp.common.os.Platform;
import com.jogamp.graph.curve.Region;
import com.jogamp.graph.curve.opengl.GLRegion;
@@ -117,13 +117,13 @@ public class MovieSBSStereo implements StereoGLEventListener {
private static final String myTextureLookupName = "myTexture2D";
/** Blender's Big Buck Bunny: 24f 416p H.264, AAC 48000 Hz, 2 ch, mpeg stream. */
- public static final URI defURI;
+ public static final Uri defURI;
static {
- URI _defURI = null;
+ Uri _defURI = null;
try {
// Blender's Big Buck Bunny Trailer: 24f 640p VP8, Vorbis 44100Hz mono, WebM/Matroska Stream.
// _defURI = new URI("http://video.webmfiles.org/big-buck-bunny_trailer.webm");
- _defURI = new URI("http://archive.org/download/BigBuckBunny_328/BigBuckBunny_512kb.mp4");
+ _defURI = Uri.cast("http://archive.org/download/BigBuckBunny_328/BigBuckBunny_512kb.mp4");
} catch (final URISyntaxException e) {
e.printStackTrace();
}
@@ -189,7 +189,7 @@ public class MovieSBSStereo implements StereoGLEventListener {
mPlayer.getAID(), mPlayer.getAudioBitrate()/1000, mPlayer.getAudioCodec());
final String text3 = String.format("video: id %d, kbps %d, codec %s",
mPlayer.getVID(), mPlayer.getVideoBitrate()/1000, mPlayer.getVideoCodec());
- final String text4 = mPlayer.getURI().getRawPath();
+ final String text4 = mPlayer.getUri().path.decode();
if( displayOSD && null != renderer ) {
// We share ClearColor w/ MovieSimple's init !
final float pixelSize = font.getPixelSize(fontSize, dpiH);
@@ -203,6 +203,7 @@ public class MovieSBSStereo implements StereoGLEventListener {
renderString(drawable, font, pixelSize, text4, 1 /* col */, -2 /* row */, 0, height, 1, true);
}
} };
+ private final boolean enableTextRendererGLEL = false;
private InfoTextRendererGLELBase textRendererGLEL = null;
private boolean displayOSD = false;
@@ -326,7 +327,7 @@ public class MovieSBSStereo implements StereoGLEventListener {
System.out.println("pC.1a "+mPlayer);
}
- public void initStream(final URI streamLoc, final int vid, final int aid, final int textureCount) {
+ public void initStream(final Uri streamLoc, final int vid, final int aid, final int textureCount) {
mPlayer.initStream(streamLoc, vid, aid, textureCount);
System.out.println("pC.1b "+mPlayer);
}
@@ -534,8 +535,12 @@ public class MovieSBSStereo implements StereoGLEventListener {
}
final int rmode = drawable.getChosenGLCapabilities().getSampleBuffers() ? 0 : Region.VBAA_RENDERING_BIT;
final boolean lowPerfDevice = gl.isGLES();
- textRendererGLEL = new InfoTextRendererGLELBase(rmode, lowPerfDevice);
- textRendererGLEL.init(drawable);
+ if( enableTextRendererGLEL ) {
+ textRendererGLEL = new InfoTextRendererGLELBase(rmode, lowPerfDevice);
+ textRendererGLEL.init(drawable);
+ } else {
+ textRendererGLEL = null;
+ }
}
protected void updateInterleavedVBO(final GL gl, final GLArrayDataServer iVBO, final Texture tex, final int eyeNum) {
@@ -608,7 +613,9 @@ public class MovieSBSStereo implements StereoGLEventListener {
}
System.out.println("pR "+mPlayer);
- textRendererGLEL.reshape(drawable, x, y, width, height);
+ if( null != textRendererGLEL ) {
+ textRendererGLEL.reshape(drawable, 0, 0, width, height);
+ }
}
private final float zNear = 0.1f;
@@ -666,13 +673,17 @@ public class MovieSBSStereo implements StereoGLEventListener {
st.useProgram(gl, true);
st.uniform(gl, pmvMatrixUniform);
st.useProgram(gl, false);
- textRendererGLEL.reshape(drawable, x, y, width, height);
+ if( null != textRendererGLEL ) {
+ textRendererGLEL.reshape(drawable, 0, 0, width, height);
+ }
}
@Override
public void dispose(final GLAutoDrawable drawable) {
- textRendererGLEL.dispose(drawable);
- textRendererGLEL = null;
+ if( null != textRendererGLEL ) {
+ textRendererGLEL.dispose(drawable);
+ textRendererGLEL = null;
+ }
disposeImpl(drawable, true);
}
@@ -747,7 +758,7 @@ public class MovieSBSStereo implements StereoGLEventListener {
pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
pmvMatrix.glPushMatrix();
pmvMatrix.glTranslatef(0, 0, zoom);
- if(rotate > 0) {
+ if( rotate > 0) {
final float ang = ((System.currentTimeMillis() - startTime) * 360.0f) / 8000.0f;
pmvMatrix.glRotatef(ang, 0, 0, 1);
} else {
@@ -778,7 +789,9 @@ public class MovieSBSStereo implements StereoGLEventListener {
st.useProgram(gl, false);
pmvMatrix.glPopMatrix();
- textRendererGLEL.display(drawable);
+ if( null != textRendererGLEL ) {
+ textRendererGLEL.display(drawable);
+ }
}
static class StereoGLMediaEventListener implements GLMediaEventListener {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java
index 0d1191528..d963294b4 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java
@@ -30,7 +30,6 @@ package com.jogamp.opengl.test.junit.jogl.demos.es2.av;
import java.io.File;
import java.io.IOException;
-import java.net.URI;
import java.net.URISyntaxException;
import java.nio.FloatBuffer;
@@ -46,8 +45,8 @@ import javax.media.opengl.GLProfile;
import javax.media.opengl.GLUniformData;
import javax.media.opengl.fixedfunc.GLMatrixFunc;
+import com.jogamp.common.net.Uri;
import com.jogamp.common.os.Platform;
-import com.jogamp.common.util.IOUtil;
import com.jogamp.graph.curve.Region;
import com.jogamp.graph.curve.opengl.GLRegion;
import com.jogamp.graph.curve.opengl.RegionRenderer;
@@ -122,13 +121,13 @@ public class MovieSimple implements GLEventListener {
private static final String myTextureLookupName = "myTexture2D";
/** Blender's Big Buck Bunny: 24f 416p H.264, AAC 48000 Hz, 2 ch, mpeg stream. */
- public static final URI defURI;
+ public static final Uri defURI;
static {
- URI _defURI = null;
+ Uri _defURI = null;
try {
// Blender's Big Buck Bunny Trailer: 24f 640p VP8, Vorbis 44100Hz mono, WebM/Matroska Stream.
// _defURI = new URI("http://video.webmfiles.org/big-buck-bunny_trailer.webm");
- _defURI = new URI("http://archive.org/download/BigBuckBunny_328/BigBuckBunny_512kb.mp4");
+ _defURI = Uri.cast("http://archive.org/download/BigBuckBunny_328/BigBuckBunny_512kb.mp4");
} catch (final URISyntaxException e) {
e.printStackTrace();
}
@@ -194,7 +193,7 @@ public class MovieSimple implements GLEventListener {
mPlayer.getAID(), mPlayer.getAudioBitrate()/1000, mPlayer.getAudioCodec());
final String text3 = String.format("video: id %d, kbps %d, codec %s",
mPlayer.getVID(), mPlayer.getVideoBitrate()/1000, mPlayer.getVideoCodec());
- final String text4 = mPlayer.getURI().getRawPath();
+ final String text4 = mPlayer.getUri().path.decode();
if( displayOSD && null != renderer ) {
// We share ClearColor w/ MovieSimple's init !
final float pixelSize = font.getPixelSize(fontSize, dpiH);
@@ -388,7 +387,7 @@ public class MovieSimple implements GLEventListener {
System.out.println("pC.1a shared "+mPlayerShared+", "+mPlayer);
}
- public void initStream(final URI streamLoc, final int vid, final int aid, final int textureCount) {
+ public void initStream(final Uri streamLoc, final int vid, final int aid, final int textureCount) {
mPlayer.initStream(streamLoc, vid, aid, textureCount);
System.out.println("pC.1b "+mPlayer);
}
@@ -988,14 +987,14 @@ public class MovieSimple implements GLEventListener {
}
origSize = _origSize;
}
- final URI streamLoc0;
+ final Uri streamLoc0;
if( null != urls_s[0] ) {
- streamLoc0 = new URI(urls_s[0]);
+ streamLoc0 = Uri.cast( urls_s[0] );
} else if( null != file_s1 ) {
final File movieFile = new File(file_s1);
- streamLoc0 = movieFile.toURI();
+ streamLoc0 = Uri.valueOf(movieFile);
} else if( null != file_s2 ) {
- streamLoc0 = IOUtil.toURISimple(new File(file_s2));
+ streamLoc0 = Uri.valueOf(new File(file_s2));
} else {
streamLoc0 = defURI;
}
@@ -1049,12 +1048,12 @@ public class MovieSimple implements GLEventListener {
windows[i].setVisible(true);
anim.add(windows[i]);
- final URI streamLocN;
+ final Uri streamLocN;
if( 0 == i ) {
streamLocN = streamLoc0;
} else {
if( null != urls_s[i] ) {
- streamLocN = new URI(urls_s[i]);
+ streamLocN = Uri.cast(urls_s[i]);
} else {
streamLocN = defURI;
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelAWT.java
index dd16b88cc..ae11c9d54 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelAWT.java
@@ -36,8 +36,10 @@ import java.awt.event.ComponentListener;
import java.lang.reflect.InvocationTargetException;
import javax.media.nativewindow.ScalableSurface;
+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;
import javax.media.opengl.awt.GLJPanel;
import javax.swing.JFrame;
@@ -137,6 +139,19 @@ public class TestGearsES2GLJPanelAWT extends UITestCase {
}
final SnapshotGLEventListener snap = new SnapshotGLEventListener();
glJPanel.addGLEventListener(snap);
+ glJPanel.addGLEventListener(new GLEventListener() {
+ @Override
+ public void init(final GLAutoDrawable drawable) { }
+ @Override
+ public void dispose(final GLAutoDrawable drawable) { }
+ @Override
+ public void display(final GLAutoDrawable drawable) { }
+ @Override
+ public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {
+ setTitle(frame, glJPanel, caps);
+ }
+
+ });
setTitle(frame, glJPanel, caps);
frame.setLocation(xpos, ypos);
@@ -213,6 +228,25 @@ public class TestGearsES2GLJPanelAWT extends UITestCase {
hasSurfacePixelScale1[0]+"x"+hasSurfacePixelScale1[1]+" (has)");
setTitle(frame, glJPanel, caps);
Assert.assertArrayEquals(hasSurfacePixelScale0, hasSurfacePixelScale1);
+ } else if(e.getKeyChar()=='m') {
+ final GLCapabilitiesImmutable capsPre = glJPanel.getChosenGLCapabilities();
+ final GLCapabilities capsNew = new GLCapabilities(capsPre.getGLProfile());
+ capsNew.copyFrom(capsPre);
+ final boolean msaa;
+ if( capsPre.getSampleBuffers() ) {
+ capsNew.setSampleBuffers(false);
+ msaa = false;
+ } else {
+ capsNew.setSampleBuffers(true);
+ capsNew.setNumSamples(4);
+ msaa = true;
+ }
+ System.err.println("[set MSAA "+msaa+" Caps had]: "+capsPre);
+ System.err.println("[set MSAA "+msaa+" Caps new]: "+capsNew);
+ System.err.println("XXX-A1: "+animator.toString());
+ glJPanel.setRequestedGLCapabilities(capsNew);
+ System.err.println("XXX-A2: "+animator.toString());
+ System.err.println("XXX: "+glJPanel.toString());
}
} };
new AWTKeyAdapter(kl, glJPanel).addTo(glJPanel);
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 cd5e20c40..29c5aac70 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
@@ -52,6 +52,7 @@ 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.util.AnimatorBase;
+import com.jogamp.opengl.util.Gamma;
import com.jogamp.opengl.util.PNGPixelRect;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
@@ -241,6 +242,9 @@ public class TestGearsES2NEWT extends UITestCase {
glWindow.addKeyListener(new KeyAdapter() {
int pointerIconIdx = 0;
+ float gamma = 1f;
+ float brightness = 0f;
+ float contrast = 1f;
@Override
public void keyPressed(final KeyEvent e) {
@@ -264,6 +268,15 @@ public class TestGearsES2NEWT extends UITestCase {
System.err.println("[set fullscreen post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets());
glWindow.setExclusiveContextThread(t);
} }.start();
+ } else if( e.getKeySymbol()== KeyEvent.VK_G ) {
+ new Thread() {
+ public void run() {
+ final float newGamma = gamma + ( e.isShiftDown() ? -0.1f : 0.1f );
+ System.err.println("[set gamma]: "+gamma+" -> "+newGamma);
+ if( Gamma.setDisplayGamma(glWindow, newGamma, brightness, contrast) ) {
+ gamma = newGamma;
+ }
+ } }.start();
} else if(e.getKeyChar()=='a') {
new Thread() {
public void run() {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java
index dbc760d15..9f97b4a21 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java
@@ -117,6 +117,36 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList
}
}
+ boolean enableCullFace = false;
+
+ private void enableStates(final GL gl, final boolean enable) {
+ final boolean msaa = gl.getContext().getGLDrawable().getChosenGLCapabilities().getSampleBuffers();
+ if( enable ) {
+ if( enableCullFace ) {
+ gl.glEnable(GL.GL_CULL_FACE);
+ }
+ gl.glEnable(GLLightingFunc.GL_LIGHTING);
+ gl.glEnable(GLLightingFunc.GL_LIGHT0);
+ gl.glEnable(GL.GL_DEPTH_TEST);
+ gl.glDepthFunc(GL.GL_LESS); // default
+ gl.glEnable(GLLightingFunc.GL_NORMALIZE);
+ if( msaa ) {
+ gl.glEnable(GL.GL_MULTISAMPLE);
+ }
+ } else {
+ if( enableCullFace ) {
+ gl.glDisable(GL.GL_CULL_FACE);
+ }
+ gl.glDisable(GLLightingFunc.GL_LIGHTING);
+ gl.glDisable(GLLightingFunc.GL_LIGHT0);
+ gl.glDisable(GL.GL_DEPTH_TEST);
+ gl.glDisable(GLLightingFunc.GL_NORMALIZE);
+ if( msaa ) {
+ gl.glDisable(GL.GL_MULTISAMPLE);
+ }
+ }
+ }
+
public void init(final GL2 gl) {
final float lightPos[] = { 5.0f, 5.0f, 10.0f, 0.0f };
final float red[] = { 0.8f, 0.1f, 0.0f, 0.7f };
@@ -134,11 +164,11 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList
gl.glLightfv(GLLightingFunc.GL_LIGHT0, GLLightingFunc.GL_POSITION, lightPos, 0);
if( ! ( flipVerticalInGLOrientation && gl.getContext().getGLDrawable().isGLOriented() ) ) {
// Only possible if we do not flip the projection matrix
- gl.glEnable(GL.GL_CULL_FACE);
+ enableCullFace = true;
+ } else {
+ enableCullFace = false;
}
- gl.glEnable(GLLightingFunc.GL_LIGHTING);
- gl.glEnable(GLLightingFunc.GL_LIGHT0);
- gl.glEnable(GL.GL_DEPTH_TEST);
+ enableStates(gl, true);
/* make the gears */
if(0>=gear1) {
@@ -174,7 +204,7 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList
System.err.println("gear3 list reused: "+gear3);
}
- gl.glEnable(GLLightingFunc.GL_NORMALIZE);
+ enableStates(gl, false);
}
@Override
@@ -196,12 +226,7 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList
}
public void reshape(final GL2 gl, final int tileX, final int tileY, final int tileWidth, final int tileHeight, final int imageWidth, final int imageHeight) {
- final boolean msaa = gl.getContext().getGLDrawable().getChosenGLCapabilities().getSampleBuffers();
- System.err.println(Thread.currentThread()+" Gears.reshape "+tileX+"/"+tileY+" "+tileWidth+"x"+tileHeight+" of "+imageWidth+"x"+imageHeight+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(gl.getContext().getGLDrawable().getHandle())+", msaa "+msaa+", tileRendererInUse "+tileRendererInUse);
-
- if( msaa ) {
- gl.glEnable(GL.GL_MULTISAMPLE);
- }
+ System.err.println(Thread.currentThread()+" Gears.reshape "+tileX+"/"+tileY+" "+tileWidth+"x"+tileHeight+" of "+imageWidth+"x"+imageHeight+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(gl.getContext().getGLDrawable().getHandle())+", tileRendererInUse "+tileRendererInUse);
// compute projection parameters 'normal'
float left, right, bottom, top;
@@ -244,10 +269,6 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList
gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
gl.glLoadIdentity();
gl.glTranslatef(0.0f, 0.0f, -40.0f);
-
- if( msaa ) {
- gl.glDisable(GL.GL_MULTISAMPLE);
- }
}
@Override
@@ -268,11 +289,8 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList
public void display(final GLAutoDrawable drawable) {
// Get the GL corresponding to the drawable we are animating
final GL2 gl = drawable.getGL().getGL2();
- final boolean msaa = gl.getContext().getGLDrawable().getChosenGLCapabilities().getSampleBuffers();
- if( msaa ) {
- gl.glEnable(GL.GL_MULTISAMPLE);
- }
+ enableStates(gl, true);
if( null == tileRendererInUse ) {
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
@@ -291,15 +309,13 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
}
displayImpl(gl);
- if( msaa ) {
- gl.glDisable(GL.GL_MULTISAMPLE);
- }
+
+ enableStates(gl, false);
}
+
public void display(final GL2 gl) {
- final boolean msaa = gl.getContext().getGLDrawable().getChosenGLCapabilities().getSampleBuffers();
- if( msaa ) {
- gl.glEnable(GL.GL_MULTISAMPLE);
- }
+ enableStates(gl, true);
+
if( null == tileRendererInUse ) {
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
} else {
@@ -307,14 +323,14 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList
}
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
displayImpl(gl);
- if( msaa ) {
- gl.glDisable(GL.GL_MULTISAMPLE);
- }
+
+ enableStates(gl, false);
}
+
private void displayImpl(final GL2 gl) {
if( doRotate ) {
// Turn the gears' teeth
- angle += 2.0f;
+ angle += 0.5f;
}
// Rotate the entire assembly of gears based on how the user
// dragged the mouse around
@@ -451,7 +467,7 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList
gl.glVertex3f(r1 * (float)Math.cos(0), r1 * (float)Math.sin(0), -width * 0.5f);
gl.glEnd();
- gl.glShadeModel(GLLightingFunc.GL_SMOOTH);
+ gl.glShadeModel(GLLightingFunc.GL_SMOOTH); // default
/* draw inside radius cylinder */
gl.glBegin(GL2.GL_QUAD_STRIP);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Teapot.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Teapot.java
index d29688b96..96d6fdba0 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Teapot.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Teapot.java
@@ -24,10 +24,46 @@ public class Teapot implements GLEventListener {
private GLUT glut;
/* glTexGen stuff: */
- private final float sgenparams[] = { 1.0f, 1.0f, 1.0f, 0.0f };
+ // private final float sgenparams[] = { 1.0f, 1.0f, 1.0f, 0.0f };
private Texture tex = null;
+ private void enableStates(final GL2 gl, final boolean enable) {
+ if( enable ) {
+ if( null != tex ) {
+ tex.bind(gl);
+ }
+ gl.glEnable(GL.GL_DEPTH_TEST);
+ gl.glDepthFunc(GL.GL_LESS); // default
+ // gl.glEnable(GL2.GL_TEXTURE_GEN_S);
+ // gl.glEnable(GL2.GL_TEXTURE_1D);
+ gl.glEnable(GL.GL_TEXTURE_2D);
+ gl.glEnable(GL.GL_CULL_FACE);
+ gl.glEnable(GLLightingFunc.GL_LIGHTING);
+ gl.glEnable(GLLightingFunc.GL_LIGHT0);
+ gl.glEnable(GL2.GL_AUTO_NORMAL);
+ gl.glEnable(GLLightingFunc.GL_NORMALIZE);
+ gl.glFrontFace(GL.GL_CW);
+ gl.glCullFace(GL.GL_BACK); // default
+ gl.glMaterialf(GL.GL_FRONT, GLLightingFunc.GL_SHININESS, 64.0f);
+ gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT);
+ } else {
+ if( null != tex ) {
+ gl.glBindTexture(tex.getTarget(), 0);
+ }
+ gl.glDisable(GL.GL_DEPTH_TEST);
+ // gl.glDisable(GL2.GL_TEXTURE_GEN_S);
+ // gl.glDisable(GL2.GL_TEXTURE_1D);
+ gl.glDisable(GL.GL_TEXTURE_2D);
+ gl.glDisable(GL.GL_CULL_FACE);
+ gl.glDisable(GLLightingFunc.GL_LIGHTING);
+ gl.glDisable(GLLightingFunc.GL_LIGHT0);
+ gl.glDisable(GL2.GL_AUTO_NORMAL);
+ gl.glDisable(GLLightingFunc.GL_NORMALIZE);
+ gl.glFrontFace(GL.GL_CCW); // default
+ }
+ }
+
@Override
public void init(final GLAutoDrawable drawable) {
final GL2 gl = drawable.getGL().getGL2();
@@ -41,7 +77,7 @@ public class Teapot implements GLEventListener {
} catch (final Exception e) {
e.printStackTrace();
}
- tex.bind(gl);
+ // tex.bind(gl);
// uncomment this and comment the above to see a working texture
// makeStripeImage();
@@ -57,24 +93,10 @@ public class Teapot implements GLEventListener {
// gl.glTexImage1D(GL2.GL_TEXTURE_1D, 0, 3, stripeImageWidth, 0,
// GL.GL_RGB, GL.GL_UNSIGNED_BYTE, stripeImageBuf);
- gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT);
+ // gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT);
// gl.glTexGeni(GL2.GL_S, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_OBJECT_LINEAR);
// gl.glTexGenfv(GL2.GL_S, GL2.GL_OBJECT_PLANE, sgenparams, 0);
-
- gl.glEnable(GL.GL_DEPTH_TEST);
- gl.glDepthFunc(GL.GL_LESS);
- // gl.glEnable(GL2.GL_TEXTURE_GEN_S);
- // gl.glEnable(GL2.GL_TEXTURE_1D);
- gl.glEnable(GL.GL_TEXTURE_2D);
- gl.glEnable(GL.GL_CULL_FACE);
- gl.glEnable(GLLightingFunc.GL_LIGHTING);
- gl.glEnable(GLLightingFunc.GL_LIGHT0);
- gl.glEnable(GL2.GL_AUTO_NORMAL);
- gl.glEnable(GLLightingFunc.GL_NORMALIZE);
- gl.glFrontFace(GL.GL_CW);
- gl.glCullFace(GL.GL_BACK);
- gl.glMaterialf(GL.GL_FRONT, GLLightingFunc.GL_SHININESS, 64.0f);
}
float angleZ = 0.0f;
@@ -85,8 +107,7 @@ public class Teapot implements GLEventListener {
public void display(final GLAutoDrawable gLDrawable) {
final GL2 gl = gLDrawable.getGL().getGL2();
- tex.bind(gl);
- gl.glEnable(GL.GL_TEXTURE_2D);
+ enableStates(gl, true);
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
gl.glPushMatrix();
@@ -101,13 +122,14 @@ public class Teapot implements GLEventListener {
rotDir = +1.0f;
}
angleZ += rotIncr * rotDir;
+
+ enableStates(gl, false);
}
@Override
public void reshape(final GLAutoDrawable gLDrawable, final int x, final int y, final int w, final int h) {
final GL2 gl = gLDrawable.getGL().getGL2();
- gl.glViewport(0, 0, w, h);
gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
gl.glLoadIdentity();
if (w <= h) {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/Bug818GLJPanelApplet.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/Bug818GLJPanelAndGLCanvasApplet.java
index 8280919e6..a153fc7ae 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/Bug818GLJPanelApplet.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/Bug818GLJPanelAndGLCanvasApplet.java
@@ -27,7 +27,9 @@
*/
package com.jogamp.opengl.test.junit.jogl.demos.gl2.awt;
+import java.awt.ComponentOrientation;
import java.awt.Dimension;
+import java.awt.GridLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.InputStream;
@@ -47,8 +49,10 @@ import javax.media.opengl.fixedfunc.GLLightingFunc;
import javax.media.opengl.fixedfunc.GLMatrixFunc;
import javax.media.opengl.fixedfunc.GLPointerFunc;
import javax.swing.JApplet;
+import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JFrame;
+import javax.swing.SwingConstants;
import com.jogamp.common.util.VersionUtil;
import com.jogamp.opengl.JoglVersion;
@@ -57,7 +61,7 @@ import com.jogamp.opengl.util.texture.Texture;
import com.jogamp.opengl.util.texture.TextureIO;
/**
- * Bug 818: OSX GLJPanel Crash
+ * Bug 818: OSX GLJPanel [and GLCanvas] Crash
* <pre>
* - NVIDIA GeForce GT 330M
* - GL_VENDOR: "NVIDIA Corporation"
@@ -66,7 +70,7 @@ import com.jogamp.opengl.util.texture.TextureIO;
* - Mac OSX 10.6.8
* </pre>
*/
-public class Bug818GLJPanelApplet extends JApplet {
+public class Bug818GLJPanelAndGLCanvasApplet extends JApplet {
private static final long serialVersionUID = 1L;
@@ -81,7 +85,7 @@ public class Bug818GLJPanelApplet extends JApplet {
static public void main(final String args[]) {
isApplet = false;
- final JApplet myApplet = new Bug818GLJPanelApplet();
+ final JApplet myApplet = new Bug818GLJPanelAndGLCanvasApplet();
appletHolder = new JPanel();
@@ -115,19 +119,25 @@ public class Bug818GLJPanelApplet extends JApplet {
public void init() {
final JPanel panel = new JPanel();
+ panel.setLayout(new GridLayout(2, 2));
+ System.err.println("Pre Orientation L2R: "+panel.getComponentOrientation().isLeftToRight());
+ panel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
+ System.err.println("Post Orientation L2R: "+panel.getComponentOrientation().isLeftToRight());
setContentPane(panel);
-
- final GLCanvas glCanvas = new GLCanvas();
- glCanvas.addGLEventListener(new JOGLQuad(true));
- animatorCanvas = new Animator(glCanvas);
- glCanvas.setPreferredSize(new Dimension(300, 300));
- panel.add(glCanvas);
+ panel.add(new JLabel("GLJPanel", SwingConstants.CENTER));
+ panel.add(new JLabel("GLCanvas", SwingConstants.CENTER));
final GLJPanel gljPanel = new GLJPanel();
gljPanel.addGLEventListener(new JOGLQuad(false));
animatorPanel = new Animator(gljPanel);
gljPanel.setPreferredSize(new Dimension(300, 300));
panel.add(gljPanel);
+
+ final GLCanvas glCanvas = new GLCanvas();
+ glCanvas.addGLEventListener(new JOGLQuad(true));
+ animatorCanvas = new Animator(glCanvas);
+ glCanvas.setPreferredSize(new Dimension(300, 300));
+ panel.add(glCanvas);
}
@Override
@@ -271,7 +281,7 @@ public class Bug818GLJPanelApplet extends JApplet {
// set the color of the quad
if (canvas) {
- gl.glColor3f(0.2f, 1.0f, 1.0f);
+ gl.glColor3f(0.2f, 0.2f, 1.0f);
} else {
gl.glColor3f(1.0f, 0.2f, 0.2f);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/GLJPanelsAndGLCanvasDemoGL2Applet.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/GLJPanelsAndGLCanvasDemoGL2Applet.java
new file mode 100644
index 000000000..fcff9e56b
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/GLJPanelsAndGLCanvasDemoGL2Applet.java
@@ -0,0 +1,180 @@
+/**
+ * Copyright 2013 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.opengl.test.junit.jogl.demos.gl2.awt;
+
+import java.awt.ComponentOrientation;
+import java.awt.Dimension;
+import java.awt.GridLayout;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+import javax.media.opengl.awt.GLCanvas;
+import javax.media.opengl.awt.GLJPanel;
+import javax.swing.JApplet;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JFrame;
+import javax.swing.SwingConstants;
+
+import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears;
+import com.jogamp.opengl.test.junit.jogl.demos.gl2.Teapot;
+import com.jogamp.opengl.util.Animator;
+
+/**
+ */
+public class GLJPanelsAndGLCanvasDemoGL2Applet extends JApplet {
+
+ private static final long serialVersionUID = 1L;
+
+ private Animator[] animator;
+
+ public static JFrame frame;
+ public static JPanel appletHolder;
+ public static boolean isApplet = true;
+
+ static public void main(final String args[]) {
+ isApplet = false;
+
+ final JApplet myApplet = new GLJPanelsAndGLCanvasDemoGL2Applet();
+
+ appletHolder = new JPanel();
+
+ frame = new JFrame("Bug818GLJPanelApplet");
+ frame.getContentPane().add(myApplet);
+
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.addWindowListener(new WindowAdapter() {
+ public void windowClosing(final WindowEvent e) {
+ System.exit(0);
+ }
+ });
+
+ try {
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ myApplet.init();
+ frame.validate();
+ frame.pack();
+ frame.setVisible(true);
+ } } );
+ } catch( final Throwable throwable ) {
+ throwable.printStackTrace();
+ }
+
+ myApplet.start();
+ }
+
+
+ @Override
+ public void init() {
+
+ final JPanel panel = new JPanel();
+ panel.setLayout(new GridLayout(3, 2));
+ System.err.println("Pre Orientation L2R: "+panel.getComponentOrientation().isLeftToRight());
+ panel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
+ System.err.println("Post Orientation L2R: "+panel.getComponentOrientation().isLeftToRight());
+ setContentPane(panel);
+
+ animator = new Animator[3*2];
+ int animIdx = 0;
+
+ panel.add(new JLabel("GLJPanel Auto V-Flip", SwingConstants.CENTER));
+ {
+ {
+ final GLJPanel gljPanel = new GLJPanel();
+ gljPanel.addGLEventListener(new Teapot());
+ animator[animIdx++] = new Animator(gljPanel);
+ gljPanel.setPreferredSize(new Dimension(300, 300));
+ panel.add(gljPanel);
+ }
+ {
+ final GLJPanel gljPanel = new GLJPanel();
+ gljPanel.addGLEventListener(new Gears(0));
+ animator[animIdx++] = new Animator(gljPanel);
+ gljPanel.setPreferredSize(new Dimension(300, 300));
+ panel.add(gljPanel);
+ }
+ }
+ panel.add(new JLabel("GLJPanel User V-Flip", SwingConstants.CENTER));
+ {
+ {
+ final GLJPanel gljPanel = new GLJPanel();
+ gljPanel.setSkipGLOrientationVerticalFlip(true);
+ gljPanel.addGLEventListener(new Teapot());
+ animator[animIdx++] = new Animator(gljPanel);
+ gljPanel.setPreferredSize(new Dimension(300, 300));
+ panel.add(gljPanel);
+ }
+ {
+ final GLJPanel gljPanel = new GLJPanel();
+ gljPanel.setSkipGLOrientationVerticalFlip(true);
+ gljPanel.addGLEventListener(new Gears(0));
+ animator[animIdx++] = new Animator(gljPanel);
+ gljPanel.setPreferredSize(new Dimension(300, 300));
+ panel.add(gljPanel);
+ }
+ }
+
+ panel.add(new JLabel("GLCanvas", SwingConstants.CENTER));
+ {
+ {
+ final GLCanvas glCanvas = new GLCanvas();
+ glCanvas.addGLEventListener(new Teapot());
+ animator[animIdx++] = new Animator(glCanvas);
+ glCanvas.setPreferredSize(new Dimension(300, 300));
+ panel.add(glCanvas);
+ }
+ {
+ final GLCanvas glCanvas = new GLCanvas();
+ glCanvas.addGLEventListener(new Gears(1));
+ animator[animIdx++] = new Animator(glCanvas);
+ glCanvas.setPreferredSize(new Dimension(300, 300));
+ panel.add(glCanvas);
+ }
+ }
+ }
+
+ @Override
+ public void start() {
+ for(int i=0; i<animator.length; i++) {
+ animator[i].start();
+ animator[i].setUpdateFPSFrames(60, System.err);
+ }
+ }
+
+ @Override
+ public void stop() {
+ for(int i=0; i<animator.length; i++) {
+ animator[i].stop();
+ }
+ }
+
+ @Override
+ public void destroy() {}
+}
+
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsGLJPanelAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsGLJPanelAWT.java
index 3650e4955..f47a9b794 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsGLJPanelAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsGLJPanelAWT.java
@@ -30,6 +30,7 @@ package com.jogamp.opengl.test.junit.jogl.demos.gl2.awt;
import javax.media.opengl.*;
+import com.jogamp.newt.event.KeyEvent;
import com.jogamp.newt.event.TraceKeyAdapter;
import com.jogamp.newt.event.TraceWindowAdapter;
import com.jogamp.newt.event.awt.AWTKeyAdapter;
@@ -121,6 +122,56 @@ public class TestGearsGLJPanelAWT extends UITestCase {
new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter), glJPanel).addTo(glJPanel);
new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter), glJPanel).addTo(frame);
+ final com.jogamp.newt.event.KeyListener kl = new com.jogamp.newt.event.KeyAdapter() {
+ @Override
+ public void keyPressed(final KeyEvent e) {
+ if( e.isAutoRepeat() ) {
+ return;
+ }
+ if(e.getKeyChar()=='m') {
+ final GLCapabilitiesImmutable capsPre = glJPanel.getChosenGLCapabilities();
+ final GLCapabilities capsNew = new GLCapabilities(capsPre.getGLProfile());
+ capsNew.copyFrom(capsPre);
+ final boolean msaa;
+ if( capsPre.getSampleBuffers() ) {
+ capsNew.setSampleBuffers(false);
+ capsNew.setDoubleBuffered(false);
+ msaa = false;
+ } else {
+ capsNew.setSampleBuffers(true);
+ capsNew.setNumSamples(4);
+ msaa = true;
+ }
+ System.err.println("[set MSAA "+msaa+" Caps had]: "+capsPre);
+ System.err.println("[set MSAA "+msaa+" Caps new]: "+capsNew);
+ System.err.println("XXX-A1: "+animator.toString());
+ glJPanel.setRequestedGLCapabilities(capsNew);
+ System.err.println("XXX-A2: "+animator.toString());
+ System.err.println("XXX: "+glJPanel.toString());
+ } else if(e.getKeyChar()=='b') {
+ final GLCapabilitiesImmutable capsPre = glJPanel.getChosenGLCapabilities();
+ final GLCapabilities capsNew = new GLCapabilities(capsPre.getGLProfile());
+ capsNew.copyFrom(capsPre);
+ final boolean bmp;
+ if( capsPre.isBitmap() ) {
+ capsNew.setBitmap(false); // auto-choose
+ bmp = false;
+ } else {
+ capsNew.setBitmap(true);
+ capsNew.setFBO(false);
+ capsNew.setPBuffer(false);
+ bmp = true;
+ }
+ System.err.println("[set Bitmap "+bmp+" Caps had]: "+capsPre);
+ System.err.println("[set Bitmap "+bmp+" Caps new]: "+capsNew);
+ System.err.println("XXX-A1: "+animator.toString());
+ glJPanel.setRequestedGLCapabilities(capsNew);
+ System.err.println("XXX-A2: "+animator.toString());
+ System.err.println("XXX: "+glJPanel.toString());
+ }
+ } };
+ new AWTKeyAdapter(kl, glJPanel).addTo(glJPanel);
+
final long t0 = System.currentTimeMillis();
long t1 = t0;
boolean triggerSnap = false;
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TessellationShader01aGL4.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TessellationShader01aGL4.java
new file mode 100644
index 000000000..a5807a096
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TessellationShader01aGL4.java
@@ -0,0 +1,191 @@
+/**
+ * Copyright 2014 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.opengl.test.junit.jogl.demos.gl4;
+
+import java.nio.FloatBuffer;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2ES2;
+import javax.media.opengl.GL2ES3;
+import javax.media.opengl.GL2GL3;
+import javax.media.opengl.GL4;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLEventListener;
+
+import com.jogamp.opengl.util.glsl.ShaderCode;
+import com.jogamp.opengl.util.glsl.ShaderProgram;
+
+/**
+ * JOGL Tessellation ShaderCode GL4 test case.
+ * <p>
+ * Demonstrates tessellation-control and -evaluation shaders.
+ * </p>
+ *
+ * @author Raymond L. Rivera, 2014
+ * @author Sven Gothel
+ */
+public class TessellationShader01aGL4 implements GLEventListener {
+ private static final double ANIMATION_RATE = 950.0;
+
+ private ShaderProgram program;
+ private final int[] vertexArray = new int[1];
+ private FloatBuffer vertexOffset;
+ private FloatBuffer backgroundColor;
+
+
+ @Override
+ public void init(final GLAutoDrawable auto) {
+ final double theta = System.currentTimeMillis() / ANIMATION_RATE;
+ vertexOffset = FloatBuffer.allocate(4);
+ vertexOffset.put(0, (float)(Math.sin(theta) * 0.5f));
+ vertexOffset.put(1, (float)(Math.cos(theta) * 0.6f));
+ vertexOffset.put(2, 0.0f);
+ vertexOffset.put(3, 0.0f);
+
+ backgroundColor = FloatBuffer.allocate(4);
+ backgroundColor.put(0, 0.25f);
+ backgroundColor.put(1, 0.25f);
+ backgroundColor.put(2, 0.25f);
+ backgroundColor.put(3, 1.0f);
+
+ final GL4 gl = auto.getGL().getGL4();
+ program = createProgram(auto);
+ gl.glGenVertexArrays(vertexArray.length, vertexArray, 0);
+ gl.glBindVertexArray(vertexArray[0]);
+ gl.glPatchParameteri(GL4.GL_PATCH_VERTICES, 3);
+ gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL2GL3.GL_LINE);
+ }
+
+ @Override
+ public void display(final GLAutoDrawable auto) {
+ final GL4 gl = auto.getGL().getGL4();
+ final double value = System.currentTimeMillis() / ANIMATION_RATE;
+ gl.glClearBufferfv(GL2ES3.GL_COLOR, 0, backgroundColor);
+ gl.glUseProgram(program.program());
+ vertexOffset.put(0, (float)(Math.sin(value) * 0.5f));
+ vertexOffset.put(1, (float)(Math.cos(value) * 0.6f));
+ gl.glVertexAttrib4fv(0, vertexOffset);
+ gl.glDrawArrays(GL4.GL_PATCHES, 0, 3);
+ }
+
+ @Override
+ public void dispose(final GLAutoDrawable auto) {
+ final GL4 gl = auto.getGL().getGL4();
+ gl.glDeleteVertexArrays(vertexArray.length, vertexArray, 0);
+ program.destroy(gl);
+ }
+
+ @Override
+ public void reshape(final GLAutoDrawable auto, final int x, final int y, final int width, final int height) {
+ // final GL4 gl = auto.getGL().getGL4();
+ }
+
+ private ShaderProgram createProgram(final GLAutoDrawable auto) {
+ final GL4 gl = auto.getGL().getGL4();
+ final String vertexSource =
+ "#version 440 core \n" +
+ " \n" +
+ "layout (location = 0) in vec4 offset; \n" +
+ " \n" +
+ "void main(void) \n" +
+ "{ \n" +
+ " const vec4 vertices[3] = vec4[3] ( \n" +
+ " vec4( 0.25, 0.25, 0.5, 1.0), \n" +
+ " vec4(-0.25, -0.25, 0.5, 1.0), \n" +
+ " vec4( 0.25, -0.25, 0.5, 1.0)); \n" +
+ " gl_Position = vertices[gl_VertexID] + offset; \n" +
+ "} \n";
+ final String tessCtrlSource =
+ "#version 440 core \n" +
+ "layout (vertices = 3) out; \n" +
+ " \n" +
+ "void main(void) \n" +
+ "{ \n" +
+ " if (gl_InvocationID == 0) \n" +
+ " { \n" +
+ " gl_TessLevelInner[0] = 5.0; \n" +
+ " gl_TessLevelOuter[0] = 5.0; \n" +
+ " gl_TessLevelOuter[1] = 5.0; \n" +
+ " gl_TessLevelOuter[2] = 5.0; \n" +
+ " } \n" +
+ " gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;\n" +
+ "} \n";
+ final String tessEvalSource =
+ "#version 440 core \n" +
+ " \n" +
+ "layout (triangles, equal_spacing, cw) in; \n" +
+ " \n" +
+ "void main(void) \n" +
+ "{ \n" +
+ " gl_Position = (gl_TessCoord.x * gl_in[0].gl_Position) + \n" +
+ " (gl_TessCoord.y * gl_in[1].gl_Position) + \n" +
+ " (gl_TessCoord.z * gl_in[2].gl_Position); \n" +
+ "} \n";
+ final String fragmentSource =
+ "#version 440 core \n" +
+ " \n" +
+ "out vec4 color; \n" +
+ " \n" +
+ "void main(void) \n" +
+ "{ \n" +
+ " color = vec4(1.0, 1.0, 1.0, 1.0); \n" +
+ "} \n";
+
+ final ShaderCode vertexShader = createShader(gl, GL2ES2.GL_VERTEX_SHADER, vertexSource);
+ final ShaderCode tessCtrlShader = createShader(gl, GL4.GL_TESS_CONTROL_SHADER, tessCtrlSource);
+ final ShaderCode tessEvalShader = createShader(gl, GL4.GL_TESS_EVALUATION_SHADER, tessEvalSource);
+ final ShaderCode fragmentShader = createShader(gl, GL2ES2.GL_FRAGMENT_SHADER, fragmentSource);
+
+ final ShaderProgram program = new ShaderProgram();
+
+ program.init(gl);
+ program.add(vertexShader);
+ program.add(tessCtrlShader);
+ program.add(tessEvalShader);
+ program.add(fragmentShader);
+
+ program.link(gl, System.err);
+ if(!program.validateProgram(gl, System.out))
+ System.err.println("[error] Program linking failed.");
+
+ return program;
+ }
+
+ private ShaderCode createShader(final GL4 gl, final int shaderType, final String source) {
+ final String[][] sources = new String[1][1];
+ sources[0] = new String[]{ source };
+ final ShaderCode shader = new ShaderCode(shaderType, sources.length, sources);
+
+ final boolean compiled = shader.compile(gl, System.err);
+ if (!compiled)
+ System.err.println("[error] Shader compilation failed.");
+
+ return shader;
+ }
+
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TessellationShader01bGL4.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TessellationShader01bGL4.java
new file mode 100644
index 000000000..7be26e400
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TessellationShader01bGL4.java
@@ -0,0 +1,142 @@
+/**
+ * Copyright 2014 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.opengl.test.junit.jogl.demos.gl4;
+
+import java.nio.FloatBuffer;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2ES2;
+import javax.media.opengl.GL2ES3;
+import javax.media.opengl.GL2GL3;
+import javax.media.opengl.GL4;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLException;
+
+import com.jogamp.opengl.util.glsl.ShaderCode;
+import com.jogamp.opengl.util.glsl.ShaderProgram;
+
+/**
+ * JOGL Tessellation ShaderCode GL4 test case.
+ * <p>
+ * Demonstrates tessellation-control and -evaluation shaders.
+ * </p>
+ *
+ * @author Raymond L. Rivera, 2014
+ * @author Sven Gothel
+ */
+public class TessellationShader01bGL4 implements GLEventListener {
+ private static final double ANIMATION_RATE = 950.0;
+
+ private ShaderProgram program;
+ private final int[] vertexArray = new int[1];
+ private FloatBuffer vertexOffset;
+ private FloatBuffer backgroundColor;
+
+
+ @Override
+ public void init(final GLAutoDrawable auto) {
+ final double theta = System.currentTimeMillis() / ANIMATION_RATE;
+ vertexOffset = FloatBuffer.allocate(4);
+ vertexOffset.put(0, (float)(Math.sin(theta) * 0.5f));
+ vertexOffset.put(1, (float)(Math.cos(theta) * 0.6f));
+ vertexOffset.put(2, 0.0f);
+ vertexOffset.put(3, 0.0f);
+
+ backgroundColor = FloatBuffer.allocate(4);
+ backgroundColor.put(0, 0.25f);
+ backgroundColor.put(1, 0.25f);
+ backgroundColor.put(2, 0.25f);
+ backgroundColor.put(3, 1.0f);
+
+ final GL4 gl = auto.getGL().getGL4();
+ program = createProgram(auto);
+ gl.glGenVertexArrays(vertexArray.length, vertexArray, 0);
+ gl.glBindVertexArray(vertexArray[0]);
+ gl.glPatchParameteri(GL4.GL_PATCH_VERTICES, 3);
+ gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL2GL3.GL_LINE);
+ }
+
+ @Override
+ public void display(final GLAutoDrawable auto) {
+ final GL4 gl = auto.getGL().getGL4();
+ final double value = System.currentTimeMillis() / ANIMATION_RATE;
+ gl.glClearBufferfv(GL2ES3.GL_COLOR, 0, backgroundColor);
+ gl.glUseProgram(program.program());
+ vertexOffset.put(0, (float)(Math.sin(value) * 0.5f));
+ vertexOffset.put(1, (float)(Math.cos(value) * 0.6f));
+ gl.glVertexAttrib4fv(0, vertexOffset);
+ gl.glDrawArrays(GL4.GL_PATCHES, 0, 3);
+ }
+
+ @Override
+ public void dispose(final GLAutoDrawable auto) {
+ final GL4 gl = auto.getGL().getGL4();
+ gl.glDeleteVertexArrays(vertexArray.length, vertexArray, 0);
+ program.destroy(gl);
+ }
+
+ @Override
+ public void reshape(final GLAutoDrawable auto, final int x, final int y, final int width, final int height) {
+ // final GL4 gl = auto.getGL().getGL4();
+ }
+
+ static final String shaderBasename = "tess_example01";
+
+ private ShaderProgram createProgram(final GLAutoDrawable auto) {
+ final GL4 gl = auto.getGL().getGL4();
+
+ final ShaderProgram sp;
+ {
+ final ShaderCode vs, tcs, tes, fs;
+ vs = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, this.getClass(),
+ "shader", "shader/bin", shaderBasename, true);
+ tcs = ShaderCode.create(gl, GL4.GL_TESS_CONTROL_SHADER, this.getClass(),
+ "shader", "shader/bin", shaderBasename, true);
+ tes = ShaderCode.create(gl, GL4.GL_TESS_EVALUATION_SHADER, this.getClass(),
+ "shader", "shader/bin", shaderBasename, true);
+ fs = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, this.getClass(),
+ "shader", "shader/bin", shaderBasename, true);
+ vs.defaultShaderCustomization(gl, true, true);
+ tcs.defaultShaderCustomization(gl, true, true);
+ tes.defaultShaderCustomization(gl, true, true);
+ fs.defaultShaderCustomization(gl, true, true);
+
+ sp = new ShaderProgram();
+ sp.add(gl, vs, System.err);
+ sp.add(gl, tcs, System.err);
+ sp.add(gl, tes, System.err);
+ sp.add(gl, fs, System.err);
+ if(!sp.link(gl, System.err)) {
+ throw new GLException("Couldn't link program: "+sp);
+ }
+ }
+
+ return sp;
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/newt/TestTessellationShader01GL4NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/newt/TestTessellationShader01GL4NEWT.java
new file mode 100644
index 000000000..a05dcec06
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/newt/TestTessellationShader01GL4NEWT.java
@@ -0,0 +1,117 @@
+/**
+ * Copyright 2014 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.opengl.test.junit.jogl.demos.gl4.newt;
+
+import java.io.IOException;
+
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLProfile;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.FixMethodOrder;
+import org.junit.runners.MethodSorters;
+
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.test.junit.jogl.demos.gl4.TessellationShader01aGL4;
+import com.jogamp.opengl.test.junit.jogl.demos.gl4.TessellationShader01bGL4;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
+import com.jogamp.opengl.test.junit.util.QuitAdapter;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.Animator;
+
+/**
+ * Test Geometry shader demo TessellationShader01aGL4 and TessellationShader01bGL4
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestTessellationShader01GL4NEWT extends UITestCase {
+ static long duration = 500; // ms
+
+ static GLCapabilities getCaps(final String profile) {
+ if( !GLProfile.isAvailable(profile) ) {
+ System.err.println("Profile "+profile+" n/a");
+ return null;
+ }
+ return new GLCapabilities(GLProfile.get(profile));
+ }
+
+ @Test
+ public void test01_01a() throws InterruptedException {
+ final GLCapabilities caps = getCaps(GLProfile.GL4);
+ if( null == caps ) { return; }
+ testImpl(caps, new TessellationShader01aGL4());
+ }
+
+ @Test
+ public void test02_01b() throws InterruptedException {
+ final GLCapabilities caps = getCaps(GLProfile.GL4);
+ if( null == caps ) { return; }
+ testImpl(caps, new TessellationShader01bGL4());
+ }
+
+ private void testImpl(final GLCapabilities caps, final GLEventListener glel) throws InterruptedException {
+ final GLWindow glWindow = GLWindow.create(caps);
+ Assert.assertNotNull(glWindow);
+ glWindow.setSize(800, 600);
+ glWindow.setVisible(true);
+ glWindow.setTitle("JOGL Tessellation Shader Test");
+ Assert.assertTrue(glWindow.isNativeValid());
+
+ final QuitAdapter quitAdapter = new QuitAdapter();
+ glWindow.addKeyListener(quitAdapter);
+ glWindow.addWindowListener(quitAdapter);
+ glWindow.addGLEventListener( glel );
+
+ final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener();
+ glWindow.addGLEventListener(snapshotGLEventListener);
+
+ final Animator animator = new Animator(glWindow);
+ animator.start();
+
+ animator.setUpdateFPSFrames(60, System.err);
+ snapshotGLEventListener.setMakeSnapshot();
+
+ while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
+ Thread.sleep(100);
+ }
+
+ animator.stop();
+ glWindow.destroy();
+ }
+
+ public static void main(final String args[]) throws IOException {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ duration = MiscUtils.atol(args[i], duration);
+ }
+ }
+ org.junit.runner.JUnitCore.main(TestTessellationShader01GL4NEWT.class.getName());
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/shader/tess_example01.fp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/shader/tess_example01.fp
new file mode 100644
index 000000000..8a3b23203
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/shader/tess_example01.fp
@@ -0,0 +1,6 @@
+
+out vec4 color;
+
+void main(void) {
+ color = vec4(1.0, 1.0, 1.0, 1.0);
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/shader/tess_example01.tcp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/shader/tess_example01.tcp
new file mode 100644
index 000000000..b76aa580d
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/shader/tess_example01.tcp
@@ -0,0 +1,12 @@
+
+layout (vertices = 3) out;
+
+void main(void) {
+ if (gl_InvocationID == 0) {
+ gl_TessLevelInner[0] = 5.0;
+ gl_TessLevelOuter[0] = 5.0;
+ gl_TessLevelOuter[1] = 5.0;
+ gl_TessLevelOuter[2] = 5.0;
+ }
+ gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/shader/tess_example01.tep b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/shader/tess_example01.tep
new file mode 100644
index 000000000..9c307f5d4
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/shader/tess_example01.tep
@@ -0,0 +1,8 @@
+
+layout (triangles, equal_spacing, cw) in;
+
+void main(void) {
+ gl_Position = (gl_TessCoord.x * gl_in[0].gl_Position) +
+ (gl_TessCoord.y * gl_in[1].gl_Position) +
+ (gl_TessCoord.z * gl_in[2].gl_Position);
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/shader/tess_example01.vp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/shader/tess_example01.vp
new file mode 100644
index 000000000..c207c1335
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/shader/tess_example01.vp
@@ -0,0 +1,12 @@
+
+layout (location = 0) in vec4 offset;
+
+void main(void)
+{
+ const vec4 vertices[3] =
+ vec4[3] (
+ vec4( 0.25, 0.25, 0.5, 1.0),
+ vec4(-0.25, -0.25, 0.5, 1.0),
+ vec4( 0.25, -0.25, 0.5, 1.0) );
+ gl_Position = vertices[gl_VertexID] + offset;
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java
index b3e01ac0f..57d6caa85 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java
@@ -67,7 +67,7 @@ public class TestGLSLShaderState01NEWT extends UITestCase {
@Test
public void test00NoShaderState_Validation() throws InterruptedException {
// preset ..
- final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(
+ final NEWTGLContext.WindowContext winctx = NEWTGLContext.createWindow(
new GLCapabilities(GLProfile.getGL2ES2()), 480, 480, true);
final GLDrawable drawable = winctx.context.getGLDrawable();
final GL2ES2 gl = winctx.context.getGL().getGL2ES2();
@@ -183,7 +183,7 @@ public class TestGLSLShaderState01NEWT extends UITestCase {
@Test
public void test01ShaderState_Validation() throws InterruptedException {
// preset ..
- final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(
+ final NEWTGLContext.WindowContext winctx = NEWTGLContext.createWindow(
new GLCapabilities(GLProfile.getGL2ES2()), 480, 480, true);
final GLDrawable drawable = winctx.context.getGLDrawable();
final GL2ES2 gl = winctx.context.getGL().getGL2ES2();
@@ -306,7 +306,7 @@ public class TestGLSLShaderState01NEWT extends UITestCase {
private void testShaderState_PerformanceSingleImpl(final boolean toggleEnable) throws InterruptedException {
// preset ..
- final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(
+ final NEWTGLContext.WindowContext winctx = NEWTGLContext.createWindow(
new GLCapabilities(GLProfile.getGL2ES2()), 480, 480, false);
final GLDrawable drawable = winctx.context.getGLDrawable();
final GL2ES2 gl = winctx.context.getGL().getGL2ES2();
@@ -395,7 +395,7 @@ public class TestGLSLShaderState01NEWT extends UITestCase {
@Test(timeout=240000)
public void test04ShaderState_PerformanceDouble() throws InterruptedException {
// preset ..
- final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(
+ final NEWTGLContext.WindowContext winctx = NEWTGLContext.createWindow(
new GLCapabilities(GLProfile.getGL2ES2()), 480, 480, false);
final GLDrawable drawable = winctx.context.getGLDrawable();
final GL2ES2 gl = winctx.context.getGL().getGL2ES2();
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java
index 21d945470..501850c4f 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java
@@ -74,7 +74,7 @@ public class TestGLSLShaderState02NEWT extends UITestCase {
private void testShaderState01Validation(final boolean linkSP1) throws InterruptedException {
// preset ..
- final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(
+ final NEWTGLContext.WindowContext winctx = NEWTGLContext.createWindow(
new GLCapabilities(GLProfile.getGL2ES2()), 480, 480, true);
final GLDrawable drawable = winctx.context.getGLDrawable();
final GL2ES2 gl = winctx.context.getGL().getGL2ES2();
@@ -240,7 +240,7 @@ public class TestGLSLShaderState02NEWT extends UITestCase {
@Test(timeout=240000)
public void testShaderState01PerformanceDouble() throws InterruptedException {
// preset ..
- final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(
+ final NEWTGLContext.WindowContext winctx = NEWTGLContext.createWindow(
new GLCapabilities(GLProfile.getGL2ES2()), 480, 480, false);
final GLDrawable drawable = winctx.context.getGLDrawable();
final GL2ES2 gl = winctx.context.getGL().getGL2ES2();
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestTransformFeedbackVaryingsBug407NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestTransformFeedbackVaryingsBug407NEWT.java
index 71b2d488e..e267d93b1 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestTransformFeedbackVaryingsBug407NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestTransformFeedbackVaryingsBug407NEWT.java
@@ -88,7 +88,7 @@ public class TestTransformFeedbackVaryingsBug407NEWT extends UITestCase {
final static String glps = GLProfile.GL3;
private NEWTGLContext.WindowContext prepareTest() throws GLException, InterruptedException {
- final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(
+ final NEWTGLContext.WindowContext winctx = NEWTGLContext.createWindow(
new GLCapabilities(GLProfile.getMaxProgrammable(true)), 480, 480, debugGL);
if(!winctx.context.getGL().isGL3()) {
System.err.println("GL3 not available");
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit01AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit01AWT.java
index 92785ef6e..0db2afc32 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit01AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit01AWT.java
@@ -31,6 +31,8 @@ import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import javax.media.opengl.GLAnimatorControl;
@@ -52,13 +54,15 @@ import org.junit.Test;
import org.junit.runners.MethodSorters;
import com.jogamp.common.os.Platform;
+import com.jogamp.newt.awt.NewtCanvasAWT;
+import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.util.Animator;
/**
- * Multiple GLJPanels in a JFrame's Grid
+ * Tests multiple [GLJPanels, GLCanvas or NewtCanvasAWT] in a JFrame's Grid
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestPerf001GLJPanelInit01AWT extends UITestCase {
@@ -69,15 +73,26 @@ public class TestPerf001GLJPanelInit01AWT extends UITestCase {
GLProfile.initSingleton();
}
+ static enum CanvasType { GLCanvas_T, GLJPanel_T, NewtCanvasAWT_T };
+
+ static class GLADComp {
+ GLADComp(final GLAutoDrawable glad, final Component comp) {
+ this.glad = glad;
+ this.comp = comp;
+ }
+ final GLAutoDrawable glad;
+ final Component comp;
+ }
public void test(final GLCapabilitiesImmutable caps, final boolean useGears, final int width, final int height, final int rows,
- final int columns, final boolean useGLJPanel, final boolean useAnim) {
+ final int columns, final CanvasType canvasType, final boolean useAnim) {
final GLAnimatorControl animator = useAnim ? new Animator() : null;
final JFrame frame;
final JPanel panel;
+ final List<NewtCanvasAWT> newtCanvasAWTList = new ArrayList<NewtCanvasAWT>();
panel = new JPanel();
- frame = new JFrame("DemoGLJPanelGridAWT");
+ frame = new JFrame(getSimpleTestName("."));
panel.setLayout(new GridLayout(rows, columns));
// panel.setBounds(0, 0, width, height);
@@ -94,8 +109,21 @@ public class TestPerf001GLJPanelInit01AWT extends UITestCase {
public void run() {
t[0] = Platform.currentTimeMillis();
for(int i=0; i<panelCount; i++) {
- final GLAutoDrawable glad = useGLJPanel ? createGLJPanel(caps, useGears, animator, eSize) : createGLCanvas(caps, useGears, animator, eSize);
- glad.addGLEventListener(new GLEventListener() {
+ final GLADComp gladComp;
+ switch(canvasType) {
+ case GLCanvas_T:
+ gladComp = createGLCanvas(caps, useGears, animator, eSize);
+ break;
+ case GLJPanel_T:
+ gladComp = createGLJPanel(caps, useGears, animator, eSize);
+ break;
+ case NewtCanvasAWT_T:
+ gladComp = createNewtCanvasAWT(caps, useGears, animator, eSize);
+ newtCanvasAWTList.add((NewtCanvasAWT)gladComp.comp);
+ break;
+ default: throw new InternalError("XXX");
+ }
+ gladComp.glad.addGLEventListener(new GLEventListener() {
@Override
public void init(final GLAutoDrawable drawable) {
initCount.getAndIncrement();
@@ -107,7 +135,7 @@ public class TestPerf001GLJPanelInit01AWT extends UITestCase {
@Override
public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {}
});
- panel.add((Component)glad);
+ panel.add(gladComp.comp);
}
t[1] = Platform.currentTimeMillis();
frame.getContentPane().add(panel);
@@ -136,7 +164,7 @@ public class TestPerf001GLJPanelInit01AWT extends UITestCase {
final double panelCountF = initCount.get();
System.err.printf("P: %d %s:%n\tctor\t%6d/t %6.2f/1%n\tvisible\t%6d/t %6.2f/1%n\tsum-i\t%6d/t %6.2f/1%n",
initCount.get(),
- useGLJPanel?"GLJPanel":"GLCanvas",
+ canvasType,
t[1]-t[0], (t[1]-t[0])/panelCountF,
t[3]-t[1], (t[3]-t[1])/panelCountF,
t[3]-t[0], (t[3]-t[0])/panelCountF);
@@ -144,15 +172,24 @@ public class TestPerf001GLJPanelInit01AWT extends UITestCase {
if( wait ) {
UITestCase.waitForKey("Post-Init");
}
+ if( null != animator ) {
+ animator.start();
+ }
try {
Thread.sleep(duration);
} catch (final InterruptedException e1) {
e1.printStackTrace();
}
+ if( null != animator ) {
+ animator.stop();
+ }
t[4] = Platform.currentTimeMillis();
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
+ while( !newtCanvasAWTList.isEmpty() ) {
+ newtCanvasAWTList.remove(0).destroy(); // removeNotify does not destroy GLWindow
+ }
frame.dispose();
} } );
} catch (final Exception e1) {
@@ -166,46 +203,76 @@ public class TestPerf001GLJPanelInit01AWT extends UITestCase {
System.err.println("Total: "+(t[4]-t[0]));
}
- private GLAutoDrawable createGLCanvas(final GLCapabilitiesImmutable caps, final boolean useGears, final GLAnimatorControl anim, final Dimension size) {
+ private GLADComp createNewtCanvasAWT(final GLCapabilitiesImmutable caps, final boolean useGears, final GLAnimatorControl anim, final Dimension size) {
+ final GLWindow window = GLWindow.create(caps);
+ final NewtCanvasAWT canvas = new NewtCanvasAWT(window);
+ canvas.setSize(size);
+ canvas.setPreferredSize(size);
+ if( useGears ) {
+ final GearsES2 g = new GearsES2(0);
+ g.setVerbose(false);
+ window.addGLEventListener(g);
+ }
+ if( null != anim ) {
+ anim.add(window);
+ }
+ return new GLADComp(window, canvas);
+ }
+ private GLADComp createGLCanvas(final GLCapabilitiesImmutable caps, final boolean useGears, final GLAnimatorControl anim, final Dimension size) {
final GLCanvas canvas = new GLCanvas(caps);
canvas.setSize(size);
canvas.setPreferredSize(size);
if( useGears ) {
- canvas.addGLEventListener(new GearsES2());
+ canvas.addGLEventListener(new GearsES2(0));
}
if( null != anim ) {
anim.add(canvas);
}
- return canvas;
+ return new GLADComp(canvas, canvas);
}
- private GLAutoDrawable createGLJPanel(final GLCapabilitiesImmutable caps, final boolean useGears, final GLAnimatorControl anim, final Dimension size) {
+ private GLADComp createGLJPanel(final GLCapabilitiesImmutable caps, final boolean useGears, final GLAnimatorControl anim, final Dimension size) {
final GLJPanel canvas = new GLJPanel(caps);
canvas.setSize(size);
canvas.setPreferredSize(size);
if( useGears ) {
- canvas.addGLEventListener(new GearsES2());
+ canvas.addGLEventListener(new GearsES2(0));
}
if( null != anim ) {
anim.add(canvas);
}
- return canvas;
+ return new GLADComp(canvas, canvas);
}
- @Test
- public void test01NopGLJPanelDef() throws InterruptedException, InvocationTargetException {
- test(new GLCapabilities(null), false /*useGears*/, width, height, rows, cols, true /* useGLJPanel */, false /*useAnim*/);
+ // @Test
+ public void test01NopGLJPanel() throws InterruptedException, InvocationTargetException {
+ test(new GLCapabilities(null), false /*useGears*/, width, height, rows, cols, CanvasType.GLJPanel_T, false /*useAnim*/);
}
- @Test
- public void test02NopGLJPanelBitmap() throws InterruptedException, InvocationTargetException {
+ // @Test
+ public void test02NopGLJPanelBMP() throws InterruptedException, InvocationTargetException {
final GLCapabilities caps = new GLCapabilities(null);
caps.setBitmap(true);
- test(caps, false /*useGears*/, width, height, rows, cols, true /* useGLJPanel */, false /*useAnim*/);
+ test(caps, false /*useGears*/, width, height, rows, cols, CanvasType.GLJPanel_T, false /*useAnim*/);
+ }
+
+ // @Test
+ public void test03NopGLCanvas() throws InterruptedException, InvocationTargetException {
+ test(new GLCapabilities(null), false /*useGears*/, width, height, rows, cols, CanvasType.GLCanvas_T, false /*useAnim*/);
+ }
+
+ // @Test
+ public void test11GearsGLJPanel() throws InterruptedException, InvocationTargetException {
+ test(new GLCapabilities(null), true /*useGears*/, width, height, rows, cols, CanvasType.GLJPanel_T, true /*useAnim*/);
+ }
+
+ // @Test
+ public void test13GearsGLCanvas() throws InterruptedException, InvocationTargetException {
+ test(new GLCapabilities(null), true /*useGears*/, width, height, rows, cols, CanvasType.GLCanvas_T, true /*useAnim*/);
}
@Test
- public void test11NopGLCanvasDef() throws InterruptedException, InvocationTargetException {
- test(new GLCapabilities(null), false /*useGears*/, width, height, rows, cols, false /* useGLJPanel */, false /*useAnim*/);
+ public void test14GearsNewtCanvasAWT() throws InterruptedException, InvocationTargetException {
+ test(new GLCapabilities(null), true /*useGears*/, width, height, rows, cols, CanvasType.NewtCanvasAWT_T, true /*useAnim*/);
}
static long duration = 0; // ms
@@ -215,7 +282,8 @@ public class TestPerf001GLJPanelInit01AWT extends UITestCase {
AtomicInteger initCount = new AtomicInteger(0);
public static void main(final String[] args) {
- boolean useGLJPanel = true, useGears = false, manual=false;
+ CanvasType canvasType = CanvasType.GLJPanel_T;
+ boolean useGears = false, manual=false;
boolean waitMain = false;
for(int i=0; i<args.length; i++) {
@@ -230,8 +298,10 @@ public class TestPerf001GLJPanelInit01AWT extends UITestCase {
rows = MiscUtils.atoi(args[++i], rows);
} else if(args[i].equals("-cols")) {
cols = MiscUtils.atoi(args[++i], cols);
- } else if(args[i].equals("-glcanvas")) {
- useGLJPanel = false;
+ } else if(args[i].equals("-type")) {
+ i++;
+ canvasType = CanvasType.valueOf(args[i]);
+ manual = true;
} else if(args[i].equals("-gears")) {
useGears = true;
} else if(args[i].equals("-wait")) {
@@ -250,7 +320,7 @@ public class TestPerf001GLJPanelInit01AWT extends UITestCase {
if( manual ) {
GLProfile.initSingleton();
final TestPerf001GLJPanelInit01AWT demo = new TestPerf001GLJPanelInit01AWT();
- demo.test(null, useGears, width, height, rows, cols, useGLJPanel, false /*useAnim*/);
+ demo.test(null, useGears, width, height, rows, cols, canvasType, useGears /*useAnim*/);
} else {
org.junit.runner.JUnitCore.main(TestPerf001GLJPanelInit01AWT.class.getName());
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java
index c60c395eb..9f2e25fd7 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java
@@ -32,6 +32,8 @@ import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import javax.media.opengl.GLAnimatorControl;
@@ -54,13 +56,15 @@ import org.junit.Test;
import org.junit.runners.MethodSorters;
import com.jogamp.common.os.Platform;
+import com.jogamp.newt.awt.NewtCanvasAWT;
+import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.util.Animator;
/**
- * Multiple GLJPanels in a JFrame
+ * Tests multiple JFrames each with a [GLJPanels, GLCanvas or NewtCanvasAWT]
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestPerf001GLJPanelInit02AWT extends UITestCase {
@@ -71,13 +75,23 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
GLProfile.initSingleton();
}
+ static enum CanvasType { NOP_T, GLCanvas_T, GLJPanel_T, NewtCanvasAWT_T };
+
+ static class GLADComp {
+ GLADComp(final GLAutoDrawable glad, final Component comp) {
+ this.glad = glad;
+ this.comp = comp;
+ }
+ final GLAutoDrawable glad;
+ final Component comp;
+ }
+
public void test(final GLCapabilitiesImmutable caps, final boolean useGears, final boolean skipGLOrientationVerticalFlip, final int width,
- final int height, final int frameCount, final boolean initMT, final boolean useGLJPanel,
- final boolean useSwingDoubleBuffer, final boolean useGLCanvas, final boolean useAnim, final boolean overlap) {
+ final int height, final int frameCount, final boolean initMT,
+ final boolean useSwingDoubleBuffer, final CanvasType canvasType, final boolean useAnim, final boolean overlap) {
final GLAnimatorControl animator;
if( useAnim ) {
animator = new Animator();
- animator.start();
} else {
animator = null;
}
@@ -91,6 +105,8 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
System.err.println("Frame size: "+width+"x"+height+" -> "+frameCount+" x "+eWidth+"x"+eHeight+", overlap "+overlap);
System.err.println("SkipGLOrientationVerticalFlip "+skipGLOrientationVerticalFlip+", useGears "+useGears+", initMT "+initMT+", useAnim "+useAnim);
final JFrame[] frame = new JFrame[frameCount];
+ final List<NewtCanvasAWT> newtCanvasAWTList = new ArrayList<NewtCanvasAWT>();
+
final long[] t = new long[10];
if( wait ) {
UITestCase.waitForKey("Pre-Init");
@@ -103,7 +119,7 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
t[0] = Platform.currentTimeMillis();
int x = 32, y = 32;
for(int i=0; i<frameCount; i++) {
- frame[i] = new JFrame("frame_"+i+"/"+frameCount);
+ frame[i] = new JFrame(i+"/"+frameCount);
frame[i].setLocation(x, y);
if(!overlap) {
x+=eWidth+32;
@@ -117,9 +133,26 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
panel.setDoubleBuffered(useSwingDoubleBuffer);
// panel.setBounds(0, 0, width, height);
final Dimension eSize = new Dimension(eWidth, eHeight);
- final GLAutoDrawable glad = useGLJPanel ? createGLJPanel(initMT, useSwingDoubleBuffer, caps, useGears, skipGLOrientationVerticalFlip, animator, eSize) : ( useGLCanvas ? createGLCanvas(caps, useGears, animator, eSize) : null );
- if( null != glad ) {
- glad.addGLEventListener(new GLEventListener() {
+ final GLADComp gladComp;
+ switch(canvasType) {
+ case GLCanvas_T:
+ gladComp = createGLCanvas(caps, useGears, animator, eSize);
+ break;
+ case GLJPanel_T:
+ gladComp = createGLJPanel(initMT, useSwingDoubleBuffer, caps, useGears, skipGLOrientationVerticalFlip, animator, eSize);
+ break;
+ case NewtCanvasAWT_T:
+ gladComp = createNewtCanvasAWT(caps, useGears, animator, eSize);
+ newtCanvasAWTList.add((NewtCanvasAWT)gladComp.comp);
+ break;
+ case NOP_T:
+ gladComp = null;
+ break;
+ default: throw new InternalError("XXX");
+ }
+
+ if( null != gladComp ) {
+ gladComp.glad.addGLEventListener(new GLEventListener() {
@Override
public void init(final GLAutoDrawable drawable) {
initCount.incrementAndGet();
@@ -131,7 +164,7 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
@Override
public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {}
});
- panel.add((Component)glad);
+ panel.add(gladComp.comp);
} else {
@SuppressWarnings("serial")
final JTextArea c = new JTextArea("area "+i) {
@@ -192,7 +225,7 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
final double panelCountF = initCount.get();
System.err.printf("P: %d %s%s:%n\tctor\t%6d/t %6.2f/1%n\tvisible\t%6d/t %6.2f/1%n\tsum-i\t%6d/t %6.2f/1%n",
initCount.get(),
- useGLJPanel?"GLJPanel":(useGLCanvas?"GLCanvas":"No_GL"), initMT?" (mt)":" (01)",
+ canvasType, initMT?" (mt)":" (01)",
t[1]-t[0], (t[1]-t[0])/panelCountF,
t[3]-t[1], (t[3]-t[1])/panelCountF,
t[3]-t[0], (t[3]-t[0])/panelCountF);
@@ -201,15 +234,24 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
if( wait ) {
UITestCase.waitForKey("Post-Init");
}
+ if( null != animator ) {
+ animator.start();
+ }
try {
Thread.sleep(duration);
} catch (final InterruptedException e1) {
e1.printStackTrace();
}
+ if( null != animator ) {
+ animator.stop();
+ }
t[4] = Platform.currentTimeMillis();
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
+ while( !newtCanvasAWTList.isEmpty() ) {
+ newtCanvasAWTList.remove(0).destroy(); // removeNotify does not destroy GLWindow
+ }
for(int i=0; i<frameCount; i++) {
frame[i].dispose();
}
@@ -226,7 +268,22 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
System.err.println("Total: "+(t[4]-t[0]));
}
- private GLAutoDrawable createGLCanvas(final GLCapabilitiesImmutable caps, final boolean useGears, final GLAnimatorControl anim, final Dimension size) {
+ private GLADComp createNewtCanvasAWT(final GLCapabilitiesImmutable caps, final boolean useGears, final GLAnimatorControl anim, final Dimension size) {
+ final GLWindow window = GLWindow.create(caps);
+ final NewtCanvasAWT canvas = new NewtCanvasAWT(window);
+ canvas.setSize(size);
+ canvas.setPreferredSize(size);
+ if( useGears ) {
+ final GearsES2 g = new GearsES2(0);
+ g.setVerbose(false);
+ window.addGLEventListener(g);
+ }
+ if( null != anim ) {
+ anim.add(window);
+ }
+ return new GLADComp(window, canvas);
+ }
+ private GLADComp createGLCanvas(final GLCapabilitiesImmutable caps, final boolean useGears, final GLAnimatorControl anim, final Dimension size) {
final GLCanvas canvas = new GLCanvas(caps);
canvas.setSize(size);
canvas.setPreferredSize(size);
@@ -238,9 +295,9 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
if( null != anim ) {
anim.add(canvas);
}
- return canvas;
+ return new GLADComp(canvas, canvas);
}
- private GLAutoDrawable createGLJPanel(final boolean initMT, final boolean useSwingDoubleBuffer, final GLCapabilitiesImmutable caps, final boolean useGears, final boolean skipGLOrientationVerticalFlip, final GLAnimatorControl anim, final Dimension size) {
+ private GLADComp createGLJPanel(final boolean initMT, final boolean useSwingDoubleBuffer, final GLCapabilitiesImmutable caps, final boolean useGears, final boolean skipGLOrientationVerticalFlip, final GLAnimatorControl anim, final Dimension size) {
final GLJPanel canvas = new GLJPanel(caps);
canvas.setSize(size);
canvas.setPreferredSize(size);
@@ -260,7 +317,7 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
if( initMT ) {
canvas.initializeBackend(true /* offthread */);
}
- return canvas;
+ return new GLADComp(canvas, canvas);
}
static GLCapabilitiesImmutable caps = null;
@@ -272,31 +329,37 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
@Test
public void test00NopNoGLDefGrid() throws InterruptedException, InvocationTargetException {
test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
- false /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.NOP_T, false /*useAnim*/, false /* overlap */);
}
@Test
public void test01NopGLCanvasDefGrid() throws InterruptedException, InvocationTargetException {
test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
- false /* useGLJPanel */, false /*useSwingDoubleBuffer*/, true /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.GLCanvas_T, false /*useAnim*/, false /* overlap */);
}
@Test
public void test02NopGLJPanelDefGridSingleAutoFlip() throws InterruptedException, InvocationTargetException {
test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
- true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.GLJPanel_T, false /*useAnim*/, false /* overlap */);
}
@Test
public void test03NopGLJPanelDefGridSingleManualFlip() throws InterruptedException, InvocationTargetException {
test(new GLCapabilities(null), false /*useGears*/, true /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
- true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.GLJPanel_T, false /*useAnim*/, false /* overlap */);
}
@Test
public void test04NopGLJPanelDefGridMTManualFlip() throws InterruptedException, InvocationTargetException {
test(new GLCapabilities(null), false /*useGears*/, true /*skipGLOrientationVerticalFlip*/, width , height, frameCount, true /* initMT */,
- true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.GLJPanel_T, false /*useAnim*/, false /* overlap */);
+ }
+
+ @Test
+ public void test05NopNewtCanvasAWTDefGrid() throws InterruptedException, InvocationTargetException {
+ test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
+ false /*useSwingDoubleBuffer*/, CanvasType.NewtCanvasAWT_T, false /*useAnim*/, false /* overlap */);
}
//
@@ -304,35 +367,34 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
//
@Test
- public void test10GearsNoGLDefGrid() throws InterruptedException, InvocationTargetException {
- test(new GLCapabilities(null), true /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
- false /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
- }
-
- @Test
public void test11GearsGLCanvasDefGrid() throws InterruptedException, InvocationTargetException {
test(new GLCapabilities(null), true /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
- false /* useGLJPanel */, false /*useSwingDoubleBuffer*/, true /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.GLCanvas_T, true /*useAnim*/, false /* overlap */);
}
@Test
public void test12GearsGLJPanelDefGridSingleAutoFlip() throws InterruptedException, InvocationTargetException {
test(new GLCapabilities(null), true /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
- true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.GLJPanel_T, true /*useAnim*/, false /* overlap */);
}
@Test
public void test13GearsGLJPanelDefGridSingleManualFlip() throws InterruptedException, InvocationTargetException {
test(new GLCapabilities(null), true /*useGears*/, true /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
- true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.GLJPanel_T, true /*useAnim*/, false /* overlap */);
}
@Test
public void test14GearsGLJPanelDefGridMTManualFlip() throws InterruptedException, InvocationTargetException {
test(new GLCapabilities(null), true /*useGears*/, true /*skipGLOrientationVerticalFlip*/, width , height, frameCount, true /* initMT */,
- true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.GLJPanel_T, true /*useAnim*/, false /* overlap */);
}
+ @Test
+ public void test15GearsNewtCanvasAWTDefGrid() throws InterruptedException, InvocationTargetException {
+ test(new GLCapabilities(null), true /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
+ false /*useSwingDoubleBuffer*/, CanvasType.NewtCanvasAWT_T, true /*useAnim*/, false /* overlap */);
+ }
//
// Overlap + NOP
@@ -342,31 +404,37 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
@Test
public void test20NopNoGLDefOverlap() throws InterruptedException, InvocationTargetException {
test(null, false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
- false /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, true /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.NOP_T, false /*useAnim*/, true /* overlap */);
}
@Test
public void test21NopGLCanvasDefOverlap() throws InterruptedException, InvocationTargetException {
test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
- false /* useGLJPanel */, false /*useSwingDoubleBuffer*/, true /* useGLCanvas */, false /*useAnim*/, true /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.GLCanvas_T, false /*useAnim*/, true /* overlap */);
}
@Test
public void test22NopGLJPanelDefOverlapSingle() throws InterruptedException, InvocationTargetException {
test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
- true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, true /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.GLJPanel_T, false /*useAnim*/, true /* overlap */);
}
@Test
public void test23NopGLJPanelDefOverlapMT() throws InterruptedException, InvocationTargetException {
test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, true /* initMT */,
- true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, true /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.GLJPanel_T, false /*useAnim*/, true /* overlap */);
+ }
+
+ @Test
+ public void test25NopNewtCanvasAWTDefOverlap() throws InterruptedException, InvocationTargetException {
+ test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
+ false /*useSwingDoubleBuffer*/, CanvasType.NewtCanvasAWT_T, false /*useAnim*/, true /* overlap */);
}
// @Test
public void testXXNopGLJPanelDefOverlapSingle() throws InterruptedException, InvocationTargetException {
test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
- true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, true /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.GLJPanel_T, false /*useAnim*/, true /* overlap */);
}
// @Test
@@ -374,7 +442,7 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
final GLCapabilities caps = new GLCapabilities(null);
caps.setBitmap(true);
test(caps, false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
- true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false);
+ false /*useSwingDoubleBuffer*/, CanvasType.GLJPanel_T, false /*useAnim*/, false);
}
static long duration = 0; // ms
@@ -386,7 +454,8 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
public static void main(final String[] args) {
boolean manual=false;
boolean waitMain = false;
- boolean useGLJPanel = true, initMT = false, useGLCanvas = false, useSwingDoubleBuffer=false;
+ CanvasType canvasType = CanvasType.GLJPanel_T;
+ boolean initMT = false, useSwingDoubleBuffer=false;
boolean useGears = false, skipGLOrientationVerticalFlip=false, useAnim = false;
boolean overlap = false;
@@ -403,16 +472,12 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
} else if(args[i].equals("-initMT")) {
initMT = true;
manual = true;
- } else if(args[i].equals("-glcanvas")) {
- useGLJPanel = false;
- useGLCanvas = true;
+ } else if(args[i].equals("-type")) {
+ i++;
+ canvasType = CanvasType.valueOf(args[i]);
manual = true;
} else if(args[i].equals("-swingDoubleBuffer")) {
useSwingDoubleBuffer = true;
- } else if(args[i].equals("-glnone")) {
- useGLJPanel = false;
- useGLCanvas = false;
- manual = true;
} else if(args[i].equals("-gears")) {
useGears = true;
} else if(args[i].equals("-anim")) {
@@ -438,7 +503,7 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
GLProfile.initSingleton();
final TestPerf001GLJPanelInit02AWT demo = new TestPerf001GLJPanelInit02AWT();
demo.test(null, useGears, skipGLOrientationVerticalFlip, width, height, frameCount,
- initMT, useGLJPanel, useSwingDoubleBuffer, useGLCanvas, useAnim, overlap);
+ initMT, useSwingDoubleBuffer, canvasType, useAnim, overlap);
} else {
org.junit.runner.JUnitCore.main(TestPerf001GLJPanelInit02AWT.class.getName());
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/stereo/StereoDemo01.java b/src/test/com/jogamp/opengl/test/junit/jogl/stereo/StereoDemo01.java
index 05685c05a..58aa8cd23 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/stereo/StereoDemo01.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/stereo/StereoDemo01.java
@@ -28,7 +28,6 @@
package com.jogamp.opengl.test.junit.jogl.stereo;
import java.io.File;
-import java.net.URI;
import java.net.URISyntaxException;
import java.util.Arrays;
@@ -40,8 +39,7 @@ import javax.media.opengl.GLProfile;
import jogamp.opengl.util.stereo.GenericStereoDevice;
-import com.jogamp.common.util.IOUtil;
-import com.jogamp.common.util.ReflectionUtil;
+import com.jogamp.common.net.Uri;
import com.jogamp.newt.event.KeyAdapter;
import com.jogamp.newt.event.KeyEvent;
import com.jogamp.newt.opengl.GLWindow;
@@ -88,6 +86,16 @@ import com.jogamp.opengl.util.stereo.StereoUtil;
* java StereoDemo01 -time 10000000 -filmURI http://whoknows.not/Some_SBS_3D_Movie.mkv
* </pre>
* <p>
+ * In case user likes to utilize the {@link StereoDeviceFactory.DeviceType#Generic Generic} software implementation,
+ * which is selected {@link StereoDeviceFactory.DeviceType#Default Default} if no other device is available
+ * or explicit via <code>-device Generic</code>, the user can chose between different <i>generic</i> stereo modes:
+ * <pre>
+ * mono : <code>-device Generic -deviceIndex 0</code>
+ * stereo-sbs : <code>-device Generic -deviceIndex 1</code>
+ * stereo-sbs-lense: <code>-device Generic -deviceIndex 2</code>
+ * </pre>
+ * </p>
+ * <p>
* Key 'R' enables/disables the VR's sensors, i.e. head rotation ..
* </p>
*
@@ -106,7 +114,6 @@ public class StereoDemo01 {
static boolean useAutoSwap = false;
static String useFilmFile = null;
static String useFilmURI = null;
- static String stereoRendererListenerName = null;
static StereoDeviceFactory.DeviceType deviceType = StereoDeviceFactory.DeviceType.Default;
static int deviceIndex = 0;
@@ -162,9 +169,6 @@ public class StereoDemo01 {
} else if(args[i].equals("-autoSwap")) {
i++;
useAutoSwap = MiscUtils.atob(args[i], useAutoSwap);
- } else if(args[i].equals("-test")) {
- i++;
- stereoRendererListenerName = args[i];
} else if(args[i].equals("-filmFile")) {
i++;
useFilmFile = args[i];
@@ -173,26 +177,20 @@ public class StereoDemo01 {
useFilmURI = args[i];
}
}
- if( null != stereoRendererListenerName ) {
- try {
- final Object stereoRendererListener = ReflectionUtil.createInstance(stereoRendererListenerName, null);
- } catch (final Exception e) {
- e.printStackTrace();
- }
- }
final StereoGLEventListener upstream;
final MovieSBSStereo movieSimple;
- final URI movieURI;
+ final Uri movieURI;
if( null != useFilmFile ) {
movieSimple = new MovieSBSStereo();
- movieURI = IOUtil.toURISimple(new File(useFilmFile));
+ movieURI = Uri.valueOf(new File(useFilmFile));
upstream = movieSimple;
} else if( null != useFilmURI ) {
movieSimple = new MovieSBSStereo();
- movieURI = new URI(useFilmURI);
+ movieURI = Uri.cast(useFilmURI);
upstream = movieSimple;
} else {
final GearsES2 demo = new GearsES2(0);
+ demo.setZ(2f, 10000f, 20f); // start closer to eye
demo.setVerbose(false);
upstream = demo;
movieSimple = null;
@@ -206,7 +204,7 @@ public class StereoDemo01 {
}
public void doIt(final StereoDeviceFactory.DeviceType deviceType, final int deviceIndex, final int posx, final int posy,
- final StereoGLEventListener upstream, final MovieSBSStereo movieSimple, final URI movieURI,
+ final StereoGLEventListener upstream, final MovieSBSStereo movieSimple, final Uri movieURI,
final boolean biLinear, final int numSamples, final boolean useSingleFBO,
final boolean useRecommendedDistortionBits, final boolean useVignette, final boolean useChromatic, final boolean useTimewarp,
final boolean useAutoSwap, final boolean useAnimator, final boolean exclusiveContext) throws InterruptedException {
@@ -256,10 +254,10 @@ public class StereoDemo01 {
final PointImmutable devicePos = stereoDevice.getPosition();
final DimensionImmutable deviceRes = stereoDevice.getSurfaceSize();
- window.setSize(deviceRes.getWidth(), deviceRes.getHeight());
if( useStereoScreen ) {
window.setPosition(devicePos.getX(), devicePos.getY());
}
+ window.setSurfaceSize(deviceRes.getWidth(), deviceRes.getHeight()); // might be not correct ..
window.setAutoSwapBufferMode(useAutoSwap);
window.setUndecorated(true);
@@ -281,8 +279,9 @@ public class StereoDemo01 {
System.err.println("Default Fov[1]: "+defaultEyeFov[1].toStringInDegrees());
}
- final float[] eyePositionOffset = null == movieSimple || isGenericDevice ? stereoDevice.getDefaultEyePositionOffset() // default
- : new float[] { 0f, 0.3f, 0f }; // better fixed movie position
+ final boolean usesLenses = 0 != ( StereoDeviceRenderer.DISTORTION_BARREL & stereoDevice.getMinimumDistortionBits() );
+ final float[] eyePositionOffset = null != movieSimple && usesLenses ? new float[] { 0f, 0.3f, 0f } // better fixed movie position w/ lenses
+ : stereoDevice.getDefaultEyePositionOffset(); // default
System.err.println("Eye Position Offset: "+Arrays.toString(eyePositionOffset));
final int textureUnit = 0;
@@ -338,6 +337,15 @@ public class StereoDemo01 {
animator.start();
}
window.setVisible(true);
+
+ // Correct window size to actual pixel size,
+ // which ration is unknown before window creation when using multiple displays!
+ System.err.println("Window.0.windowSize : "+window.getWidth()+" x "+window.getHeight());
+ System.err.println("Window.0.surfaceSize: "+window.getSurfaceWidth()+" x "+window.getSurfaceHeight());
+ window.setSurfaceSize(deviceRes.getWidth(), deviceRes.getHeight());
+ System.err.println("Window.1.windowSize : "+window.getWidth()+" x "+window.getHeight());
+ System.err.println("Window.1.surfaceSize: "+window.getSurfaceWidth()+" x "+window.getSurfaceHeight());
+
if( useAnimator ) {
animator.setUpdateFPSFrames(60, System.err);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestMultipleNewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestMultipleNewtCanvasAWT.java
new file mode 100644
index 000000000..0e11ff1e8
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestMultipleNewtCanvasAWT.java
@@ -0,0 +1,185 @@
+/**
+ * Copyright 2011 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.opengl.test.junit.newt;
+
+import java.awt.Component;
+import java.awt.Dimension;
+import java.io.IOException;
+
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLProfile;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.SwingUtilities;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.FixMethodOrder;
+import org.junit.runners.MethodSorters;
+
+import com.jogamp.newt.awt.NewtCanvasAWT;
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.Animator;
+
+
+/**
+ * TestMultipleNewtCanvasAWT
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestMultipleNewtCanvasAWT extends UITestCase {
+
+ static long durationPerTest = 1000;
+
+ @BeforeClass
+ public static void initClass() {
+ if(!GLProfile.isAvailable(GLProfile.GL2ES2)) {
+ setTestSupported(false);
+ }
+ }
+
+ @Test
+ public void test01() throws InterruptedException {
+ testImpl();
+ }
+
+ public void testImpl() throws InterruptedException {
+ final JFrame frame = new JFrame(this.getSimpleTestName("."));
+
+ //
+ // GLDrawableFactory factory = GLDrawableFactory.getFactory(GLProfile.get(GLProfile.GL2));
+ // GLContext sharedContext = factory.getOrCreateSharedContext(factory.getDefaultDevice());
+ //
+ final GLCapabilities glCapabilities = new GLCapabilities(GLProfile.get(GLProfile.GL2));
+ glCapabilities.setSampleBuffers(true);
+ glCapabilities.setNumSamples(4);
+
+ final GearsES2 eventListener1 = new GearsES2(0);
+ final GearsES2 eventListener2 = new GearsES2(1);
+
+ final Component openGLComponent1;
+ final Component openGLComponent2;
+ final GLAutoDrawable openGLAutoDrawable1;
+ final GLAutoDrawable openGLAutoDrawable2;
+
+ final GLWindow glWindow1 = GLWindow.create(glCapabilities);
+ final NewtCanvasAWT newtCanvasAWT1 = new NewtCanvasAWT(glWindow1);
+ newtCanvasAWT1.setPreferredSize(new Dimension(640, 480));
+ glWindow1.addGLEventListener(eventListener1);
+ //
+ final GLWindow glWindow2 = GLWindow.create(glCapabilities);
+ final NewtCanvasAWT newtCanvasAWT2 = new NewtCanvasAWT(glWindow2);
+ newtCanvasAWT2.setPreferredSize(new Dimension(640, 480));
+ glWindow2.addGLEventListener(eventListener2);
+
+ openGLComponent1 = newtCanvasAWT1;
+ openGLComponent2 = newtCanvasAWT2;
+ openGLAutoDrawable1 = glWindow1;
+ openGLAutoDrawable2 = glWindow2;
+
+ // group both OpenGL canvases / windows into a horizontal panel
+ final JPanel openGLPanel = new JPanel();
+ openGLPanel.setLayout(new BoxLayout(openGLPanel, BoxLayout.LINE_AXIS));
+ openGLPanel.add(openGLComponent1);
+ openGLPanel.add(Box.createHorizontalStrut(5));
+ openGLPanel.add(openGLComponent2);
+
+ final JPanel mainPanel = (JPanel) frame.getContentPane();
+ mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.LINE_AXIS));
+ mainPanel.add(Box.createHorizontalGlue());
+ mainPanel.add(openGLPanel);
+ mainPanel.add(Box.createHorizontalGlue());
+
+ final Animator animator = new Animator(Thread.currentThread().getThreadGroup());
+ animator.setUpdateFPSFrames(1, null);
+ animator.add(openGLAutoDrawable1);
+ animator.add(openGLAutoDrawable2);
+
+ // make the window visible using the EDT
+ SwingUtilities.invokeLater( new Runnable() {
+ public void run() {
+ frame.pack();
+ frame.setVisible(true);
+ }
+ });
+
+ Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true));
+ Assert.assertEquals(true, AWTRobotUtil.waitForRealized(openGLComponent1, true));
+ Assert.assertEquals(true, AWTRobotUtil.waitForRealized(openGLComponent2, true));
+
+ animator.start();
+
+ // sleep for test duration, then request the window to close, wait for the window to close,s and stop the animation
+ while(animator.isAnimating() && animator.getTotalFPSDuration() < durationPerTest) {
+ Thread.sleep(100);
+ }
+
+ animator.stop();
+
+ // ask the EDT to dispose of the frame;
+ // if using newt, explicitly dispose of the canvases because otherwise it seems our destroy methods are not called
+ SwingUtilities.invokeLater( new Runnable() {
+ public void run() {
+ newtCanvasAWT1.destroy(); // removeNotify does not destroy GLWindow
+ newtCanvasAWT2.destroy(); // removeNotify does not destroy GLWindow
+ frame.dispose();
+ }
+ });
+ Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, false));
+ Assert.assertEquals(true, AWTRobotUtil.waitForRealized(openGLComponent1, false));
+ Assert.assertEquals(true, AWTRobotUtil.waitForRealized(openGLComponent2, false));
+ }
+
+ static int atoi(final String a) {
+ int i=0;
+ try {
+ i = Integer.parseInt(a);
+ } catch (final Exception ex) { ex.printStackTrace(); }
+ return i;
+ }
+
+ public static void main(final String[] args) throws IOException {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ if (++i < args.length) {
+ durationPerTest = atoi(args[i]);
+ }
+ }
+ }
+ org.junit.runner.JUnitCore.main(TestMultipleNewtCanvasAWT.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 e401534bd..7100e1e1a 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java
@@ -214,21 +214,23 @@ public class MiscUtils {
}
}
- public static void dumpSharedGLContext(final GLContext self) {
+ public static void dumpSharedGLContext(final String prefix, final GLContext self) {
int i = 0, j = 0;
- System.err.println("Myself: hash 0x"+Integer.toHexString(self.hashCode())+", \t(isShared "+self.isShared()+", created "+self.isCreated()+")");
+ final GLContext master = self.getSharedMaster();
+ final int masterHash = null != master ? master.hashCode() : 0;
+ System.err.println(prefix+": hash 0x"+Integer.toHexString(self.hashCode())+", \t(isShared "+self.isShared()+", created "+self.isCreated()+", master 0x"+Integer.toHexString(masterHash)+")");
{
final List<GLContext> set = self.getCreatedShares();
for (final Iterator<GLContext> iter = set.iterator(); iter.hasNext(); ) {
final GLContext c = iter.next();
- System.err.println("Ctx #"+(i++)+": hash 0x"+Integer.toHexString(c.hashCode())+", \t(created "+c.isCreated()+")");
+ System.err.println(" Created Ctx #"+(i++)+": hash 0x"+Integer.toHexString(c.hashCode())+", \t(created "+c.isCreated()+")");
}
}
{
final List<GLContext> set = self.getDestroyedShares();
for (final Iterator<GLContext> iter = set.iterator(); iter.hasNext(); ) {
final GLContext c = iter.next();
- System.err.println("Ctx #"+(j++)+": hash 0x"+Integer.toHexString(c.hashCode())+", \t(created "+c.isCreated()+")");
+ System.err.println(" Destroyed Ctx #"+(j++)+": hash 0x"+Integer.toHexString(c.hashCode())+", \t(created "+c.isCreated()+")");
}
}
System.err.println("\t Total created "+i+" + destroyed "+j+" = "+(i+j));
diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTGLContext.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTGLContext.java
index cd3a1eaa2..d897a51a1 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/NEWTGLContext.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTGLContext.java
@@ -53,45 +53,7 @@ public class NEWTGLContext {
}
}
- public static WindowContext createOffscreenWindow(final GLCapabilities caps, final int width, final int height, final boolean debugGL) throws InterruptedException {
- caps.setOnscreen(false);
- caps.setPBuffer(true);
-
- //
- // Create native windowing resources .. X11/Win/OSX
- //
- final Display display = NewtFactory.createDisplay(null); // local display
- Assert.assertNotNull(display);
-
- final Screen screen = NewtFactory.createScreen(display, 0); // screen 0
- Assert.assertNotNull(screen);
-
- final Window window = NewtFactory.createWindow(screen, caps);
- Assert.assertNotNull(window);
- window.setSize(width, height);
- window.setVisible(true);
- Assert.assertTrue(AWTRobotUtil.waitForVisible(window, true));
- Assert.assertTrue(AWTRobotUtil.waitForRealized(window, true));
-
- final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile());
- final GLDrawable drawable = factory.createGLDrawable(window);
- Assert.assertNotNull(drawable);
-
- drawable.setRealized(true);
- Assert.assertTrue(drawable.isRealized());
-
- final GLContext context = drawable.createContext(null);
- Assert.assertNotNull(context);
-
- context.enableGLDebugMessage(debugGL);
-
- final int res = context.makeCurrent();
- Assert.assertTrue(GLContext.CONTEXT_CURRENT_NEW==res || GLContext.CONTEXT_CURRENT==res);
-
- return new WindowContext(window, drawable, context);
- }
-
- public static WindowContext createOnscreenWindow(final GLCapabilities caps, final int width, final int height, final boolean debugGL) throws InterruptedException {
+ public static WindowContext createWindow(final GLCapabilities caps, final int width, final int height, final boolean debugGL) throws InterruptedException {
//
// Create native windowing resources .. X11/Win/OSX
//