summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-06-25 06:41:57 +0200
committerSven Gothel <[email protected]>2012-06-25 06:41:57 +0200
commit741bc48237fb1735bab09843ebf09feba200bd81 (patch)
tree192e0301668f1fde5279f482252f3221b19d2038
parent1c05c85e1ccc480da227cd6aa4718efd386e1e35 (diff)
Tests [Multisample, Offscreen, ..]: Add Snapshots and store them in current directory instead of tempdir, so they get archived (CI/jenkins).
Multisample/TestGLReadBufferUtilTextureIOWrite01NEWT: Add offscreen test
-rwxr-xr-xmake/scripts/tests.sh4
-rwxr-xr-xsrc/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java51
-rwxr-xr-xsrc/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1NEWT.java87
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/offscreen/Surface2File.java25
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen01GLPBufferNEWT.java14
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen02BitmapNEWT.java13
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/offscreen/WindowUtilNEWT.java31
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite01NEWT.java42
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02NEWT.java25
10 files changed, 197 insertions, 97 deletions
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index c9db61564..71fa425d5 100755
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -314,7 +314,7 @@ function testawtswt() {
#testawt com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentParentingAWT $*
#testawt com.jogamp.opengl.test.junit.newt.TestCloseNewtAWT
#testawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1AWT $*
-#testawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1NEWT $*
+testawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1NEWT $*
#testawt com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyAWT $*
#testawt com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyNEWT $*
#testawt com.jogamp.opengl.test.junit.jogl.glsl.TestShaderCompilationBug459AWT
@@ -330,7 +330,7 @@ function testawtswt() {
#
#testnoawt com.jogamp.opengl.test.junit.jogl.util.TestPNGImage01NEWT $*
#testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTexture01AWT
-testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileAWT $*
+#testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileAWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite02NEWT $*
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java
index 517d12578..4b0caf898 100755
--- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java
@@ -40,23 +40,28 @@
package com.jogamp.opengl.test.junit.jogl.caps;
+import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.awt.BorderLayout;
import java.awt.Frame;
+import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLCapabilitiesChooser;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLProfile;
import javax.media.opengl.awt.GLCanvas;
import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.GLReadBufferUtil;
import org.junit.Test;
public class TestMultisampleES1AWT extends UITestCase {
- static long durationPerTest = 250; // ms
+ static long durationPerTest = 60; // ms
private GLCanvas canvas;
public static void main(String[] args) {
@@ -70,33 +75,54 @@ public class TestMultisampleES1AWT extends UITestCase {
org.junit.runner.JUnitCore.main(tstname);
}
+ protected void snapshot(GLAutoDrawable drawable, boolean alpha, boolean flip, String filename) {
+ GLReadBufferUtil screenshot = new GLReadBufferUtil(alpha, false);
+ if(screenshot.readPixels(drawable.getGL(), drawable, flip)) {
+ screenshot.write(new File(filename));
+ }
+ }
+
+ @Test
+ public void testOnscreenMultiSampleAA0() throws InterruptedException, InvocationTargetException {
+ testMultiSampleAAImpl(0);
+ }
+
@Test
- public void testMultiSampleAA4() throws InterruptedException, InvocationTargetException {
+ public void testOnscreenMultiSampleAA4() throws InterruptedException, InvocationTargetException {
testMultiSampleAAImpl(4);
}
@Test
- public void testMultiSampleNone() throws InterruptedException, InvocationTargetException {
- testMultiSampleAAImpl(0);
+ public void testOnscreenMultiSampleAA8() throws InterruptedException, InvocationTargetException {
+ testMultiSampleAAImpl(8);
}
- private void testMultiSampleAAImpl(int samples) throws InterruptedException, InvocationTargetException {
+ private void testMultiSampleAAImpl(int reqSamples) throws InterruptedException, InvocationTargetException {
GLProfile glp = GLProfile.getMaxFixedFunc(true);
GLCapabilities caps = new GLCapabilities(glp);
GLCapabilitiesChooser chooser = new MultisampleChooser01();
- if(samples>0) {
+ if(reqSamples>0) {
caps.setSampleBuffers(true);
- caps.setNumSamples(samples);
- // turns out we need to have alpha,
- // otherwise no AA will be visible.
- caps.setAlphaBits(1);
+ caps.setNumSamples(reqSamples);
}
canvas = new GLCanvas(caps, chooser, null, null);
- canvas.addGLEventListener(new MultisampleDemoES1(samples>0?true:false));
+ canvas.addGLEventListener(new MultisampleDemoES1(reqSamples>0?true:false));
+ canvas.addGLEventListener(new GLEventListener() {
+ public void init(GLAutoDrawable drawable) {}
+ public void dispose(GLAutoDrawable drawable) {}
+ public void display(GLAutoDrawable drawable) {
+ final GLCapabilitiesImmutable caps = drawable.getChosenGLCapabilities();
+ final String pfmt = caps.getAlphaBits() > 0 ? "rgba" : "rgb_";
+ final String aaext = caps.getSampleExtension();
+ final int samples = caps.getSampleBuffers() ? caps.getNumSamples() : 0 ;
+ snapshot(drawable, false, false, getSimpleTestName(".")+"-F_rgb_-I_"+pfmt+"-S"+samples+"-"+aaext+"-"+drawable.getGLProfile().getName()+".png");
+ }
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { }
+ });
- final Frame frame = new Frame("Multi Samples "+samples);
+ final Frame frame = new Frame("Multi Samples "+reqSamples);
frame.setLayout(new BorderLayout());
canvas.setSize(512, 512);
frame.add(canvas, BorderLayout.CENTER);
@@ -105,7 +131,6 @@ public class TestMultisampleES1AWT extends UITestCase {
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
frame.setVisible(true);
- frame.setLocation(0, 0);
canvas.requestFocus();
canvas.display();
}});
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1NEWT.java
index cdfeb2bad..2e47b6841 100755
--- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1NEWT.java
@@ -40,17 +40,24 @@
package com.jogamp.opengl.test.junit.jogl.caps;
+import java.io.File;
+
+import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLCapabilitiesChooser;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLProfile;
import org.junit.Test;
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.GLReadBufferUtil;
-public class TestMultisampleES1NEWT {
- static long durationPerTest = 500; // ms
+public class TestMultisampleES1NEWT extends UITestCase {
+ static long durationPerTest = 60; // ms
private GLWindow window;
public static void main(String[] args) {
@@ -64,36 +71,84 @@ public class TestMultisampleES1NEWT {
org.junit.runner.JUnitCore.main(tstname);
}
+ protected void snapshot(GLAutoDrawable drawable, boolean alpha, boolean flip, String filename) {
+ GLReadBufferUtil screenshot = new GLReadBufferUtil(alpha, false);
+ if(screenshot.readPixels(drawable.getGL(), drawable, flip)) {
+ screenshot.write(new File(filename));
+ }
+ }
+
+ @Test
+ public void testOnscreenMultiSampleAA0() throws InterruptedException {
+ testMultiSampleAAImpl(true, 0);
+ }
+
+ @Test
+ public void testOnscreenMultiSampleAA2() throws InterruptedException {
+ testMultiSampleAAImpl(true, 2);
+ }
+
+ @Test
+ public void testOnscreenMultiSampleAA4() throws InterruptedException {
+ testMultiSampleAAImpl(true, 4);
+ }
+
@Test
- public void testMultiSampleAA4() throws InterruptedException {
- testMultiSampleAAImpl(4);
+ public void testOnscreenMultiSampleAA8() throws InterruptedException {
+ testMultiSampleAAImpl(true, 8);
}
- // @Test
- public void testMultiSampleNone() throws InterruptedException {
- testMultiSampleAAImpl(0);
+ @Test
+ public void testOffscreenMultiSampleAA0() throws InterruptedException {
+ testMultiSampleAAImpl(false, 0);
}
- private void testMultiSampleAAImpl(int samples) throws InterruptedException {
+ @Test
+ public void testOffscreenMultiSampleAA2() throws InterruptedException {
+ testMultiSampleAAImpl(false, 2);
+ }
+
+ @Test
+ public void testOffscreenMultiSampleAA4() throws InterruptedException {
+ testMultiSampleAAImpl(false, 4);
+ }
+
+ @Test
+ public void testOffsreenMultiSampleAA8() throws InterruptedException {
+ testMultiSampleAAImpl(false, 8);
+ }
+
+ private void testMultiSampleAAImpl(boolean onscreen, int reqSamples) throws InterruptedException {
GLProfile glp = GLProfile.getMaxFixedFunc(true);
GLCapabilities caps = new GLCapabilities(glp);
GLCapabilitiesChooser chooser = new MultisampleChooser01();
- if(samples>0) {
+ if(!onscreen) {
+ caps.setOnscreen(onscreen);
+ caps.setPBuffer(true);
+ }
+ if(reqSamples>0) {
caps.setSampleBuffers(true);
- caps.setNumSamples(4);
+ caps.setNumSamples(reqSamples);
}
- // turns out we need to have alpha,
- // otherwise no AA will be visible.
- // This is done implicit now ..
- // caps.setAlphaBits(1);
window = GLWindow.create(caps);
window.setCapabilitiesChooser(chooser);
- window.addGLEventListener(new MultisampleDemoES1(samples>0?true:false));
+ window.addGLEventListener(new MultisampleDemoES1(reqSamples>0?true:false));
+ window.addGLEventListener(new GLEventListener() {
+ public void init(GLAutoDrawable drawable) {}
+ public void dispose(GLAutoDrawable drawable) {}
+ public void display(GLAutoDrawable drawable) {
+ final GLCapabilitiesImmutable caps = drawable.getChosenGLCapabilities();
+ final String pfmt = caps.getAlphaBits() > 0 ? "rgba" : "rgb_";
+ final String aaext = caps.getSampleExtension();
+ final int samples = caps.getSampleBuffers() ? caps.getNumSamples() : 0 ;
+ snapshot(drawable, false, false, getSimpleTestName(".")+"-F_rgb_-I_"+pfmt+"-S"+samples+"-"+aaext+"-"+drawable.getGLProfile().getName()+".png");
+ }
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { }
+ });
window.setSize(512, 512);
window.setVisible(true);
- window.setPosition(0, 0);
window.requestFocus();
Thread.sleep(durationPerTest);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java
index 620267125..eceaa0637 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java
@@ -118,7 +118,7 @@ public class RedSquareES2 implements GLEventListener {
colors.enableBuffer(gl, false);
// OpenGL Render Settings
- gl.glClearColor(0, 0, 0, 1);
+ gl.glClearColor(0, 0, 0, 0);
gl.glEnable(GL2ES2.GL_DEPTH_TEST);
st.useProgram(gl, false);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/Surface2File.java b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/Surface2File.java
index d1297e034..b046df6af 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/Surface2File.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/Surface2File.java
@@ -34,14 +34,24 @@ import com.jogamp.opengl.util.GLReadBufferUtil;
import java.io.File;
import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
import javax.media.nativewindow.*;
public class Surface2File implements SurfaceUpdatedListener {
- GLReadBufferUtil readBufferUtil = new GLReadBufferUtil(false, false);
+ final String filename;
+ final boolean alpha;
+ final GLReadBufferUtil readBufferUtil;
int shotNum = 0;
+ public Surface2File(String filename, boolean alpha) {
+ this.filename = filename;
+ this.alpha = alpha;
+ this.readBufferUtil = new GLReadBufferUtil(alpha, false);
+ }
+
public void dispose(GL gl) {
readBufferUtil.dispose(gl);
}
@@ -57,7 +67,7 @@ public class Surface2File implements SurfaceUpdatedListener {
if(readBufferUtil.readPixels(gl, drawable, false)) {
gl.glFinish();
try {
- surface2File("shot");
+ surface2File();
} catch (IOException ex) {
throw new RuntimeException("can not write survace to file", ex);
}
@@ -66,14 +76,17 @@ public class Surface2File implements SurfaceUpdatedListener {
}
}
- public void surface2File(String basename) throws IOException {
+ public void surface2File() throws IOException {
if (!readBufferUtil.isValid()) {
return;
}
-
- File file = File.createTempFile(basename + shotNum + "-", ".tga");
+ final StringWriter sw = new StringWriter();
+ {
+ final String pfmt = alpha ? "rgba" : "rgb_" ;
+ new PrintWriter(sw).printf("%s-I_%s-%04d.png", filename, pfmt, shotNum);
+ }
+ File file = new File(sw.toString());
readBufferUtil.write(file);
- System.err.println("Wrote: " + file.getAbsolutePath() + ", ...");
shotNum++;
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen01GLPBufferNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen01GLPBufferNEWT.java
index 3f1fd144f..2ed471436 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen01GLPBufferNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen01GLPBufferNEWT.java
@@ -32,8 +32,6 @@ import com.jogamp.newt.Display;
import com.jogamp.newt.NewtFactory;
import com.jogamp.newt.Screen;
import com.jogamp.newt.Window;
-import com.jogamp.newt.event.MouseListener;
-import com.jogamp.newt.event.WindowListener;
import com.jogamp.newt.opengl.GLWindow;
import org.junit.AfterClass;
import org.junit.Assert;
@@ -42,7 +40,6 @@ import org.junit.BeforeClass;
import org.junit.Test;
import javax.media.opengl.*;
-import javax.media.nativewindow.*;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2;
@@ -72,6 +69,7 @@ public class TestOffscreen01GLPBufferNEWT extends UITestCase {
public void init() {
capsDefault = new GLCapabilities(glpDefault);
Assert.assertNotNull(capsDefault);
+ capsDefault.setAlphaBits(1); // req. alpha channel
}
private void do01OffscreenWindowPBuffer(GLCapabilities caps) {
@@ -280,14 +278,8 @@ public class TestOffscreen01GLPBufferNEWT extends UITestCase {
Assert.assertNotNull(glWindow);
glWindow.setVisible(true);
- WindowListener wl=null;
- MouseListener ml=null;
- SurfaceUpdatedListener ul=null;
-
- GLEventListener demo = new RedSquareES2();
- Assert.assertNotNull(demo);
-
- WindowUtilNEWT.run(glWindow, demo, null, wl, ml, ul, 2, true /*snapshot*/, false /*debug*/);
+ WindowUtilNEWT.run(getSimpleTestName("."), glWindow, new RedSquareES2(), null, null, null, null,
+ 2 /* frames */, true /*snapshot*/, false /*debug*/);
if(null!=glWindow) {
glWindow.destroy();
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen02BitmapNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen02BitmapNEWT.java
index 7898ddad9..0701d883c 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen02BitmapNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen02BitmapNEWT.java
@@ -33,14 +33,11 @@ import com.jogamp.newt.Display;
import com.jogamp.newt.NewtFactory;
import com.jogamp.newt.Screen;
import com.jogamp.newt.Window;
-import com.jogamp.newt.event.MouseListener;
-import com.jogamp.newt.event.WindowListener;
import com.jogamp.newt.opengl.GLWindow;
import org.junit.Assert;
import org.junit.Test;
import javax.media.opengl.*;
-import javax.media.nativewindow.*;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquareES1;
@@ -119,14 +116,8 @@ public class TestOffscreen02BitmapNEWT extends UITestCase {
Assert.assertNotNull(glWindow);
glWindow.setVisible(true);
- WindowListener wl=null;
- MouseListener ml=null;
- SurfaceUpdatedListener ul=null;
-
- GLEventListener demo = new RedSquareES1();
- Assert.assertNotNull(demo);
-
- WindowUtilNEWT.run(glWindow, demo, null, wl, ml, ul, 2, true /*snapshot*/, false /*debug*/);
+ WindowUtilNEWT.run(getSimpleTestName("."), glWindow, new RedSquareES1(), null, null, null, null,
+ 2 /* frames */, true /*snapshot*/, false /*debug*/);
if(null!=glWindow) {
glWindow.destroy();
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/WindowUtilNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/WindowUtilNEWT.java
index 1d1ee1e0c..efca752a1 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/WindowUtilNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/WindowUtilNEWT.java
@@ -60,8 +60,8 @@ public class WindowUtilNEWT {
}
}
- public static void run(GLWindow windowOffScreen, GLEventListener demo,
- GLWindow windowOnScreen, WindowListener wl, MouseListener ml,
+ public static void run(String testName, GLWindow windowOffScreen, GLEventListener demo,
+ GLWindow windowOnScreenBlit, WindowListener wl, MouseListener ml,
SurfaceUpdatedListener ul, int frames, boolean snapshot, boolean debug) {
Assert.assertNotNull(windowOffScreen);
Assert.assertNotNull(demo);
@@ -69,35 +69,34 @@ public class WindowUtilNEWT {
setDemoFields(demo, windowOffScreen, windowOffScreen, debug);
windowOffScreen.addGLEventListener(demo);
- if ( null != windowOnScreen ) {
+ if ( null != windowOnScreenBlit ) {
if(null!=wl) {
- windowOnScreen.addWindowListener(wl);
+ windowOnScreenBlit.addWindowListener(wl);
}
if(null!=ml) {
- windowOnScreen.addMouseListener(ml);
+ windowOnScreenBlit.addMouseListener(ml);
}
- windowOnScreen.setVisible(true);
+ windowOnScreenBlit.setVisible(true);
}
GLDrawable readDrawable = windowOffScreen.getContext().getGLDrawable() ;
-
- if ( null == windowOnScreen ) {
- if(snapshot) {
- Surface2File s2f = new Surface2File();
- windowOffScreen.addSurfaceUpdatedListener(s2f);
- }
- } else {
+ if ( null != windowOnScreenBlit ) {
ReadBuffer2Screen readDemo = new ReadBuffer2Screen( readDrawable ) ;
- windowOnScreen.addGLEventListener(readDemo);
+ windowOnScreenBlit.addGLEventListener(readDemo);
+ }
+ if(snapshot) {
+ final boolean alpha = windowOffScreen.getChosenGLCapabilities().getAlphaBits()>0;
+ Surface2File s2f = new Surface2File(testName, alpha);
+ windowOffScreen.addSurfaceUpdatedListener(s2f);
}
if(null!=ul) {
windowOffScreen.addSurfaceUpdatedListener(ul);
}
if(debug) {
- System.err.println("+++++++++++++++++++++++++++");
+ System.err.println("+++++++++++++++++++++++++++ "+testName);
System.err.println(windowOffScreen);
- System.err.println("+++++++++++++++++++++++++++");
+ System.err.println("+++++++++++++++++++++++++++ "+testName);
}
while ( windowOffScreen.getTotalFPSFrames() < frames) {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite01NEWT.java
index 687465a5d..b5b12035d 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite01NEWT.java
@@ -40,6 +40,7 @@ import com.jogamp.opengl.util.GLReadBufferUtil;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.jogl.offscreen.WindowUtilNEWT;
import org.junit.Assert;
import org.junit.BeforeClass;
@@ -56,6 +57,7 @@ public class TestGLReadBufferUtilTextureIOWrite01NEWT extends UITestCase {
Assert.assertNotNull(glp);
caps = new GLCapabilities(glp);
Assert.assertNotNull(caps);
+ caps.setAlphaBits(1); // req. alpha channel
width = 256;
height = 256;
}
@@ -68,7 +70,7 @@ public class TestGLReadBufferUtilTextureIOWrite01NEWT extends UITestCase {
}
@Test
- public void testWritePNG_TGA_PAM() throws InterruptedException {
+ public void testOnscreenWritePNG_TGA_PAM() throws InterruptedException {
GLWindow glWindow = GLWindow.create(caps);
Assert.assertNotNull(glWindow);
glWindow.setTitle("Shared Gears NEWT Test");
@@ -78,16 +80,38 @@ public class TestGLReadBufferUtilTextureIOWrite01NEWT extends UITestCase {
public void init(GLAutoDrawable drawable) {}
public void dispose(GLAutoDrawable drawable) {}
public void display(GLAutoDrawable drawable) {
+ final String pfmt = drawable.getChosenGLCapabilities().getAlphaBits() > 0 ? "rgba" : "rgb_";
// snapshot(drawable, false, true, getSimpleTestName(".")+"-rgb_-"+drawable.getGLProfile().getName()+".ppm");
- snapshot(drawable, true, false, getSimpleTestName(".")+"-rgba-"+drawable.getGLProfile().getName()+".png");
- snapshot(drawable, true, false, getSimpleTestName(".")+"-rgba-"+drawable.getGLProfile().getName()+".tga");
- snapshot(drawable, true, true, getSimpleTestName(".")+"-rgba-"+drawable.getGLProfile().getName()+".pam");
- snapshot(drawable, false, false, getSimpleTestName(".")+"-rgb_-"+drawable.getGLProfile().getName()+".png");
- snapshot(drawable, false, false, getSimpleTestName(".")+"-rgb_-"+drawable.getGLProfile().getName()+".tga");
- snapshot(drawable, false, true, getSimpleTestName(".")+"-rgb_-"+drawable.getGLProfile().getName()+".pam");
+ snapshot(drawable, true, false, getSimpleTestName(".")+"-F_rgba-I_"+pfmt+"-"+drawable.getGLProfile().getName()+".png");
+ snapshot(drawable, true, false, getSimpleTestName(".")+"-F_rgba-I_"+pfmt+"-"+drawable.getGLProfile().getName()+".tga");
+ snapshot(drawable, true, true, getSimpleTestName(".")+"-F_rgba-I_"+pfmt+"-"+drawable.getGLProfile().getName()+".pam");
+ snapshot(drawable, false, false, getSimpleTestName(".")+"-F_rgb_-I_"+pfmt+"-"+drawable.getGLProfile().getName()+".png");
+ snapshot(drawable, false, false, getSimpleTestName(".")+"-F_rgb_-I_"+pfmt+"-"+drawable.getGLProfile().getName()+".tga");
+ snapshot(drawable, false, true, getSimpleTestName(".")+"-F_rgb_-I_"+pfmt+"-"+drawable.getGLProfile().getName()+".pam");
}
- public void reshape(GLAutoDrawable drawable, int x, int y,
- int width, int height) { }
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { }
+ });
+ glWindow.setVisible(true);
+ Thread.sleep(60);
+ glWindow.destroy();
+ }
+
+ @Test
+ public void testOffscreenWritePNG() throws InterruptedException {
+ final GLCapabilities caps2 = WindowUtilNEWT.fixCaps(caps, false, true, false);
+ GLWindow glWindow = GLWindow.create(caps2);
+ Assert.assertNotNull(glWindow);
+ glWindow.setSize(width, height);
+ glWindow.addGLEventListener(new GearsES2(1));
+ glWindow.addGLEventListener(new GLEventListener() {
+ public void init(GLAutoDrawable drawable) {}
+ public void dispose(GLAutoDrawable drawable) {}
+ public void display(GLAutoDrawable drawable) {
+ final String pfmt = drawable.getChosenGLCapabilities().getAlphaBits() > 0 ? "rgba" : "rgb_";
+ snapshot(drawable, true, false, getSimpleTestName(".")+"-F_rgba-I_"+pfmt+"-"+drawable.getGLProfile().getName()+".png");
+ snapshot(drawable, false, false, getSimpleTestName(".")+"-F_rgb_-I_"+pfmt+"-"+drawable.getGLProfile().getName()+".png");
+ }
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { }
});
glWindow.setVisible(true);
Thread.sleep(60);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02NEWT.java
index 6bb7f3b73..25a773c6a 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02NEWT.java
@@ -58,6 +58,7 @@ public class TestGLReadBufferUtilTextureIOWrite02NEWT extends UITestCase {
Assert.assertNotNull(glp);
caps = new GLCapabilities(glp);
Assert.assertNotNull(caps);
+ caps.setAlphaBits(1); // req. alpha channel
width = 256;
height = 256;
}
@@ -81,19 +82,19 @@ public class TestGLReadBufferUtilTextureIOWrite02NEWT extends UITestCase {
public void init(GLAutoDrawable drawable) {}
public void dispose(GLAutoDrawable drawable) {}
public void display(GLAutoDrawable drawable) {
- StringWriter filename = new StringWriter();
+ final StringWriter filename = new StringWriter();
{
- PrintWriter pw = new PrintWriter(filename);
- pw.printf("%s-rgba-%s-%03dx%03d-n%03d.tga",
- getSimpleTestName("."), drawable.getGLProfile().getName(),
+ final PrintWriter pw = new PrintWriter(filename);
+ final String pfmt = drawable.getChosenGLCapabilities().getAlphaBits() > 0 ? "rgba" : "rgb_";
+ pw.printf("%s-F_rgba-I_%s-%s-%03dx%03d-n%03d.tga",
+ getSimpleTestName("."), pfmt, drawable.getGLProfile().getName(),
drawable.getWidth(), drawable.getHeight(), i++);
}
if(screenshot.readPixels(drawable.getGL(), drawable, false)) {
screenshot.write(new File(filename.toString()));
}
}
- public void reshape(GLAutoDrawable drawable, int x, int y,
- int width, int height) { }
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { }
});
glWindow.setVisible(true);
Thread.sleep(60);
@@ -117,19 +118,19 @@ public class TestGLReadBufferUtilTextureIOWrite02NEWT extends UITestCase {
public void init(GLAutoDrawable drawable) {}
public void dispose(GLAutoDrawable drawable) {}
public void display(GLAutoDrawable drawable) {
- StringWriter filename = new StringWriter();
+ final StringWriter filename = new StringWriter();
{
- PrintWriter pw = new PrintWriter(filename);
- pw.printf("%s-rgba-%s-%03dx%03d-n%03d.png",
- getSimpleTestName("."), drawable.getGLProfile().getName(),
+ final PrintWriter pw = new PrintWriter(filename);
+ final String pfmt = drawable.getChosenGLCapabilities().getAlphaBits() > 0 ? "rgba" : "rgb_";
+ pw.printf("%s-F_rgba-I_%s-%s-%03dx%03d-n%03d.png",
+ getSimpleTestName("."), pfmt, drawable.getGLProfile().getName(),
drawable.getWidth(), drawable.getHeight(), i++);
}
if(screenshot.readPixels(drawable.getGL(), drawable, false)) {
screenshot.write(new File(filename.toString()));
}
}
- public void reshape(GLAutoDrawable drawable, int x, int y,
- int width, int height) { }
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { }
});
glWindow.setVisible(true);
Thread.sleep(60);