diff options
author | Sven Gothel <[email protected]> | 2014-02-18 19:12:46 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-02-18 19:12:46 +0100 |
commit | d46d9ad8f998a7128d9f023294d5f489673d6d8a (patch) | |
tree | 05b9227fc131a4ec05f368308233b44553da3917 /src/test/com/jogamp/opengl | |
parent | e685f79ec7071e266a1bd3d3ce3e742397b5372e (diff) |
Bug 975 - GLJPanel's OffscreenDrawable shall not double swap - Refine unit test for visual validation of 'no frame lag'
To validate whether a 'display' command w/o animator results to the desired frame
we introduce a 'userCounter' in TextRendererGLEL.
The latter gets increased and maybe visually validated by a key-press -> display.
Results: In all modes, MSAA or !MSAA, or flip - the result is valid.
Tested on windows and linux.
Diffstat (limited to 'src/test/com/jogamp/opengl')
3 files changed, 43 insertions, 11 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/GLReadBuffer00Base.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/GLReadBuffer00Base.java index 06fefe059..43f8b89bd 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/GLReadBuffer00Base.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/GLReadBuffer00Base.java @@ -51,7 +51,8 @@ import com.jogamp.opengl.test.junit.util.UITestCase; public abstract class GLReadBuffer00Base extends UITestCase { public static class TextRendererGLEL extends TextRendererGLELBase { - int frameNo = 0; + public int frameNo = 0; + public int userCounter = 0; public TextRendererGLEL() { // FIXME: Graph TextRenderer does not AA well w/o MSAA and FBO @@ -68,13 +69,14 @@ public abstract class GLReadBuffer00Base extends UITestCase { @Override public void display(GLAutoDrawable drawable) { - frameNo++; - final String text = String.format("Frame %04d: %04dx%04d", frameNo, drawable.getWidth(), drawable.getHeight()); + final String text = String.format("Frame %04d (%03d): %04dx%04d", frameNo, userCounter, drawable.getWidth(), drawable.getHeight()); + System.err.println("TextRendererGLEL.display: "+text); if( null != renderer ) { renderString(drawable, text, 0 /* col */, 0 /* row */, 0, 0, -1); } else { System.err.println(text); } + frameNo++; } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLJPanelAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLJPanelAWT.java index ee9eea725..58ca24453 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLJPanelAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLJPanelAWT.java @@ -73,7 +73,8 @@ public class TestGLReadBuffer01GLJPanelAWT extends GLReadBuffer00Base { final JFrame frame = new JFrame(); final Dimension d = new Dimension(320, 240); final GLJPanel glad = createGLJPanel(skipGLOrientationVerticalFlip, useSwingDoubleBuffer, caps, d); - final SnapshotGLELAWT snapshotGLEL = new SnapshotGLELAWT(awtGLReadBufferUtil, skipGLOrientationVerticalFlip); + final TextRendererGLEL textRendererGLEL = new TextRendererGLEL(); + final SnapshotGLELAWT snapshotGLEL = new SnapshotGLELAWT(textRendererGLEL, awtGLReadBufferUtil, skipGLOrientationVerticalFlip); try { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { @@ -87,7 +88,6 @@ public class TestGLReadBuffer01GLJPanelAWT extends GLReadBuffer00Base { gears.setFlipVerticalInGLOrientation(skipGLOrientationVerticalFlip); gears.setVerbose(false); glad.addGLEventListener(gears); - final TextRendererGLEL textRendererGLEL = new TextRendererGLEL(); textRendererGLEL.setFlipVerticalInGLOrientation(skipGLOrientationVerticalFlip); glad.addGLEventListener(textRendererGLEL); glad.addGLEventListener(snapshotGLEL); @@ -104,6 +104,15 @@ public class TestGLReadBuffer01GLJPanelAWT extends GLReadBuffer00Base { final Dimension size1 = new Dimension(size0.width+100, size0.height+100); final Dimension size2 = new Dimension(size0.width-100, size0.height-100); try { + for(int i=0; i<3; i++) { + final String str = "Frame# "+textRendererGLEL.frameNo+", user #"+(i+1); + System.err.println(str); + if( keyFrame ) { + waitForKey(str); + } + textRendererGLEL.userCounter = i + 1; + glad.display(); + } try { Thread.sleep(duration); } catch (InterruptedException e) { } javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { @@ -153,13 +162,15 @@ public class TestGLReadBuffer01GLJPanelAWT extends GLReadBuffer00Base { } private class SnapshotGLELAWT implements GLEventListener { + final TextRendererGLEL textRendererGLEL; final AWTGLReadBufferUtil glReadBufferUtil; final boolean skipGLOrientationVerticalFlip; boolean defAutoSwapMode; boolean swapBuffersBeforeRead; int i; - SnapshotGLELAWT(final AWTGLReadBufferUtil glReadBufferUtil, final boolean skipGLOrientationVerticalFlip) { + SnapshotGLELAWT(final TextRendererGLEL textRendererGLEL, final AWTGLReadBufferUtil glReadBufferUtil, final boolean skipGLOrientationVerticalFlip) { + this.textRendererGLEL = textRendererGLEL; this.glReadBufferUtil = glReadBufferUtil; this.skipGLOrientationVerticalFlip = skipGLOrientationVerticalFlip; this.defAutoSwapMode = true; @@ -185,7 +196,8 @@ public class TestGLReadBuffer01GLJPanelAWT extends GLReadBuffer00Base { } public void snapshot(int sn, GL gl, String fileSuffix, String destPath) { final GLDrawable drawable = gl.getContext().getGLReadDrawable(); - final String filenameAWT = getSnapshotFilename(sn, "awt", + final String postSNDetail = String.format("awt-usr%03d", textRendererGLEL.userCounter); + final String filenameAWT = getSnapshotFilename(sn, postSNDetail, drawable.getChosenGLCapabilities(), drawable.getWidth(), drawable.getHeight(), glReadBufferUtil.hasAlpha(), fileSuffix, destPath); if( swapBuffersBeforeRead ) { @@ -217,12 +229,15 @@ public class TestGLReadBuffer01GLJPanelAWT extends GLReadBuffer00Base { }; static GLCapabilitiesImmutable caps = null; + static boolean keyFrame = false; public static void main(String[] args) { for(int i=0; i<args.length; i++) { if(args[i].equals("-time")) { i++; duration = MiscUtils.atol(args[i], duration); + } else if(args[i].equals("-keyFrame")) { + keyFrame = true; } } org.junit.runner.JUnitCore.main(TestGLReadBuffer01GLJPanelAWT.class.getName()); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLWindowNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLWindowNEWT.java index dde4c32fa..af5ff2a1a 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLWindowNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLWindowNEWT.java @@ -67,14 +67,14 @@ public class TestGLReadBuffer01GLWindowNEWT extends GLReadBuffer00Base { } final GLReadBufferUtil glReadBufferUtil = new GLReadBufferUtil(false, false); final GLWindow glad= GLWindow.create(caps); - final SnapshotGLEL snapshotGLEL = new SnapshotGLEL(glReadBufferUtil); + final TextRendererGLEL textRendererGLEL = new TextRendererGLEL(); + final SnapshotGLEL snapshotGLEL = new SnapshotGLEL(textRendererGLEL, glReadBufferUtil); try { glad.setPosition(64, 64); glad.setSize(320, 240); final GearsES2 gears = new GearsES2(1); gears.setVerbose(false); glad.addGLEventListener(gears); - final TextRendererGLEL textRendererGLEL = new TextRendererGLEL(); textRendererGLEL.setFlipVerticalInGLOrientation(skipGLOrientationVerticalFlip); glad.addGLEventListener(textRendererGLEL); glad.addGLEventListener(snapshotGLEL); @@ -87,6 +87,15 @@ public class TestGLReadBuffer01GLWindowNEWT extends GLReadBuffer00Base { final DimensionImmutable size1 = new Dimension(size0.getWidth()+100, size0.getHeight()+100); final DimensionImmutable size2 = new Dimension(size0.getWidth()-100, size0.getHeight()-100); try { + for(int i=0; i<3; i++) { + final String str = "Frame# "+textRendererGLEL.frameNo+", user #"+(i+1); + System.err.println(str); + if( keyFrame ) { + waitForKey(str); + } + textRendererGLEL.userCounter = i + 1; + glad.display(); + } try { Thread.sleep(duration); } catch (InterruptedException e) { } glad.setSize(size1.getWidth(), size1.getHeight()); try { Thread.sleep(duration); } catch (InterruptedException e) { } @@ -107,12 +116,14 @@ public class TestGLReadBuffer01GLWindowNEWT extends GLReadBuffer00Base { } private class SnapshotGLEL implements GLEventListener { + final TextRendererGLEL textRendererGLEL; final GLReadBufferUtil glReadBufferUtil; boolean defAutoSwapMode; boolean swapBuffersBeforeRead; int i; - SnapshotGLEL(final GLReadBufferUtil glReadBufferUtil) { + SnapshotGLEL(final TextRendererGLEL textRendererGLEL, final GLReadBufferUtil glReadBufferUtil) { + this.textRendererGLEL = textRendererGLEL; this.glReadBufferUtil = glReadBufferUtil; this.defAutoSwapMode = true; this.swapBuffersBeforeRead = false; @@ -137,7 +148,8 @@ public class TestGLReadBuffer01GLWindowNEWT extends GLReadBuffer00Base { } public void snapshot(int sn, GLAutoDrawable drawable, String fileSuffix, String destPath) { final GL gl = drawable.getGL(); - final String filenameJGL = getSnapshotFilename(sn, "jgl", + final String postSNDetail = String.format("jgl-usr%03d", textRendererGLEL.userCounter); + final String filenameJGL = getSnapshotFilename(sn, postSNDetail, drawable.getChosenGLCapabilities(), drawable.getWidth(), drawable.getHeight(), glReadBufferUtil.hasAlpha(), fileSuffix, destPath); if( swapBuffersBeforeRead ) { @@ -158,12 +170,15 @@ public class TestGLReadBuffer01GLWindowNEWT extends GLReadBuffer00Base { }; static GLCapabilitiesImmutable caps = null; + static boolean keyFrame = false; public static void main(String[] args) { for(int i=0; i<args.length; i++) { if(args[i].equals("-time")) { i++; duration = MiscUtils.atol(args[i], duration); + } else if(args[i].equals("-keyFrame")) { + keyFrame = true; } } org.junit.runner.JUnitCore.main(TestGLReadBuffer01GLWindowNEWT.class.getName()); |