diff options
author | Sven Gothel <[email protected]> | 2010-04-10 01:20:56 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2010-04-10 01:20:56 +0200 |
commit | 987fb51e6c2dc3a8553ff1e01162fd10c3bc8fab (patch) | |
tree | 656cb443a579487eb70746d5791782787aba7e38 | |
parent | e8f4dc96c037b4465ad1db9062249f80508117fd (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)
-rw-r--r-- | make/build-common.xml | 4 | ||||
-rw-r--r-- | make/build-gluegen.xml | 4 | ||||
-rw-r--r-- | make/build-jogl.xml | 5 | ||||
-rw-r--r-- | make/build-junit.xml | 79 | ||||
-rw-r--r-- | make/build-nativewindow.xml | 2 | ||||
-rw-r--r-- | make/build-newt.xml | 2 | ||||
-rw-r--r-- | make/build-staticglgen.xml | 10 | ||||
-rw-r--r-- | make/build.xml | 16 | ||||
-rwxr-xr-x | src/junit/com/jogamp/test/junit/jogl/demos/es1/RedSquare.java | 32 | ||||
-rwxr-xr-x | src/junit/com/jogamp/test/junit/jogl/drawable/TestDrawable01NEWT.java | 75 | ||||
-rwxr-xr-x | src/junit/com/jogamp/test/junit/jogl/offscreen/ReadBuffer2File.java | 4 | ||||
-rwxr-xr-x | src/junit/com/jogamp/test/junit/jogl/offscreen/Surface2File.java | 10 | ||||
-rwxr-xr-x | src/junit/com/jogamp/test/junit/jogl/offscreen/TestOffscreen01NEWT.java | 8 | ||||
-rwxr-xr-x | src/junit/com/jogamp/test/junit/jogl/offscreen/WindowUtilNEWT.java | 22 |
14 files changed, 206 insertions, 67 deletions
diff --git a/make/build-common.xml b/make/build-common.xml index bee69a5a9..10f37c3e4 100644 --- a/make/build-common.xml +++ b/make/build-common.xml @@ -8,6 +8,8 @@ <property name="gluegen.root" value="../../gluegen" /> <import file="${gluegen.root}/make/gluegen-cpptasks.xml" /> + <property name="ant-contrib.jar" value="${gluegen.root}/make/lib/ant-contrib-1.0b3.jar" /> + <condition property="rootrel.build" value="build"> <not> <isset property="rootrel.build"/> @@ -191,6 +193,8 @@ <pathelement location="${newt.all.jar}" /> <pathelement location="${jogl.test.jar}" /> </path> + <property name="junit_jogl_newt.run.jars" + value="${junit.jar}${path.separator}${gluegen-rt.jar}${path.separator}${nativewindow.all.jar}${path.separator}${jogl.all.jar}${path.separator}${newt.all.jar}${path.separator}${jogl.test.jar}"/> <!-- JavaSE combinations . NO.AWT --> <property name="nativewindow.all-noawt.jar" value="${build.nativewindow}/nativewindow.all-noawt.jar" /> diff --git a/make/build-gluegen.xml b/make/build-gluegen.xml index 992599cdb..fedfd9d93 100644 --- a/make/build-gluegen.xml +++ b/make/build-gluegen.xml @@ -88,6 +88,7 @@ - NOTE: GlueGenTask is NOT built at this time. It is done in - a separate task. --> <javac destdir="${classes}" includes="**/gluegen/**" excludes="**/GlueGenTask.java" + includeAntRuntime="false" source="1.4" debug="true" debuglevel="source,lines"> <src path="${src.java}" /> <src path="${src.generated.java}" /> @@ -140,7 +141,8 @@ <!-- Build the GlueGen ANT task. - NOTE: ONLY the GlueGenTask is built at this time. GlueGen - itself is built in a separate task. --> - <javac destdir="${classes}" includes="**/GlueGenTask.java" source="1.4" debug="true" debuglevel="source,lines"> + <javac destdir="${classes}" includes="**/GlueGenTask.java" source="1.4" debug="true" debuglevel="source,lines" + includeAntRuntime="false"> <src path="${src.java}" /> <classpath refid="antlr.classpath" /> </javac> diff --git a/make/build-jogl.xml b/make/build-jogl.xml index 5381c2051..b1f0a02eb 100644 --- a/make/build-jogl.xml +++ b/make/build-jogl.xml @@ -949,6 +949,7 @@ includes="javax/media/opengl/fixedfunc/** javax/media/opengl/GLDrawableFactory.java javax/media/opengl/GLDrawable.java javax/media/opengl/GLContext.java javax/media/opengl/GL.java javax/media/opengl/GL2ES1.java javax/media/opengl/GL2ES2.java javax/media/opengl/GL2GL3.java javax/media/opengl/GL2.java javax/media/opengl/GLES1.java javax/media/opengl/GLES2.java javax/media/opengl/GL3.java javax/media/opengl/GL3bc.java" fork="yes" memoryMaximumSize="${javac.memorymax}" + includeAntRuntime="false" source="1.4" debug="${javacdebug}" debuglevel="${javacdebuglevel}"> <classpath refid="nativewindow_gluegen.classpath"/> <src path="${src.java}" /> @@ -973,6 +974,7 @@ source="${target.sourcelevel}" fork="yes" memoryMaximumSize="${javac.memorymax}" + includeAntRuntime="false" debug="${javacdebug}" debuglevel="${javacdebuglevel}"> <classpath refid="nativewindow_gluegen.classpath"/> <src path="${src.java}" /> @@ -988,6 +990,7 @@ source="${target.sourcelevel}" fork="yes" memoryMaximumSize="${javac.memorymax}" + includeAntRuntime="false" debug="${javacdebug}" debuglevel="${javacdebuglevel}"> <classpath refid="nativewindow_gluegen.classpath-cdc"/> <src path="${src.java}" /> @@ -1004,6 +1007,7 @@ source="${target.sourcelevel}" fork="yes" memoryMaximumSize="${javac.memorymax}" + includeAntRuntime="false" debug="${javacdebug}" debuglevel="${javacdebuglevel}"> <classpath refid="nativewindow_gluegen.classpath"/> <src path="${src.java}" /> @@ -1019,6 +1023,7 @@ bootclasspath="${javac.bootclasspath-cdc.jar}" fork="yes" memoryMaximumSize="${javac.memorymax}" + includeAntRuntime="false" debug="${javacdebug}" debuglevel="${javacdebuglevel}"> <classpath refid="nativewindow_gluegen.classpath-cdc"/> <src path="${src.java}" /> diff --git a/make/build-junit.xml b/make/build-junit.xml index f06035de3..74cb30606 100644 --- a/make/build-junit.xml +++ b/make/build-junit.xml @@ -6,6 +6,10 @@ <import file="build-common.xml"/> + <taskdef resource="net/sf/antcontrib/antlib.xml"> + <classpath> <pathelement location="${ant-contrib.jar}"/> </classpath> + </taskdef> + <!-- ================================================================== --> <!-- - Declare all paths and user defined variables. @@ -15,10 +19,13 @@ <property name="src.junit" value="${project.root}/${rootrel.src.junit}" /> <property name="classes" value="${build.junit}/classes" /> + <property name="classes.path" location="${classes}"/> <!-- absolute path --> <property name="java.dir.test" value="com/jogamp/test"/> <property name="java.part.test" value="${java.dir.test}/**"/> + <property name="batchtest.timeout" value="10000"/> + </target> <!-- ================================================================== --> @@ -52,6 +59,7 @@ source="${host.sourcelevel}" fork="yes" memoryMaximumSize="${javac.memorymax}" + includeAntRuntime="false" debug="${javacdebug}" debuglevel="${javacdebuglevel}"> <classpath refid="junit_jogl_newt.compile.classpath"/> <src path="${src.junit}" /> @@ -63,10 +71,73 @@ </jar> </target> - <target name="junit.run" depends="declare.common"> + <target name="junit.run" depends="junit.compile"> <!-- Perform the junit tests--> <mkdir dir="${results.junit}" /> - <junit forkmode="once" showoutput="true" fork="true" haltonerror="off" timeout="30000"> + <delete quiet="true"> + <fileset dir="${results.junit}" includes="**"/> + </delete> + + <condition property="jvmarg.newt" value="-XstartOnFirstThread -Djava.awt.headless=true"><isset property="isOSX"/></condition> + <condition property="jvmarg.newt" value="-Djava.awt.headless=true"><not><isset property="isOSX"/></not></condition> + + <!-- 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). + --> + <for param="test.class.path.m" keepgoing="true"> + <!-- results in absolute path --> + <fileset dir="${classes}"> + <include name="${java.dir.test}/**/Test*NEWT*"/> + </fileset> + <sequential> + <var name="test.class.path" unset="true"/> + <property name="test.class.path" basedir="${classes}" relative="true" location="@{test.class.path.m}"/> + <var name="test.class.fqn" unset="true"/> + <pathconvert property="test.class.fqn"> + <fileset file="${classes}/${test.class.path}"/> + <chainedmapper> + <globmapper from="${classes.path}/*" to="*"/> <!-- rel. --> + <packagemapper from="*.class" to="*"/> <!-- FQCN --> + </chainedmapper> + </pathconvert> + <var name="test.class.result.file" value="${results.junit}/TEST-${test.class.fqn}.xml"/> + <echo message="Testing ${test.class.fqn} -> ${test.class.result.file}"/> + <apply dir="." executable="java" + parallel="false" + timeout="${batchtest.timeout}" + vmlauncher="false" + relative="true" + failonerror="false"> + <env key="${system.env.library.path}" path="${obj.all.paths}"/> + <env key="CLASSPATH" value="${ant.home}/lib/ant.jar${path.separator}${ant.home}/lib/ant-junit.jar${path.separator}${junit_jogl_newt.run.jars}"/> + <arg value="-Djava.library.path=${obj.all.paths}"/> + <arg line="${jvmarg.newt}"/> + <arg line="com.jogamp.newt.util.MainThread"/> + <arg line="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner"/> + <srcfile/> + <arg line="filtertrace=true"/> + <arg line="haltOnError=false"/> + <arg line="haltOnFailure=false"/> + <arg line="showoutput=true"/> + <arg line="outputtoformatters=true"/> + <arg line="logfailedtests=true"/> + <arg line="logtestlistenerevents=true"/> + <arg line="formatter=org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter"/> + <arg line="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.class.result.file}"/> + <mappedresources> + <fileset dir="${classes}" includes="${test.class.path}"/> + <packagemapper from="*.class" to="*"/> + </mappedresources> + </apply> + </sequential> + </for> + + <!-- Test*AWT* --> + <junit forkmode="once" showoutput="true" fork="true" haltonerror="off" timeout="${batchtest.timeout}"> <env key="${system.env.library.path}" path="${obj.all.paths}"/> <jvmarg value="-Djava.library.path=${obj.all.paths}"/> @@ -88,13 +159,13 @@ <batchtest todir="${results.junit}"> <fileset dir="${classes}"> - <include name="${java.dir.test}/**/Test*"/> + <include name="${java.dir.test}/**/Test*AWT*"/> </fileset> <formatter usefile="false" type="brief"/> <formatter usefile="true" type="xml"/> </batchtest> - </junit> + </target> <!-- ================================================================== --> diff --git a/make/build-nativewindow.xml b/make/build-nativewindow.xml index 3cb7e7746..3a62e9733 100644 --- a/make/build-nativewindow.xml +++ b/make/build-nativewindow.xml @@ -319,6 +319,7 @@ classpath="${gluegen-rt-cdc.jar}" bootclasspath="${javac.bootclasspath-cdc.jar}" fork="yes" + includeAntRuntime="false" memoryMaximumSize="${javac.memorymax}" debug="${javacdebug}" debuglevel="${javacdebuglevel}"> <src path="${src.java}" /> @@ -333,6 +334,7 @@ source="${target.sourcelevel}" classpath="${gluegen-rt.jar}" fork="yes" + includeAntRuntime="false" memoryMaximumSize="${javac.memorymax}" debug="${javacdebug}" debuglevel="${javacdebuglevel}"> <src path="${src.java}" /> diff --git a/make/build-newt.xml b/make/build-newt.xml index d8f8c2b60..db357bf37 100644 --- a/make/build-newt.xml +++ b/make/build-newt.xml @@ -195,6 +195,7 @@ excludes="${java.excludes.all}" source="${target.sourcelevel}" fork="yes" + includeAntRuntime="false" memoryMaximumSize="${javac.memorymax}" debug="${javacdebug}" debuglevel="${javacdebuglevel}"> <src path="${src.java}" /> @@ -209,6 +210,7 @@ source="${target.sourcelevel}" bootclasspath="${javac.bootclasspath-cdc.jar}" fork="yes" + includeAntRuntime="false" memoryMaximumSize="${javac.memorymax}" debug="${javacdebug}" debuglevel="${javacdebuglevel}"> <classpath refid="nativewindow_gluegen_jogl.classpath-cdc"/> diff --git a/make/build-staticglgen.xml b/make/build-staticglgen.xml index 2683b305a..3d5fb2d12 100644 --- a/make/build-staticglgen.xml +++ b/make/build-staticglgen.xml @@ -29,7 +29,8 @@ <mkdir dir="${classes}" /> <!-- Compile BuildStaticGLInfo --> - <javac srcdir="${src.java}" destdir="${classes}" includes="**/BuildStaticGLInfo.java" source="1.4" debug="true" debuglevel="source,lines"> + <javac srcdir="${src.java}" destdir="${classes}" includes="**/BuildStaticGLInfo.java" source="1.4" debug="true" debuglevel="source,lines" + includeAntRuntime="false"> <classpath refid="antlr.classpath" /> </javac> @@ -49,8 +50,9 @@ <!-- Build the BuildStaticGLInfo ANT task. - NOTE: ONLY the StaticGLGen is built at this time. BuildStaticGLInfo - itself is built in a separate task. --> - <javac destdir="${classes}" includes="**/StaticGLGenTask.java" source="1.4" debug="true" debuglevel="source,lines"> - <src path="${src.java}" /> + <javac destdir="${classes}" includes="**/StaticGLGenTask.java" source="1.4" debug="true" debuglevel="source,lines" + includeAntRuntime="false"> + <src path="${src.java}" /> <classpath refid="classpath" /> </javac> @@ -88,4 +90,4 @@ <antcall target="build.static.gl.task" /> </target> -</project>
\ No newline at end of file +</project> diff --git a/make/build.xml b/make/build.xml index e39e6dea2..8d2c9765a 100644 --- a/make/build.xml +++ b/make/build.xml @@ -30,15 +30,15 @@ </target> <target name="build.nativewindow" depends="init"> - <ant antfile="${nativewindow.build.xml}" dir="${nativewindow.make}" target="all" inheritAll="false"/> + <ant antfile="${nativewindow.build.xml}" dir="${nativewindow.make}" target="all" inheritRefs="true" inheritAll="true"/> </target> <target name="build.jogl" depends="init"> - <ant antfile="${jogl.build.xml}" dir="${jogl.make}" target="all" inheritAll="false"/> + <ant antfile="${jogl.build.xml}" dir="${jogl.make}" target="all" inheritRefs="true" inheritAll="true"/> </target> <target name="build.newt" depends="init"> - <ant antfile="${newt.build.xml}" dir="${newt.make}" target="all" inheritAll="false"/> + <ant antfile="${newt.build.xml}" dir="${newt.make}" target="all" inheritRefs="true" inheritAll="true"/> </target> <target name="one-lib-dir" depends="init,gluegen.cpptasks.detect.os"> @@ -128,18 +128,18 @@ <target name="all" description="Build nativewindow, jogl and newt projects, incl. all junit tests " depends="init,build.nativewindow,build.jogl,build.newt,junit.compile,one-lib-dir,developer-zip-archive,source-archive" /> <target name="junit.compile"> - <ant antfile="build-junit.xml" target="junit.compile"/> + <ant antfile="build-junit.xml" target="junit.compile" inheritRefs="true" inheritAll="true"/> </target> <target name="test" depends="junit.run"/> <target name="junit.run" description="Run JUNIT tests in nativewindow, jogl and newt projects"> - <ant antfile="build-junit.xml" target="junit.run"/> + <ant antfile="build-junit.xml" target="junit.run" inheritRefs="true" inheritAll="true"/> </target> <target name="clean" depends="init"> - <ant antfile="${nativewindow.build.xml}" dir="${nativewindow.make}" target="clean" inheritAll="false"/> - <ant antfile="${jogl.build.xml}" dir="${jogl.make}" target="clean" inheritAll="false"/> - <ant antfile="${newt.build.xml}" dir="${newt.make}" target="clean" inheritAll="false"/> + <ant antfile="${nativewindow.build.xml}" dir="${nativewindow.make}" target="clean" inheritRefs="true" inheritAll="true"/> + <ant antfile="${jogl.build.xml}" dir="${jogl.make}" target="clean" inheritRefs="true" inheritAll="true"/> + <ant antfile="${newt.build.xml}" dir="${newt.make}" target="clean" inheritRefs="true" inheritAll="true"/> <delete includeEmptyDirs="true" quiet="true"> <fileset dir="${build}" /> </delete> 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(); |