diff options
Diffstat (limited to 'src/test/com')
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java | 30 | ||||
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java | 153 |
2 files changed, 135 insertions, 48 deletions
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 3d7db0465..ff5de7cb0 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 @@ -61,6 +61,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL private GLUniformData pmvMatrixUniform = null; private GLUniformData colorU = null; private float view_rotx = 20.0f, view_roty = 30.0f; + private boolean flipVerticalInGLOrientation = false; private final float view_rotz = 0.0f; private float panX = 0.0f, panY = 0.0f, panZ=0.0f; @@ -119,6 +120,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL public void setDoRotation(boolean rotate) { this.doRotate = rotate; } public void setClearBuffers(boolean v) { clearBuffers = v; } public void setVerbose(boolean v) { verbose = v; } + public void setFlipVerticalInGLOrientation(boolean v) { flipVerticalInGLOrientation=v; } public void setPMVUseBackingArray(boolean pmvUseBackingArray) { this.pmvUseBackingArray = pmvUseBackingArray; @@ -186,10 +188,10 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL drawable.setGLEventListenerInitState(this, false); return; } - System.err.println(Thread.currentThread()+" GearsES2.init "+sid()+": tileRendererInUse "+tileRendererInUse); final GL2ES2 gl = drawable.getGL().getGL2ES2(); if(verbose) { + System.err.println(Thread.currentThread()+" GearsES2.init "+sid()+": tileRendererInUse "+tileRendererInUse); System.err.println("GearsES2 init "+sid()+" on "+Thread.currentThread()); System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities()); System.err.println("INIT GL IS: " + gl.getClass().getName()); @@ -307,7 +309,9 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL gl.glFinish(); // make sure .. for shared context (impacts OSX 10.9) isInit = true; - System.err.println(Thread.currentThread()+" GearsES2.init "+sid()+" FIN "+this); + if(verbose) { + System.err.println(Thread.currentThread()+" GearsES2.init "+sid()+" FIN "+this); + } } public final boolean isInit() { return isInit; } @@ -343,7 +347,9 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL void reshapeImpl(GL2ES2 gl, int tileX, int tileY, int tileWidth, int tileHeight, int imageWidth, int imageHeight) { final boolean msaa = gl.getContext().getGLDrawable().getChosenGLCapabilities().getSampleBuffers(); - System.err.println(Thread.currentThread()+" GearsES2.reshape "+sid()+" "+tileX+"/"+tileY+" "+tileWidth+"x"+tileHeight+" of "+imageWidth+"x"+imageHeight+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(gl.getContext().getGLDrawable().getHandle())+", msaa "+msaa+", tileRendererInUse "+tileRendererInUse); + if(verbose) { + System.err.println(Thread.currentThread()+" GearsES2.reshape "+sid()+" "+tileX+"/"+tileY+" "+tileWidth+"x"+tileHeight+" of "+imageWidth+"x"+imageHeight+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(gl.getContext().getGLDrawable().getHandle())+", msaa "+msaa+", tileRendererInUse "+tileRendererInUse); + } if( !gl.hasGLSL() ) { return; @@ -388,6 +394,9 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL pmvMatrix.glMatrixMode(PMVMatrix.GL_MODELVIEW); pmvMatrix.glLoadIdentity(); pmvMatrix.glTranslatef(0.0f, 0.0f, -40.0f); + if(flipVerticalInGLOrientation && gl.getContext().getGLDrawable().isGLOriented() ) { + pmvMatrix.glRotatef(180f, 1.0f, 0.0f, 0.0f); + } st.uniform(gl, pmvMatrixUniform); st.useProgram(gl, false); @@ -399,7 +408,9 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL public void dispose(GLAutoDrawable drawable) { if( !isInit ) { return; } isInit = false; - System.err.println(Thread.currentThread()+" GearsES2.dispose "+sid()+": tileRendererInUse "+tileRendererInUse); + if(verbose) { + System.err.println(Thread.currentThread()+" GearsES2.dispose "+sid()+": tileRendererInUse "+tileRendererInUse); + } final Object upstreamWidget = drawable.getUpstreamWidget(); if (upstreamWidget instanceof Window) { final Window window = (Window) upstreamWidget; @@ -425,7 +436,9 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL st.destroy(gl); st = null; - System.err.println(Thread.currentThread()+" GearsES2.dispose "+sid()+" FIN"); + if(verbose) { + System.err.println(Thread.currentThread()+" GearsES2.dispose "+sid()+" FIN"); + } } @Override @@ -482,9 +495,10 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL st.useProgram(gl, true); pmvMatrix.glPushMatrix(); pmvMatrix.glTranslatef(panX, panY, panZ); - pmvMatrix.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f); - pmvMatrix.glRotatef(view_roty, 0.0f, 1.0f, 0.0f); - pmvMatrix.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f); + final float flipVF = ( flipVerticalInGLOrientation && drawable.isGLOriented() ) ? -1f : 1f; + pmvMatrix.glRotatef(flipVF*view_rotx, 1.0f, 0.0f, 0.0f); + pmvMatrix.glRotatef(flipVF*view_roty, 0.0f, 1.0f, 0.0f); + pmvMatrix.glRotatef(flipVF*view_rotz, 0.0f, 0.0f, 1.0f); gear1.draw(gl, -3.0f, -2.0f, 1f * angle - 0f); gear2.draw(gl, 3.1f, -2.0f, -2f * angle - 9.0f); 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 18ec289d8..3133a449d 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 @@ -69,10 +69,16 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase { GLProfile.initSingleton(); } - public void test(final GLCapabilitiesImmutable caps, final boolean useGears, final int width, final int height, - final int frameCount, final boolean initMT, final boolean useGLJPanel, final boolean useGLCanvas, - final boolean useAnim, final boolean overlap) { - final GLAnimatorControl animator = useAnim ? new Animator() : null; + 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 GLAnimatorControl animator; + if( useAnim ) { + animator = new Animator(); + animator.start(); + } else { + animator = null; + } final int eWidth, eHeight; { final int cols = (int)Math.round(Math.sqrt(frameCount)); @@ -81,7 +87,7 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase { eHeight = height/rows-32; } 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 long[] t = new long[10]; if( wait ) { @@ -106,9 +112,10 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase { } final JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); + panel.setDoubleBuffered(useSwingDoubleBuffer); // panel.setBounds(0, 0, width, height); final Dimension eSize = new Dimension(eWidth, eHeight); - final GLAutoDrawable glad = useGLJPanel ? createGLJPanel(initMT, caps, useGears, animator, eSize) : ( useGLCanvas ? createGLCanvas(caps, useGears, animator, eSize) : null ); + 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() { @Override @@ -218,19 +225,26 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase { canvas.setSize(size); canvas.setPreferredSize(size); if( useGears ) { - canvas.addGLEventListener(new GearsES2()); + final GearsES2 g = new GearsES2(0); + g.setVerbose(false); + canvas.addGLEventListener(g); } if( null != anim ) { anim.add(canvas); } return canvas; } - private GLAutoDrawable createGLJPanel(boolean initMT, GLCapabilitiesImmutable caps, boolean useGears, GLAnimatorControl anim, Dimension size) { + private GLAutoDrawable createGLJPanel(boolean initMT, boolean useSwingDoubleBuffer, GLCapabilitiesImmutable caps, boolean useGears, boolean skipGLOrientationVerticalFlip, GLAnimatorControl anim, Dimension size) { GLJPanel canvas = new GLJPanel(caps); canvas.setSize(size); canvas.setPreferredSize(size); + canvas.setDoubleBuffered(useSwingDoubleBuffer); + canvas.setSkipGLOrientationVerticalFlip(skipGLOrientationVerticalFlip); if( useGears ) { - canvas.addGLEventListener(new GearsES2()); + final GearsES2 g = new GearsES2(0); + g.setVerbose(false); + g.setFlipVerticalInGLOrientation(skipGLOrientationVerticalFlip); + canvas.addGLEventListener(g); } if( null != anim ) { anim.add(canvas); @@ -243,66 +257,116 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase { static GLCapabilitiesImmutable caps = null; + // + // NOP + // + @Test public void test00NopNoGLDefGrid() throws InterruptedException, InvocationTargetException { - test(null, false /*useGears*/, width, height , frameCount, false /* initMT */, false /* useGLJPanel */, - false /* useGLCanvas */, false /*useAnim*/, false /* overlap */); + test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */, + false /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */); } @Test public void test01NopGLCanvasDefGrid() throws InterruptedException, InvocationTargetException { - test(new GLCapabilities(null), false /*useGears*/, width, height , frameCount, false /* initMT */, false /* useGLJPanel */, - true /* useGLCanvas */, false /*useAnim*/, false /* overlap */); + test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */, + false /* useGLJPanel */, false /*useSwingDoubleBuffer*/, true /* useGLCanvas */, 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 */); + } + + @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 */); + } + + @Test + public void test04GearsGLJPanelDefGridMTManualFlip() 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 */); + } + + // + // Gears + // + + @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 */); + } + + @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 */); } @Test - public void test02NopGLJPanelDefGridSingle() throws InterruptedException, InvocationTargetException { - test(new GLCapabilities(null), false /*useGears*/, width, height , frameCount, false /* initMT */, true /* useGLJPanel */, - false /* useGLCanvas */, false /*useAnim*/, false /* overlap */); + 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 */); } @Test - public void test03NopGLJPanelDefGridMT() throws InterruptedException, InvocationTargetException { - test(new GLCapabilities(null), false /*useGears*/, width, height , frameCount, true /* initMT */, true /* useGLJPanel */, - false /* useGLCanvas */, false /*useAnim*/, false /* overlap */); + 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 */); } + + // + // Overlap + NOP + // + + @Test - public void test10NopNoGLDefOverlap() throws InterruptedException, InvocationTargetException { - test(null, false /*useGears*/, width, height , frameCount, false /* initMT */, false /* useGLJPanel */, - false /* useGLCanvas */, false /*useAnim*/, true /* overlap */); + 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 */); } @Test - public void test11NopGLCanvasDefOverlap() throws InterruptedException, InvocationTargetException { - test(new GLCapabilities(null), false /*useGears*/, width, height , frameCount, false /* initMT */, false /* useGLJPanel */, - true /* useGLCanvas */, false /*useAnim*/, true /* overlap */); + 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 */); } @Test - public void test12NopGLJPanelDefOverlapSingle() throws InterruptedException, InvocationTargetException { - test(new GLCapabilities(null), false /*useGears*/, width, height , frameCount, false /* initMT */, true /* useGLJPanel */, - false /* useGLCanvas */, false /*useAnim*/, true /* overlap */); + 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 */); } @Test - public void test13NopGLJPanelDefOverlapMT() throws InterruptedException, InvocationTargetException { - test(new GLCapabilities(null), false /*useGears*/, width, height , frameCount, true /* initMT */, true /* useGLJPanel */, - false /* useGLCanvas */, false /*useAnim*/, true /* overlap */); + 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 */); } // @Test - public void test04NopGLJPanelDefOverlapSingle() throws InterruptedException, InvocationTargetException { - test(new GLCapabilities(null), false /*useGears*/, width, height , frameCount, false /* initMT */, true /* useGLJPanel */, - false /* useGLCanvas */, false /*useAnim*/, true /* overlap */); + 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 */); } // @Test - public void test05NopGLJPanelBitmapGridSingle() throws InterruptedException, InvocationTargetException { + public void testXXNopGLJPanelBitmapGridSingle() throws InterruptedException, InvocationTargetException { GLCapabilities caps = new GLCapabilities(null); caps.setBitmap(true); - test(caps, false /*useGears*/, width, height , frameCount, false /* initMT */, true /* useGLJPanel */, - false /* useGLCanvas */, false /*useAnim*/, false); + test(caps, false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */, + true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false); } static long duration = 0; // ms @@ -312,9 +376,11 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase { volatile int initCount = 0; public static void main(String[] args) { - boolean useGLJPanel = true, initMT = false, useGLCanvas = false, useGears = false, manual=false; - boolean overlap = false; + boolean manual=false; boolean waitMain = false; + boolean useGLJPanel = true, initMT = false, useGLCanvas = false, useSwingDoubleBuffer=false; + boolean useGears = false, skipGLOrientationVerticalFlip=false, useAnim = false; + boolean overlap = false; for(int i=0; i<args.length; i++) { if(args[i].equals("-time")) { @@ -333,12 +399,18 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase { useGLJPanel = false; useGLCanvas = true; 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")) { + useAnim = true; + } else if(args[i].equals("-userVertFlip")) { + skipGLOrientationVerticalFlip = true; } else if(args[i].equals("-overlap")) { overlap = true; } else if(args[i].equals("-wait")) { @@ -357,7 +429,8 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase { if( manual ) { GLProfile.initSingleton(); TestPerf001GLJPanelInit02AWT demo = new TestPerf001GLJPanelInit02AWT(); - demo.test(null, useGears, width, height, frameCount, initMT, useGLJPanel, useGLCanvas, false /*useAnim*/, overlap /* overlap */); + demo.test(null, useGears, skipGLOrientationVerticalFlip, width, height, frameCount, + initMT, useGLJPanel, useSwingDoubleBuffer, useGLCanvas, useAnim, overlap); } else { org.junit.runner.JUnitCore.main(TestPerf001GLJPanelInit02AWT.class.getName()); } |