diff options
Diffstat (limited to 'src/test')
11 files changed, 146 insertions, 10 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFloatUtil01MatrixMatrixMultNOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtil01MatrixMatrixMultNOUI.java index adeb700d7..83a1be456 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFloatUtil01MatrixMatrixMultNOUI.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtil01MatrixMatrixMultNOUI.java @@ -26,7 +26,7 @@ * or implied, of JogAmp Community. */ -package com.jogamp.opengl.test.junit.jogl.acore; +package com.jogamp.opengl.test.junit.jogl.math; import org.junit.Assert; import org.junit.Test; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestGluUnprojectDoubleNOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestGluUnprojectDoubleNOUI.java index 34b30f04e..32861f764 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestGluUnprojectDoubleNOUI.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestGluUnprojectDoubleNOUI.java @@ -26,7 +26,7 @@ * or implied, of JogAmp Community. */ -package com.jogamp.opengl.test.junit.jogl.glu; +package com.jogamp.opengl.test.junit.jogl.math; import javax.media.opengl.glu.GLU; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestGluUnprojectFloatNOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestGluUnprojectFloatNOUI.java index 717d5e4b8..9951500fc 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestGluUnprojectFloatNOUI.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestGluUnprojectFloatNOUI.java @@ -26,7 +26,7 @@ * or implied, of JogAmp Community. */ -package com.jogamp.opengl.test.junit.jogl.glu; +package com.jogamp.opengl.test.junit.jogl.math; import javax.media.opengl.glu.GLU; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPMVMatrix01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix01NEWT.java index c99bac9a4..3d9bfed7e 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPMVMatrix01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix01NEWT.java @@ -26,7 +26,7 @@ * or implied, of JogAmp Community. */ -package com.jogamp.opengl.test.junit.jogl.acore; +package com.jogamp.opengl.test.junit.jogl.math; import java.nio.FloatBuffer; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPMVMatrix02NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix02NOUI.java index 4e959d460..0c66ad237 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPMVMatrix02NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix02NOUI.java @@ -26,7 +26,7 @@ * or implied, of JogAmp Community.
*/
-package com.jogamp.opengl.test.junit.jogl.acore;
+package com.jogamp.opengl.test.junit.jogl.math;
import org.junit.Before;
import org.junit.Test;
@@ -41,7 +41,7 @@ import static org.junit.Assert.assertArrayEquals; /**
* @author Thomas De Bodt
*/
-public class TestPMVMatrix02NEWT {
+public class TestPMVMatrix02NOUI {
private PMVMatrix fMat;
@@ -104,6 +104,6 @@ public class TestPMVMatrix02NEWT { }
public static void main(String args[]) {
- org.junit.runner.JUnitCore.main(TestPMVMatrix02NEWT.class.getName());
+ org.junit.runner.JUnitCore.main(TestPMVMatrix02NOUI.class.getName());
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix03NOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix03NOUI.java new file mode 100644 index 000000000..81242ce6e --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix03NOUI.java @@ -0,0 +1,125 @@ +package com.jogamp.opengl.test.junit.jogl.math; + +import java.util.Arrays; + +import jogamp.opengl.ProjectFloat; + +import com.jogamp.opengl.math.FloatUtil; +import com.jogamp.opengl.util.PMVMatrix; + +import org.junit.Assert; +import org.junit.Test; + +public class TestPMVMatrix03NOUI { + + static final float epsilon = 0.00001f; + + // Simple 10 x 10 view port + static final int[] viewport = new int[] { 0,0,10,10}; + + @Test + public void test01() { + float[] winA00 = new float[4]; + float[] winA01 = new float[4]; + float[] winA10 = new float[4]; + float[] winA11 = new float[4]; + PMVMatrix m = new PMVMatrix(); + + m.gluProject(1f, 0f, 0f, viewport, 0, winA00, 0); + System.out.println("A.0.0 - Project 1,0 -->" + Arrays.toString(winA00)); + + m.gluProject(0f, 0f, 0f, viewport, 0, winA01, 0); + System.out.println("A.0.1 - Project 0,0 -->" + Arrays.toString(winA01)); + + m.glMatrixMode(PMVMatrix.GL_PROJECTION); + m.glOrthof(0, 10, 0, 10, 1, -1); + System.out.println("MATRIX - Ortho 0,0,10,10 - Locate the origin in the bottom left and scale"); + System.out.println(m); + float[] projMatrixA = new float[16]; + float[] modelMatrixA = new float[16]; + m.glGetFloatv(PMVMatrix.GL_PROJECTION, projMatrixA, 0); + m.glGetFloatv(PMVMatrix.GL_MODELVIEW, modelMatrixA, 0); + + m.gluProject(1f, 0f, 0f, viewport, 0, winA10, 0); + System.out.println("A.1.0 - Project 1,0 -->" +Arrays.toString(winA10)); + + m.gluProject(0f, 0f, 0f, viewport, 0, winA11, 0); + System.out.println("A.1.1 - Project 0,0 -->" +Arrays.toString(winA11)); + + + //////////////////// + ///////////////////// + + float[] winB00 = new float[4]; + float[] winB01 = new float[4]; + float[] winB10 = new float[4]; + float[] winB11 = new float[4]; + float[] projMatrixB = new float[16]; + float[] modelMatrixB = new float[16]; + FloatUtil.makeIdentityf(projMatrixB, 0); + FloatUtil.makeIdentityf(modelMatrixB, 0); + final ProjectFloat projectFloat = new ProjectFloat(true); + + projectFloat.gluProject(1f, 0f, 0f, modelMatrixB, 0, projMatrixB, 0, viewport, 0, winB00, 0); + System.out.println("B.0.0 - Project 1,0 -->" +Arrays.toString(winB00)); + + projectFloat.gluProject(0f, 0f, 0f, modelMatrixB, 0, projMatrixB, 0, viewport, 0, winB01, 0); + System.out.println("B.0.1 - Project 0,0 -->" +Arrays.toString(winB01)); + + glOrthof(projMatrixB, 0, 10, 0, 10, 1, -1); + System.out.println("FloatUtil - Ortho 0,0,10,10 - Locate the origin in the bottom left and scale"); + System.out.println("Projection"); + System.err.println(FloatUtil.matrixToString(null, null, "%10.5f", projMatrixB, 0, 4, 4, false /* rowMajorOrder */)); + System.out.println("Modelview"); + System.err.println(FloatUtil.matrixToString(null, null, "%10.5f", modelMatrixB, 0, 4, 4, false /* rowMajorOrder */)); + + projectFloat.gluProject(1f, 0f, 0f, modelMatrixB, 0, projMatrixB, 0, viewport, 0, winB10, 0); + System.out.println("B.1.0 - Project 1,0 -->" +Arrays.toString(winB10)); + + projectFloat.gluProject(0f, 0f, 0f, modelMatrixB, 0, projMatrixB, 0, viewport, 0, winB11, 0); + System.out.println("B.1.1 - Project 0,0 -->" +Arrays.toString(winB11)); + + Assert.assertArrayEquals("A/B 0.0 Project 1,0 failure", winB00, winA00, epsilon); + Assert.assertArrayEquals("A/B 0.1 Project 0,0 failure", winB01, winA01, epsilon); + Assert.assertArrayEquals("A/B 1.0 Project 1,0 failure", winB10, winA10, epsilon); + Assert.assertArrayEquals("A/B 1.1 Project 0,0 failure", winB11, winA11, epsilon); + + Assert.assertEquals("A 0.0 Project 1,0 failure X", 10.0, winA00[0], epsilon); + Assert.assertEquals("A 0.0 Project 1,0 failure Y", 5.0, winA00[1], epsilon); + Assert.assertEquals("A.0.1 Project 0,0 failure X", 5.0, winA01[0], epsilon); + Assert.assertEquals("A.0.1 Project 0,0 failure Y", 5.0, winA01[1], epsilon); + Assert.assertEquals("A 1.0 Project 1,0 failure X", 1.0, winA10[0], epsilon); + Assert.assertEquals("A 1.0 Project 1,0 failure Y", 0.0, winA10[1], epsilon); + Assert.assertEquals("A.1.1 Project 0,0 failure X", 0.0, winA11[0], epsilon); + Assert.assertEquals("A.1.1 Project 0,0 failure Y", 0.0, winA11[1], epsilon); + } + + public final void glOrthof(final float[] m, final float left, final float right, final float bottom, final float top, final float zNear, final float zFar) { + // Ortho matrix: + // 2/dx 0 0 tx + // 0 2/dy 0 ty + // 0 0 2/dz tz + // 0 0 0 1 + final float dx=right-left; + final float dy=top-bottom; + final float dz=zFar-zNear; + final float tx=-1.0f*(right+left)/dx; + final float ty=-1.0f*(top+bottom)/dy; + final float tz=-1.0f*(zFar+zNear)/dz; + + float[] matrixOrtho = new float[16]; + FloatUtil.makeIdentityf(matrixOrtho, 0); + matrixOrtho[0+4*0] = 2.0f/dx; + matrixOrtho[1+4*1] = 2.0f/dy; + matrixOrtho[2+4*2] = -2.0f/dz; + matrixOrtho[0+4*3] = tx; + matrixOrtho[1+4*3] = ty; + matrixOrtho[2+4*3] = tz; + + FloatUtil.multMatrixf(m, 0, matrixOrtho, 0); + } + + public static void main(String args[]) { + org.junit.runner.JUnitCore.main(TestPMVMatrix03NOUI.class.getName()); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage01NEWT.java index 7b53d973c..81f64f0ae 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage01NEWT.java @@ -26,7 +26,7 @@ public class TestPNGImage01NEWT extends UITestCase { System.err.println("PNGImage - Orig: "+image1); image1.write(out1_f, true); { - Assert.assertEquals(image1.getData(), PNGImage.read(IOUtil.toURL(out1_f).openStream()).getData()); + Assert.assertEquals(image1.getData(), PNGImage.read(out1_f.toURI().toURL().openStream()).getData()); } final PNGImage image2 = PNGImage.createFromData(image1.getWidth(), image1.getHeight(), @@ -34,7 +34,7 @@ public class TestPNGImage01NEWT extends UITestCase { image1.getBytesPerPixel(), false /* reverseChannels */, image1.isGLOriented(), image1.getData()); image2.write(out2_f, true); { - Assert.assertEquals(image1.getData(), PNGImage.read(IOUtil.toURL(out2_f).openStream()).getData()); + Assert.assertEquals(image1.getData(), PNGImage.read(out2_f.toURI().toURL().openStream()).getData()); } // flipped diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00bNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00bNEWT.java index f4eaec5fa..fe5dd93cb 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00bNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00bNEWT.java @@ -42,6 +42,7 @@ import com.jogamp.newt.Screen; import com.jogamp.newt.MonitorMode; 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; @@ -110,6 +111,7 @@ public class TestScreenMode00bNEWT extends UITestCase { Assert.assertEquals(false,window.isVisible()); Assert.assertEquals(false,window.isNativeValid()); + Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); Assert.assertEquals(false,screen.isNativeValid()); Assert.assertEquals(false,display.isNativeValid()); } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01NEWT.java index 2dd16b9d2..a2ce7cec0 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01NEWT.java @@ -261,6 +261,7 @@ public class TestScreenMode01NEWT extends UITestCase { Assert.assertEquals(false,window.isVisible()); Assert.assertEquals(false,window.isRealized()); Assert.assertEquals(false,window.isNativeValid()); + Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); Assert.assertEquals(false,screen.isNativeValid()); Assert.assertEquals(false,display.isNativeValid()); @@ -363,6 +364,7 @@ public class TestScreenMode01NEWT extends UITestCase { Assert.assertEquals(false,window.isVisible()); Assert.assertEquals(false,window.isRealized()); Assert.assertEquals(false,window.isNativeValid()); + Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); Assert.assertEquals(false,screen.isNativeValid()); Assert.assertEquals(false,display.isNativeValid()); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode02NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode02NEWT.java index 542297209..58bce4cc9 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode02NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode02NEWT.java @@ -49,6 +49,7 @@ import com.jogamp.newt.MonitorMode; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.newt.util.MonitorModeUtil; 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 java.util.List; import javax.media.nativewindow.util.Dimension; @@ -167,6 +168,7 @@ public class TestScreenMode02NEWT extends UITestCase { Assert.assertEquals(false,window.isVisible()); Assert.assertEquals(false,window.isNativeValid()); + Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); Assert.assertEquals(false,screen.isNativeValid()); Assert.assertEquals(false,display.isNativeValid()); diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java index e128123ed..b5f8def3c 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java @@ -633,7 +633,12 @@ public class AWTRobotUtil { */ public static boolean waitForRealized(Object obj, boolean realized) throws InterruptedException { int wait; - if(obj instanceof com.jogamp.newt.Window) { + if(obj instanceof com.jogamp.newt.Screen) { + com.jogamp.newt.Screen screen = (com.jogamp.newt.Screen) obj; + for (wait=0; wait<POLL_DIVIDER && realized != screen.isNativeValid(); wait++) { + Thread.sleep(TIME_SLICE); + } + } else if(obj instanceof com.jogamp.newt.Window) { com.jogamp.newt.Window win = (com.jogamp.newt.Window) obj; for (wait=0; wait<POLL_DIVIDER && realized != win.isNativeValid(); wait++) { Thread.sleep(TIME_SLICE); |