summaryrefslogtreecommitdiffstats
path: root/src/junit
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-04-10 01:20:56 +0200
committerSven Gothel <[email protected]>2010-04-10 01:20:56 +0200
commit987fb51e6c2dc3a8553ff1e01162fd10c3bc8fab (patch)
tree656cb443a579487eb70746d5791782787aba7e38 /src/junit
parente8f4dc96c037b4465ad1db9062249f80508117fd (diff)
*** Now Using Apache-Ant-1.8.0 ***
Cleanup: - Adding Javac includeAntRuntime argument (false whenever possible) - Clear junit results folder before testing - <ant ..> tasks, use inheritRefs="true" inheritAll="true" whenever possible for better performance and consistency (no duplicate property names). The JOGL build -> build-<component> tree is clean in this respect. junit.run: Test*NEWT* Emulation of junit task, due to the fact that we have to place invoke our MainThread class first (-> MacOSX). Utilizing Ant-1.8.0 and ant-contrib-1.0b3 (loops, mutable properties). Fixed NEWT tests: - No more println .. using Assertions .. - Offscreen produces 2 files correctly (Linux/NVidia, OSX/NVidia, Win32/Emulation)
Diffstat (limited to 'src/junit')
-rwxr-xr-xsrc/junit/com/jogamp/test/junit/jogl/demos/es1/RedSquare.java32
-rwxr-xr-xsrc/junit/com/jogamp/test/junit/jogl/drawable/TestDrawable01NEWT.java75
-rwxr-xr-xsrc/junit/com/jogamp/test/junit/jogl/offscreen/ReadBuffer2File.java4
-rwxr-xr-xsrc/junit/com/jogamp/test/junit/jogl/offscreen/Surface2File.java10
-rwxr-xr-xsrc/junit/com/jogamp/test/junit/jogl/offscreen/TestOffscreen01NEWT.java8
-rwxr-xr-xsrc/junit/com/jogamp/test/junit/jogl/offscreen/WindowUtilNEWT.java22
6 files changed, 101 insertions, 50 deletions
diff --git a/src/junit/com/jogamp/test/junit/jogl/demos/es1/RedSquare.java b/src/junit/com/jogamp/test/junit/jogl/demos/es1/RedSquare.java
index 82da095b9..9b8982ed4 100755
--- a/src/junit/com/jogamp/test/junit/jogl/demos/es1/RedSquare.java
+++ b/src/junit/com/jogamp/test/junit/jogl/demos/es1/RedSquare.java
@@ -19,12 +19,18 @@ public class RedSquare implements GLEventListener {
public static boolean useAnimator = false;
public static int swapInterval = -1;
+ boolean debug = false;
long startTime = 0;
long curTime = 0;
GLU glu = null;
public RedSquare() {
+ this(false);
+ }
+
+ public RedSquare(boolean debug) {
+ this.debug = debug;
}
// FIXME: we must add storage of the pointers in the GL state to
@@ -75,14 +81,16 @@ public class RedSquare implements GLEventListener {
glu = GLU.createGLU(gl);
- System.err.println(Thread.currentThread()+" Entering initialization");
- System.err.println(Thread.currentThread()+" GL Profile: "+gl.getGLProfile());
- System.err.println(Thread.currentThread()+" GL:" + gl);
- System.err.println(Thread.currentThread()+" GL_VERSION=" + gl.glGetString(gl.GL_VERSION));
- System.err.println(Thread.currentThread()+" GL_EXTENSIONS:");
- System.err.println(Thread.currentThread()+" " + gl.glGetString(gl.GL_EXTENSIONS));
- System.err.println(Thread.currentThread()+" swapInterval: " + swapInterval + " (GL: "+gl.getSwapInterval()+")");
- System.err.println(Thread.currentThread()+" GLU: " + glu);
+ if(debug) {
+ System.err.println(Thread.currentThread()+" Entering initialization");
+ System.err.println(Thread.currentThread()+" GL Profile: "+gl.getGLProfile());
+ System.err.println(Thread.currentThread()+" GL:" + gl);
+ System.err.println(Thread.currentThread()+" GL_VERSION=" + gl.glGetString(gl.GL_VERSION));
+ System.err.println(Thread.currentThread()+" GL_EXTENSIONS:");
+ System.err.println(Thread.currentThread()+" " + gl.glGetString(gl.GL_EXTENSIONS));
+ System.err.println(Thread.currentThread()+" swapInterval: " + swapInterval + " (GL: "+gl.getSwapInterval()+")");
+ System.err.println(Thread.currentThread()+" GLU: " + glu);
+ }
// Allocate vertex arrays
colors = Buffers.newDirectFloatBuffer(16);
@@ -140,7 +148,9 @@ public class RedSquare implements GLEventListener {
public void dispose(GLAutoDrawable drawable) {
GL2ES1 gl = drawable.getGL().getGL2ES1();
- System.out.println(Thread.currentThread()+" RedSquare.dispose: "+gl.getContext());
+ if(debug) {
+ System.out.println(Thread.currentThread()+" RedSquare.dispose: "+gl.getContext());
+ }
gl.glDisableClientState(gl.GL_VERTEX_ARRAY);
gl.glDisableClientState(gl.GL_COLOR_ARRAY);
glu.destroy();
@@ -149,7 +159,9 @@ public class RedSquare implements GLEventListener {
colors = null;
vertices.clear();
vertices = null;
- System.out.println(Thread.currentThread()+" RedSquare.dispose: FIN");
+ if(debug) {
+ System.out.println(Thread.currentThread()+" RedSquare.dispose: FIN");
+ }
}
public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
diff --git a/src/junit/com/jogamp/test/junit/jogl/drawable/TestDrawable01NEWT.java b/src/junit/com/jogamp/test/junit/jogl/drawable/TestDrawable01NEWT.java
index 6c812ba18..fa15e3fef 100755
--- a/src/junit/com/jogamp/test/junit/jogl/drawable/TestDrawable01NEWT.java
+++ b/src/junit/com/jogamp/test/junit/jogl/drawable/TestDrawable01NEWT.java
@@ -55,10 +55,12 @@ public class TestDrawable01NEWT {
Window window;
GLDrawable drawable;
GLContext context;
+ GLDrawableFactory factory;
@BeforeClass
public static void initClass() {
glp = GLProfile.getDefault();
+ Assert.assertNotNull(glp);
width = 640;
height = 480;
}
@@ -66,56 +68,91 @@ public class TestDrawable01NEWT {
@Before
public void initTest() {
caps = new GLCapabilities(glp);
+ Assert.assertNotNull(caps);
}
void createWindow(boolean onscreen, boolean pbuffer, boolean undecorated) {
caps.setOnscreen(onscreen);
caps.setPBuffer(!onscreen && pbuffer);
caps.setDoubleBuffered(!onscreen);
- System.out.println("**********************************************************");
- System.out.println("**********************************************************");
- System.out.println("Requested: "+caps);
+ // System.out.println("Requested: "+caps);
//
// Create native windowing resources .. X11/Win/OSX
//
Display display = NewtFactory.createDisplay(null); // local display
+ Assert.assertNotNull(display);
+
Screen screen = NewtFactory.createScreen(display, 0); // screen 0
+ Assert.assertNotNull(screen);
+
window = NewtFactory.createWindow(screen, caps, onscreen && undecorated);
+ Assert.assertNotNull(window);
window.setSize(width, height);
window.setVisible(true);
- System.out.println("**********************************************************");
- System.out.println("**********************************************************");
- System.out.println("Created: "+window);
+ // System.out.println("Created: "+window);
//
// Create native OpenGL resources .. XGL/WGL/CGL ..
// equivalent to GLAutoDrawable methods: setVisible(true)
//
GLCapabilities glCaps = (GLCapabilities) window.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
-
- GLDrawableFactory factory = GLDrawableFactory.getFactory(glCaps.getGLProfile());
- System.out.println(factory);
+ Assert.assertNotNull(glCaps);
+ Assert.assertTrue(glCaps.getGreenBits()>5);
+ Assert.assertTrue(glCaps.getBlueBits()>5);
+ Assert.assertTrue(glCaps.getRedBits()>5);
+ Assert.assertTrue(glCaps.isOnscreen()==onscreen);
+ Assert.assertTrue(glCaps.isPBuffer()==(!onscreen && pbuffer));
+ Assert.assertTrue(glCaps.getDoubleBuffered()==!onscreen);
+ Assert.assertTrue(glCaps.getDepthBits()>4);
+
+ factory = GLDrawableFactory.getFactory(glCaps.getGLProfile());
+ Assert.assertNotNull(factory);
drawable = factory.createGLDrawable(window);
- System.out.println("**********************************************************");
- System.out.println("**********************************************************");
- System.out.println("Pre: "+drawable);
+ Assert.assertNotNull(drawable);
+ // System.out.println("Pre: "+drawable);
+ //
drawable.setRealized(true);
- System.out.println("**********************************************************");
- System.out.println("**********************************************************");
- System.out.println("Post: "+drawable);
+ Assert.assertTrue(width==drawable.getWidth());
+ Assert.assertTrue(height==drawable.getHeight());
+ // Assert.assertTrue(glCaps==drawable.getChosenGLCapabilities());
+ Assert.assertTrue(window==drawable.getNativeWindow());
+ // System.out.println("Post: "+drawable);
+
context = drawable.createContext(null);
- System.out.println(context);
+ Assert.assertNotNull(context);
+ // System.out.println(context);
+
+ int res = context.makeCurrent();
+ Assert.assertTrue(GLContext.CONTEXT_CURRENT_NEW==res || GLContext.CONTEXT_CURRENT==res);
+
+ // draw something ..
- System.out.println("**********************************************************");
- System.out.println("**********************************************************");
- System.out.println("Final: "+window);
+ drawable.swapBuffers();
+ context.release();
+
+ // System.out.println("Final: "+window);
}
void destroyWindow() {
+ // GLWindow.dispose(..) sequence
+ Assert.assertNotNull(context);
context.destroy();
+
+ Assert.assertNotNull(drawable);
drawable.setRealized(false);
+
+ // GLWindow.destroy(..) sequence cont..
+ Assert.assertNotNull(window);
window.destroy(true); // incl screen + display
+
+ drawable = null;
+ context = null;
+ window = null;
+
+ // test code cont ..
+ factory.shutdown();
+ factory = null;
}
@Test
diff --git a/src/junit/com/jogamp/test/junit/jogl/offscreen/ReadBuffer2File.java b/src/junit/com/jogamp/test/junit/jogl/offscreen/ReadBuffer2File.java
index 2b32f720e..4970cbbdf 100755
--- a/src/junit/com/jogamp/test/junit/jogl/offscreen/ReadBuffer2File.java
+++ b/src/junit/com/jogamp/test/junit/jogl/offscreen/ReadBuffer2File.java
@@ -60,9 +60,7 @@ public class ReadBuffer2File extends ReadBufferBase {
try {
File file = File.createTempFile("shot"+shotNum+"-", ".ppm");
TextureIO.write(readBufferUtil.getTextureData(), file);
- if(0==shotNum) {
- System.out.println("Wrote: "+file.getAbsolutePath()+", ...");
- }
+ System.out.println("Wrote: "+file.getAbsolutePath()+", ...");
shotNum++;
} catch (IOException ioe) { ioe.printStackTrace(); }
readBufferUtil.rewindPixelBuffer();
diff --git a/src/junit/com/jogamp/test/junit/jogl/offscreen/Surface2File.java b/src/junit/com/jogamp/test/junit/jogl/offscreen/Surface2File.java
index 43e2df54c..b4f1ba743 100755
--- a/src/junit/com/jogamp/test/junit/jogl/offscreen/Surface2File.java
+++ b/src/junit/com/jogamp/test/junit/jogl/offscreen/Surface2File.java
@@ -55,7 +55,11 @@ public class Surface2File implements SurfaceUpdatedListener {
GLDrawable drawable = (GLDrawable) updater;
GLContext ctx = GLContext.getCurrent();
if(null!=ctx && ctx.getGLDrawable()==drawable) {
- readBufferUtil.fetchOffscreenTexture(drawable, ctx.getGL());
+ GL gl = ctx.getGL();
+ // FIXME glFinish() is an expensive paranoia sync, should not be necessary due to spec
+ gl.glFinish();
+ readBufferUtil.fetchOffscreenTexture(drawable, gl);
+ gl.glFinish();
surface2File("shot");
}
}
@@ -67,9 +71,7 @@ public class Surface2File implements SurfaceUpdatedListener {
try {
File file = File.createTempFile(basename+shotNum+"-", ".ppm");
TextureIO.write(readBufferUtil.getTextureData(), file);
- if(0==shotNum) {
- System.out.println("Wrote: "+file.getAbsolutePath()+", ...");
- }
+ System.out.println("Wrote: "+file.getAbsolutePath()+", ...");
shotNum++;
} catch (IOException ioe) { ioe.printStackTrace(); }
readBufferUtil.rewindPixelBuffer();
diff --git a/src/junit/com/jogamp/test/junit/jogl/offscreen/TestOffscreen01NEWT.java b/src/junit/com/jogamp/test/junit/jogl/offscreen/TestOffscreen01NEWT.java
index 5800af9af..277b41af3 100755
--- a/src/junit/com/jogamp/test/junit/jogl/offscreen/TestOffscreen01NEWT.java
+++ b/src/junit/com/jogamp/test/junit/jogl/offscreen/TestOffscreen01NEWT.java
@@ -66,7 +66,6 @@ public class TestOffscreen01NEWT {
@Test
public void test01OffscreenWindow() {
- if(true) {
GLWindow windowOffscreen = WindowUtilNEWT.createGLWindow(caps, width, height, false, true, false);
GLEventListener demo = new RedSquare();
GLWindow windowOnScreen = null;
@@ -74,17 +73,15 @@ public class TestOffscreen01NEWT {
MouseListener ml=null;
SurfaceUpdatedListener ul=null;
- WindowUtilNEWT.run(windowOffscreen, null, windowOnScreen, wl, ml, ul, 2, true /*debug*/);
+ WindowUtilNEWT.run(windowOffscreen, null, windowOnScreen, wl, ml, ul, 2, false /*snapshot*/, false /*debug*/);
try {
Thread.sleep(1000); // 1000 ms
} catch (Exception e) {}
WindowUtilNEWT.shutdown(windowOffscreen, windowOnScreen);
- }
}
@Test
public void test02OffscreenSnapshotWithDemo() {
- if(true) {
GLWindow windowOffscreen = WindowUtilNEWT.createGLWindow(caps, width, height, false, true, false);
GLEventListener demo = new RedSquare();
GLWindow windowOnScreen = null;
@@ -92,12 +89,11 @@ public class TestOffscreen01NEWT {
MouseListener ml=null;
SurfaceUpdatedListener ul=null;
- WindowUtilNEWT.run(windowOffscreen, demo, windowOnScreen, wl, ml, ul, 2, true /*debug*/);
+ WindowUtilNEWT.run(windowOffscreen, demo, windowOnScreen, wl, ml, ul, 2, true /*snapshot*/, false /*debug*/);
try {
Thread.sleep(1000); // 1000 ms
} catch (Exception e) {}
WindowUtilNEWT.shutdown(windowOffscreen, windowOnScreen);
- }
}
public static void main(String args[]) {
diff --git a/src/junit/com/jogamp/test/junit/jogl/offscreen/WindowUtilNEWT.java b/src/junit/com/jogamp/test/junit/jogl/offscreen/WindowUtilNEWT.java
index b9541dbaf..26b13cf7d 100755
--- a/src/junit/com/jogamp/test/junit/jogl/offscreen/WindowUtilNEWT.java
+++ b/src/junit/com/jogamp/test/junit/jogl/offscreen/WindowUtilNEWT.java
@@ -77,7 +77,7 @@ public class WindowUtilNEWT {
public static void run(GLWindow windowOffscreen, GLEventListener demo,
GLWindow windowOnScreen, WindowListener wl, MouseListener ml,
- SurfaceUpdatedListener ul, int frames, boolean debug) {
+ SurfaceUpdatedListener ul, int frames, boolean snapshot, boolean debug) {
try {
if(debug && null!=demo) {
MiscUtils.setField(demo, "glDebug", new Boolean(true));
@@ -103,22 +103,28 @@ public class WindowUtilNEWT {
GLDrawable readDrawable = windowOffscreen.getContext().getGLDrawable() ;
if ( null == windowOnScreen ) {
- ReadBuffer2File readDemo = new ReadBuffer2File( readDrawable ) ;
+ if(snapshot) {
+ Surface2File s2f = new Surface2File();
+ windowOffscreen.addSurfaceUpdatedListener(s2f);
+ }
} else {
ReadBuffer2Screen readDemo = new ReadBuffer2Screen( readDrawable ) ;
windowOnScreen.addGLEventListener(readDemo);
- if(null!=wl) {
- windowOffscreen.addSurfaceUpdatedListener(ul);
- }
+ }
+ if(null!=ul) {
+ windowOffscreen.addSurfaceUpdatedListener(ul);
}
- System.out.println("+++++++++++++++++++++++++++");
- System.out.println(windowOffscreen);
- System.out.println("+++++++++++++++++++++++++++");
+ if(debug) {
+ System.out.println("+++++++++++++++++++++++++++");
+ System.out.println(windowOffscreen);
+ System.out.println("+++++++++++++++++++++++++++");
+ }
while ( windowOffscreen.getTotalFrames() < frames) {
windowOffscreen.display();
}
+ windowOffscreen.removeAllSurfaceUpdatedListener();
} catch (GLException e) {
e.printStackTrace();