diff options
author | Sven Gothel <[email protected]> | 2011-04-23 06:20:45 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-04-23 06:20:45 +0200 |
commit | ea819ff768d507c37a981c1ab0bdc0cad32c6a87 (patch) | |
tree | 769f0b3c394fb93da235cd7abf6bdd7f642be42a | |
parent | f5e0656fe20925d8c921d1b4cc70acd02dfbf9fd (diff) |
New FPSCounter, impl. by GLWindow and GLAnimatorControl (fps perf related API change)
- Don't fetch System.currentTimeMillis() by default and for every frame (performance)
- Default behavior is FPSCounter switched off
- Enable by frame interval, ie measure each 60 frames.
- FPSCounterImpl is default impl. used by impl. FPSCounter class (reduce code/redundancy)
- Might be promoted to GLAutoDrawable ?!
43 files changed, 584 insertions, 374 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/Animator.java b/src/jogl/classes/com/jogamp/opengl/util/Animator.java index 4fbd0e478..e7fbc4d58 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/Animator.java +++ b/src/jogl/classes/com/jogamp/opengl/util/Animator.java @@ -125,7 +125,7 @@ public class Animator extends AnimatorBase { class MainLoop implements Runnable { public String toString() { - return "[started "+isStartedImpl()+", animating "+isAnimatingImpl()+", paused "+isPausedImpl()+", frames "+getTotalFrames()+", drawable "+drawables.size()+"]"; + return "[started "+isStartedImpl()+", animating "+isAnimatingImpl()+", paused "+isPausedImpl()+", drawable "+drawables.size()+"]"; } public void run() { @@ -134,11 +134,7 @@ public class Animator extends AnimatorBase { if(DEBUG) { System.err.println("Animator start:" + Thread.currentThread() + ": " + toString()); } - - startTime = System.currentTimeMillis(); - curTime = startTime; - totalFrames = 0; - + fpsCounter.resetFPSCounter(); animThread = Thread.currentThread(); setIsAnimatingSynced(false); // barrier Animator.this.notifyAll(); @@ -161,9 +157,7 @@ public class Animator extends AnimatorBase { if (wasPaused) { // resume from pause -> reset counter - startTime = System.currentTimeMillis(); - curTime = startTime; - totalFrames = 0; + fpsCounter.resetFPSCounter(); if (DEBUG) { System.err.println("Animator resume:" + Thread.currentThread() + ": " + toString()); } @@ -269,7 +263,7 @@ public class Animator extends AnimatorBase { if (runnable == null) { runnable = new MainLoop(); } - resetCounter(); + fpsCounter.resetFPSCounter(); String threadName = Thread.currentThread().getName()+"-"+baseName; Thread thread; if(null==threadGroup) { diff --git a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java index 01c2ea664..a6ba74665 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java +++ b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java @@ -30,7 +30,12 @@ package com.jogamp.opengl.util; import com.jogamp.common.util.locks.RecursiveLock; import jogamp.opengl.Debug; +import jogamp.opengl.FPSCounterImpl; + +import java.io.PrintStream; import java.util.ArrayList; + +import javax.media.opengl.FPSCounter; import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLProfile; @@ -61,9 +66,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { protected Thread animThread; protected boolean ignoreExceptions; protected boolean printExceptions; - protected long startTime; - protected long curTime; - protected int totalFrames; + protected FPSCounterImpl fpsCounter = new FPSCounterImpl(); protected RecursiveLock stateSync = new RecursiveLock(); /** Creates a new, empty Animator. */ @@ -83,7 +86,6 @@ public abstract class AnimatorBase implements GLAnimatorControl { baseName = baseName.concat("-"+animatorCount); drawablesEmpty = true; } - resetCounter(); } protected abstract String getBaseName(String prefix); @@ -138,25 +140,48 @@ public abstract class AnimatorBase implements GLAnimatorControl { lightweight widgets are continually being redrawn. */ protected void display() { impl.display(drawables, ignoreExceptions, printExceptions); - curTime = System.currentTimeMillis(); - totalFrames++; + fpsCounter.tickFPS(); + } + + public final void setUpdateFPSFrames(int frames, PrintStream out) { + fpsCounter.setUpdateFPSFrames(frames, out); + } + + public final void resetFPSCounter() { + fpsCounter.resetFPSCounter(); } - public long getCurrentTime() { - return curTime; + public final int getUpdateFPSFrames() { + return fpsCounter.getUpdateFPSFrames(); + } + + public final long getFPSStartTime() { + return fpsCounter.getFPSStartTime(); } - public long getDuration() { - return curTime - startTime; + public final long getLastFPSUpdateTime() { + return fpsCounter.getLastFPSUpdateTime(); } - public long getStartTime() { - return startTime; + public final long getLastFPSPeriod() { + return fpsCounter.getLastFPSPeriod(); + } + + public final float getLastFPS() { + return fpsCounter.getLastFPS(); + } + + public final int getTotalFPSFrames() { + return fpsCounter.getTotalFPSFrames(); } - public int getTotalFrames() { - return totalFrames; + public final long getTotalFPSDuration() { + return fpsCounter.getTotalFPSDuration(); } + + public final float getTotalFPS() { + return fpsCounter.getTotalFPS(); + } public final Thread getThread() { stateSync.lock(); @@ -167,12 +192,6 @@ public abstract class AnimatorBase implements GLAnimatorControl { } } - public synchronized void resetCounter() { - startTime = System.currentTimeMillis(); // overwrite startTime to real init one - curTime = startTime; - totalFrames = 0; - } - /** Sets a flag causing this Animator to ignore exceptions produced while redrawing the drawables. By default this flag is set to false, causing any exception thrown to halt the Animator. */ @@ -189,6 +208,6 @@ public abstract class AnimatorBase implements GLAnimatorControl { } public String toString() { - return getClass().getName()+"[started "+isStarted()+", animating "+isAnimating()+", paused "+isPaused()+", frames "+getTotalFrames()+", drawable "+drawables.size()+"]"; + return getClass().getName()+"[started "+isStarted()+", animating "+isAnimating()+", paused "+isPaused()+", drawable "+drawables.size()+"]"; } } diff --git a/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java b/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java index f59351ad8..f7fc58160 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java +++ b/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java @@ -130,7 +130,7 @@ public class FPSAnimator extends AnimatorBase { } }; - resetCounter(); + fpsCounter.resetFPSCounter(); shouldRun = true; if (scheduleAtFixedRate) { diff --git a/src/jogl/classes/javax/media/opengl/FPSCounter.java b/src/jogl/classes/javax/media/opengl/FPSCounter.java new file mode 100644 index 000000000..aa42ac9e0 --- /dev/null +++ b/src/jogl/classes/javax/media/opengl/FPSCounter.java @@ -0,0 +1,117 @@ +/** + * Copyright 2011 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package javax.media.opengl; + +import java.io.PrintStream; + +/** + * FPSCounter feature.<br> + * An implementation initially has the FPSCounter feature disabled.<br> + * Use {@link #setUpdateFPSFrames(int, PrintStream)} to enable and disable the FPSCounter feature. + */ +public interface FPSCounter { + public static final int DEFAULT_FRAMES_PER_INTERVAL = 60; + + /** + * @param frames Update interval in frames.<br> At every rendered <i>frames</i> interval the currentTime and fps values are updated. + * If the <i>frames</i> interval is <= 0, no update will be issued, ie the FPSCounter feature is turned off. You may choose {@link #DEFAULT_FRAMES_PER_INTERVAL}. + * @param out optional print stream where the fps values gets printed if not null at every <i>frames</i> interval + */ + void setUpdateFPSFrames(int frames, PrintStream out); + + /** + * Reset all performance counter (startTime, currentTime, frame number) + */ + void resetFPSCounter(); + + /** + * @return update interval in frames + * + * @see #setUpdateFPSFrames(int, PrintStream) + */ + int getUpdateFPSFrames(); + + /** + * Returns the time of the first display call in milliseconds after enabling this feature via {@link #setUpdateFPSFrames(int, PrintStream)}.<br> + * This value is reset via {@link #resetFPSCounter()}. + * + * @see #setUpdateFPSFrames(int, PrintStream) + * @see #resetFPSCounter() + */ + long getFPSStartTime(); + + /** + * Returns the time of the last update interval in milliseconds, if this feature is enabled via {@link #setUpdateFPSFrames(int, PrintStream)}.<br> + * This value is reset via {@link #resetFPSCounter()}. + * + * @see #setUpdateFPSFrames(int, PrintStream) + * @see #resetFPSCounter() + */ + long getLastFPSUpdateTime(); + + /** + * @return Duration of the last update interval in milliseconds. + * + * @see #setUpdateFPSFrames(int, PrintStream) + * @see #resetFPSCounter() + */ + long getLastFPSPeriod(); + + /** + * @return Last update interval's frames per seconds, {@link #getUpdateFPSFrames()} / {@link #getLastFPSPeriod()} + * + * @see #setUpdateFPSFrames(int, PrintStream) + * @see #resetFPSCounter() + */ + float getLastFPS(); + + /** + * @return Number of frame rendered since {@link #getFPSStartTime()} up to {@link #getLastFPSUpdateTime()} + * + * @see #setUpdateFPSFrames(int, PrintStream) + * @see #resetFPSCounter() + */ + int getTotalFPSFrames(); + + /** + * @return Total duration in milliseconds, {@link #getLastFPSUpdateTime()} - {@link #getFPSStartTime()} + * + * @see #setUpdateFPSFrames(int, PrintStream) + * @see #resetFPSCounter() + */ + long getTotalFPSDuration(); + + + /** + * @return Total frames per seconds, {@link #getTotalFPSFrames()} / {@link #getTotalFPSDuration()} + * + * @see #setUpdateFPSFrames(int, PrintStream) + * @see #resetFPSCounter() + */ + float getTotalFPS(); +} diff --git a/src/jogl/classes/javax/media/opengl/GLAnimatorControl.java b/src/jogl/classes/javax/media/opengl/GLAnimatorControl.java index 2c8c7cca3..83e9e22c4 100644 --- a/src/jogl/classes/javax/media/opengl/GLAnimatorControl.java +++ b/src/jogl/classes/javax/media/opengl/GLAnimatorControl.java @@ -32,47 +32,7 @@ package javax.media.opengl; * An animator control interface, * which implementation may drive a {@link javax.media.opengl.GLAutoDrawable} animation. */ -public interface GLAnimatorControl { - - /** - * @return Time of the first display call in milliseconds. - * This value is reset if started or resumed. - * - * @see #start() - * @see #resume() - */ - long getStartTime(); - - /** - * @return Time of the last display call in milliseconds. - * This value is reset if started or resumed. - * - * @see #start() - * @see #resume() - */ - long getCurrentTime(); - - /** - * @return Duration <code>getCurrentTime() - getStartTime()</code>. - * - * @see #getStartTime() - * @see #getCurrentTime() - */ - long getDuration(); - - - /** - * @return Number of frame cycles displayed - * since the first display call, ie <code>getStartTime()</code>. - * This value is reset if started or resumed. - * - * @see #start() - * @see #resume() - */ - int getTotalFrames(); - - /** Reset all performance counter (startTime, currentTime, frame number) */ - public void resetCounter(); +public interface GLAnimatorControl extends FPSCounter { /** * Indicates whether this animator is running, ie. has been started and not stopped. diff --git a/src/jogl/classes/jogamp/opengl/FPSCounterImpl.java b/src/jogl/classes/jogamp/opengl/FPSCounterImpl.java new file mode 100644 index 000000000..96d62fbb3 --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/FPSCounterImpl.java @@ -0,0 +1,137 @@ +/** + * Copyright 2011 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package jogamp.opengl; + +import java.io.PrintStream; +import javax.media.opengl.FPSCounter; + +/** + * Default implementation of FPSCounter to be used for FPSCounter implementing renderer. + */ +public class FPSCounterImpl implements FPSCounter { + private int fpsUpdateFramesInterval; + private PrintStream fpsOutputStream ; + private long fpsStartTime, fpsLastUpdateTime, fpsLastPeriod, fpsTotalDuration; + private int fpsTotalFrames; + private float fpsLast, fpsTotal; + + /** Creates a disabled instance */ + public FPSCounterImpl() { + setUpdateFPSFrames(0, null); + } + + /** + * Increases total frame count and updates values if feature is enabled and + * update interval is reached.<br> + * + * Shall be called by actual FPSCounter implementing renderer, after display a new frame. + * + */ + public final synchronized void tickFPS() { + fpsTotalFrames++; + if(fpsUpdateFramesInterval>0 && fpsTotalFrames%fpsUpdateFramesInterval == 0) { + final long now = System.currentTimeMillis(); + fpsLastPeriod = now - fpsLastUpdateTime; + fpsLastPeriod = Math.max(fpsLastPeriod, 1); // div 0 + fpsLast = ( (float)fpsUpdateFramesInterval * 1000f ) / ( (float) fpsLastPeriod ) ; + + fpsTotalDuration = now - fpsStartTime; + fpsTotalDuration = Math.max(fpsTotalDuration, 1); // div 0 + fpsTotal= ( (float)fpsTotalFrames * 1000f ) / ( (float) fpsTotalDuration ) ; + + if(null != fpsOutputStream) { + fpsOutputStream.println(toString()); + } + + fpsLastUpdateTime = now; + } + } + + public StringBuilder toString(StringBuilder sb) { + if(null==sb) { + sb = new StringBuilder(); + } + String fpsLastS = String.valueOf(fpsLast); + fpsLastS = fpsLastS.substring(0, fpsLastS.indexOf('.') + 2); + String fpsTotalS = String.valueOf(fpsTotal); + fpsTotalS = fpsTotalS.substring(0, fpsTotalS.indexOf('.') + 2); + sb.append(fpsTotalDuration/1000 +" s: "+ fpsUpdateFramesInterval+" f / "+ fpsLastPeriod+" ms, " + fpsLastS+" fps, "+ fpsLastPeriod/fpsUpdateFramesInterval+" ms/f; "+ + "total: "+ fpsTotalFrames+" f, "+ fpsTotalS+ " fps, "+ fpsTotalDuration/fpsTotalFrames+" ms/f"); + return sb; + } + + public String toString() { + return toString(null).toString(); + } + + public final synchronized void setUpdateFPSFrames(int frames, PrintStream out) { + fpsUpdateFramesInterval = frames; + fpsOutputStream = out; + resetFPSCounter(); + } + + public final synchronized void resetFPSCounter() { + fpsStartTime = System.currentTimeMillis(); // overwrite startTime to real init one + fpsLastUpdateTime = fpsStartTime; + fpsLastPeriod = 0; + fpsTotalFrames = 0; + fpsLast = 0f; fpsTotal = 0f; + } + + public final synchronized int getUpdateFPSFrames() { + return fpsUpdateFramesInterval; + } + + public final synchronized long getFPSStartTime() { + return fpsStartTime; + } + + public final synchronized long getLastFPSUpdateTime() { + return fpsLastUpdateTime; + } + + public final synchronized long getLastFPSPeriod() { + return fpsLastPeriod; + } + + public final synchronized float getLastFPS() { + return fpsLast; + } + + public final synchronized int getTotalFPSFrames() { + return fpsTotalFrames; + } + + public final synchronized long getTotalFPSDuration() { + return fpsTotalDuration; + } + + public final synchronized float getTotalFPS() { + return fpsTotal; + } +} diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 48531fcf8..2dcb6345e 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -34,6 +34,7 @@ package com.jogamp.newt.opengl; +import java.io.PrintStream; import java.util.List; import com.jogamp.common.GlueGenVersion; @@ -48,6 +49,7 @@ import javax.media.nativewindow.util.Point; import javax.media.nativewindow.util.Insets; import javax.media.opengl.*; +import jogamp.opengl.FPSCounterImpl; import jogamp.opengl.GLDrawableHelper; import com.jogamp.opengl.JoglVersion; @@ -64,14 +66,14 @@ import com.jogamp.opengl.JoglVersion; * via {@link #invoke(boolean, javax.media.opengl.GLRunnable)} to the OpenGL command stream.<br> * <p> */ -public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer { +public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSCounter { private WindowImpl window; /** * Constructor. Do not call this directly -- use {@link #create()} instead. */ protected GLWindow(Window window) { - resetCounter(); + resetFPSCounter(); this.window = (WindowImpl) window; ((WindowImpl)this.window).setHandleDestroyNotify(false); window.addWindowListener(new WindowAdapter() { @@ -365,7 +367,7 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer { if(Window.DEBUG_WINDOW_EVENT || Window.DEBUG_IMPLEMENTATION) { System.err.println("GLWindow.resetCounter() "+Thread.currentThread()); } - GLWindow.this.resetCounter(); + GLWindow.this.resetFPSCounter(); } public synchronized void setVisibleActionPost(boolean visible, boolean nativeWindowCreated) { @@ -433,9 +435,7 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer { // To make reshape events be sent immediately before a display event private boolean sendReshape=false; private boolean sendDestroy=false; - private boolean perfLog = false; - private long startTime, curTime, lastCheck; - private int totalFrames, lastFrames; + private FPSCounterImpl fpsCounter = new FPSCounterImpl(); public GLDrawableFactory getFactory() { return factory; @@ -507,12 +507,6 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer { return null; } - public boolean getPerfLogEnabled() { return perfLog; } - - public void enablePerfLog(boolean v) { - perfLog = v; - } - public void invoke(boolean wait, GLRunnable glRunnable) { if(null!=helper) { helper.invoke(this, wait, glRunnable); @@ -577,7 +571,7 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer { public final void run() { // Lock: Locked Surface/Window by MakeCurrent/Release helper.init(GLWindow.this); - resetCounter(); + resetFPSCounter(); } } private InitAction initAction = new InitAction(); @@ -592,66 +586,50 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer { helper.display(GLWindow.this); - curTime = System.currentTimeMillis(); - totalFrames++; - - if(perfLog) { - long dt0, dt1; - lastFrames++; - dt0 = curTime-lastCheck; - if ( dt0 > 5000 ) { - dt1 = curTime-startTime; - System.err.println(dt0/1000 +"s: "+ lastFrames + "f, " + (lastFrames*1000)/dt0 + " fps, "+dt0/lastFrames+" ms/f; "+ - "total: "+ dt1/1000+"s, "+(totalFrames*1000)/dt1 + " fps, "+dt1/totalFrames+" ms/f"); - lastCheck=curTime; - lastFrames=0; - } - } + fpsCounter.tickFPS(); } } private DisplayAction displayAction = new DisplayAction(); - /** - * @return Time of the first display call in milliseconds. - * This value is reset if becoming visible again or reparenting. - */ - public final long getStartTime() { - return startTime; + public final void setUpdateFPSFrames(int frames, PrintStream out) { + fpsCounter.setUpdateFPSFrames(frames, out); + } + + public final void resetFPSCounter() { + fpsCounter.resetFPSCounter(); } - /** - * @return Time of the last display call in milliseconds. - * This value is reset if becoming visible again or reparenting. - */ - public final long getCurrentTime() { - return curTime; + public final int getUpdateFPSFrames() { + return fpsCounter.getUpdateFPSFrames(); + } + + public final long getFPSStartTime() { + return fpsCounter.getFPSStartTime(); } - /** - * @return Duration <code>getCurrentTime() - getStartTime()</code>. - * - * @see #getStartTime() - * @see #getCurrentTime() - */ - public final long getDuration() { - return getCurrentTime()-getStartTime(); + public final long getLastFPSUpdateTime() { + return fpsCounter.getLastFPSUpdateTime(); } - /** - * @return Number of frames displayed since the first display call, ie <code>getStartTime()</code>. - * This value is reset if becoming visible again or reparenting. - */ - public final int getTotalFrames() { - return totalFrames; + public final long getLastFPSPeriod() { + return fpsCounter.getLastFPSPeriod(); + } + + public final float getLastFPS() { + return fpsCounter.getLastFPS(); + } + + public final int getTotalFPSFrames() { + return fpsCounter.getTotalFPSFrames(); } - /** Reset all counter (startTime, currentTime, frame number) */ - public final synchronized void resetCounter() { - startTime = System.currentTimeMillis(); // overwrite startTime to real init one - curTime = startTime; - lastCheck = startTime; - totalFrames = 0; lastFrames = 0; + public final long getTotalFPSDuration() { + return fpsCounter.getTotalFPSDuration(); } + + public final float getTotalFPS() { + return fpsCounter.getTotalFPS(); + } private class SwapBuffersAction implements Runnable { public final void run() { diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo01.java index e2ed5f0d0..a7534dc01 100755 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo01.java @@ -28,6 +28,7 @@ package com.jogamp.opengl.test.junit.graph.demos; +import javax.media.opengl.FPSCounter; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLProfile; @@ -69,11 +70,12 @@ public class GPURegionNewtDemo01 { regionGLListener.attachInputListenerTo(window); window.addGLEventListener(regionGLListener); - window.enablePerfLog(true); + window.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); window.setVisible(true); //FPSAnimator animator = new FPSAnimator(60); Animator animator = new Animator(); + animator.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); animator.add(window); animator.start(); } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo02.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo02.java index 678a40c29..9353e0c06 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo02.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo02.java @@ -28,6 +28,7 @@ package com.jogamp.opengl.test.junit.graph.demos; +import javax.media.opengl.FPSCounter; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLProfile; @@ -69,11 +70,12 @@ public class GPURegionNewtDemo02 { regionGLListener.attachInputListenerTo(window); window.addGLEventListener(regionGLListener); - window.enablePerfLog(true); + window.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); window.setVisible(true); //FPSAnimator animator = new FPSAnimator(60); Animator animator = new Animator(); + animator.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); animator.add(window); animator.start(); } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java index 17e0a06d2..b173c1f06 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java @@ -31,6 +31,7 @@ import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; +import javax.media.opengl.FPSCounter; import javax.media.opengl.GL; import javax.media.opengl.GL2ES2; import javax.media.opengl.GLAnimatorControl; @@ -228,7 +229,10 @@ public abstract class GPURendererListenerBase01 implements GLEventListener { gl.setSwapInterval(i); final GLAnimatorControl a = drawable.getAnimator(); if( null != a ) { - a.resetCounter(); + a.resetFPSCounter(); + } + if(drawable instanceof FPSCounter) { + ((FPSCounter)drawable).resetFPSCounter(); } System.err.println("Swap Interval: "+i); } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo01.java index ff22a920e..219438146 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo01.java @@ -28,6 +28,7 @@ package com.jogamp.opengl.test.junit.graph.demos; +import javax.media.opengl.FPSCounter; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLProfile; @@ -61,11 +62,12 @@ public class GPUTextNewtDemo01 { GPUTextGLListener0A textGLListener = new GPUTextGLListener0A(rs, Region.SINGLE_PASS, 0, DEBUG, TRACE); textGLListener.attachInputListenerTo(window); window.addGLEventListener(textGLListener); - - window.enablePerfLog(true); + + window.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); window.setVisible(true); // FPSAnimator animator = new FPSAnimator(10); Animator animator = new Animator(); + animator.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); animator.add(window); animator.start(); } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo02.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo02.java index 067d45b73..cbe597508 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo02.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo02.java @@ -27,6 +27,7 @@ */ package com.jogamp.opengl.test.junit.graph.demos; +import javax.media.opengl.FPSCounter; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLProfile; @@ -72,11 +73,12 @@ public class GPUTextNewtDemo02 { // ((TextRenderer)textGLListener.getRenderer()).setCacheLimit(32); textGLListener.attachInputListenerTo(window); window.addGLEventListener(textGLListener); - - window.enablePerfLog(true); + + window.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); window.setVisible(true); // FPSAnimator animator = new FPSAnimator(60); - Animator animator = new Animator(); + Animator animator = new Animator(); + animator.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); animator.add(window); animator.start(); } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java index 7199226f9..119b38584 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java @@ -137,11 +137,11 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB final int width = drawable.getWidth(); final int height = drawable.getHeight(); final GLAnimatorControl animator = drawable.getAnimator(); - final boolean _drawFPS = drawFPS && null != animator && animator.getTotalFrames()>10; + final boolean _drawFPS = drawFPS && null != animator && animator.getTotalFPSFrames()>10; textRenderer.reshapeOrtho(null, width, height, 0.1f, 7000.0f); if(_drawFPS) { - final float fps = ( animator.getTotalFrames() * 1000.0f ) / (float) animator.getDuration() ; + final float fps = ( animator.getTotalFPSFrames() * 1000.0f ) / (float) animator.getTotalFPSDuration() ; final String fpsS = String.valueOf(fps); final int fpsSp = fpsS.indexOf('.'); textRenderer.resetModelview(null); diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java index f854d8195..c74d11f0d 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java @@ -294,7 +294,7 @@ public abstract class UIListenerBase01 implements GLEventListener { gl.setSwapInterval(i); final GLAnimatorControl a = drawable.getAnimator(); if( null != a ) { - a.resetCounter(); + a.resetFPSCounter(); } System.err.println("Swap Interval: "+i); } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UINewtDemo01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UINewtDemo01.java index e2aff5793..7d0ad83fa 100755 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UINewtDemo01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UINewtDemo01.java @@ -28,6 +28,7 @@ package com.jogamp.opengl.test.junit.graph.demos.ui; +import javax.media.opengl.FPSCounter; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLProfile; @@ -67,10 +68,11 @@ public class UINewtDemo01 { uiGLListener.attachInputListenerTo(window); window.addGLEventListener(uiGLListener); - window.enablePerfLog(true); + window.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); window.setVisible(true); Animator animator = new Animator(); + animator.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); animator.add(window); animator.start(); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java index bf4c493bc..10c4bce42 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java @@ -28,6 +28,7 @@ package com.jogamp.opengl.test.junit.jogl.acore; +import javax.media.opengl.FPSCounter; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLPbuffer; @@ -119,8 +120,9 @@ public class TestSharedContextListAWT extends UITestCase { GLCanvas glc2 = runTestGL(f2, animator, width, 0, true); GLCanvas glc3 = runTestGL(f3, animator, 0, height, false); + animator.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); animator.start(); - while(animator.isAnimating() && animator.getDuration()<duration) { + while(animator.isAnimating() && animator.getTotalFPSDuration()<duration) { Thread.sleep(100); } animator.stop(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT.java index f5c950646..cc565a7d0 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT.java @@ -29,6 +29,8 @@ package com.jogamp.opengl.test.junit.jogl.acore; import com.jogamp.newt.opengl.GLWindow; + +import javax.media.opengl.FPSCounter; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLPbuffer; @@ -106,8 +108,9 @@ public class TestSharedContextListNEWT extends UITestCase { GLWindow f1 = runTestGL(animator, 0, 0, true); GLWindow f2 = runTestGL(animator, width, 0, true); GLWindow f3 = runTestGL(animator, 0, height, false); + animator.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); animator.start(); - while(animator.isAnimating() && animator.getDuration()<duration) { + while(animator.isAnimating() && animator.getTotalFPSDuration()<duration) { Thread.sleep(100); } animator.stop(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/TestGearsAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/TestGearsAWT.java index d04ce3849..c8a89cb9b 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/TestGearsAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/TestGearsAWT.java @@ -29,6 +29,7 @@ package com.jogamp.opengl.test.junit.jogl.demos.gl2.gears; import javax.media.opengl.*; + import com.jogamp.opengl.util.Animator; import javax.media.opengl.awt.GLCanvas; import com.jogamp.newt.event.awt.AWTKeyAdapter; @@ -80,9 +81,10 @@ public class TestGearsAWT extends UITestCase { new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); frame.setVisible(true); + animator.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); animator.start(); - while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getDuration()<duration) { + while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) { Thread.sleep(100); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/TestGearsGLJPanelAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/TestGearsGLJPanelAWT.java index 40e2ae933..900a1d116 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/TestGearsGLJPanelAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/TestGearsGLJPanelAWT.java @@ -29,6 +29,7 @@ package com.jogamp.opengl.test.junit.jogl.demos.gl2.gears; import javax.media.opengl.*; + import com.jogamp.opengl.util.FPSAnimator; import javax.media.opengl.awt.GLJPanel; @@ -83,10 +84,11 @@ public class TestGearsGLJPanelAWT extends UITestCase { _frame.setVisible(true); } } ) ; + animator.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); animator.start(); Assert.assertEquals(true, animator.isAnimating()); - while(animator.isAnimating() && animator.getDuration()<duration) { + while(animator.isAnimating() && animator.getTotalFPSDuration()<duration) { Thread.sleep(100); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/TestGearsGLJPanelAWTBug450.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/TestGearsGLJPanelAWTBug450.java index c8e45ec46..07c9a89bb 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/TestGearsGLJPanelAWTBug450.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/TestGearsGLJPanelAWTBug450.java @@ -114,10 +114,11 @@ public class TestGearsGLJPanelAWTBug450 extends UITestCase { _frame.setVisible(true); } } ) ; + animator.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); animator.start(); Assert.assertEquals(true, animator.isAnimating()); - while(animator.isAnimating() && animator.getDuration()<duration) { + while(animator.isAnimating() && animator.getTotalFPSDuration()<duration) { Thread.sleep(100); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/newt/TestGearsNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/newt/TestGearsNEWT.java index 0f7d77f82..a3f144c06 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/newt/TestGearsNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/newt/TestGearsNEWT.java @@ -37,6 +37,8 @@ import com.jogamp.opengl.test.junit.util.QuitAdapter; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.test.junit.jogl.demos.gl2.gears.Gears; + +import javax.media.opengl.FPSCounter; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLProfile; @@ -98,9 +100,10 @@ public class TestGearsNEWT extends UITestCase { glWindow.setSize(width, height); glWindow.setVisible(true); + animator.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); animator.start(); - while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getDuration()<duration) { + while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) { Thread.sleep(100); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/newt/TestGearsNewtAWTWrapper.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/newt/TestGearsNewtAWTWrapper.java index f05c20c4c..9ed324b32 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/newt/TestGearsNewtAWTWrapper.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/newt/TestGearsNewtAWTWrapper.java @@ -30,6 +30,7 @@ package com.jogamp.opengl.test.junit.jogl.demos.gl2.gears.newt; import javax.media.nativewindow.*; import javax.media.opengl.*; + import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.test.junit.util.UITestCase; @@ -80,9 +81,10 @@ public class TestGearsNewtAWTWrapper extends UITestCase { glWindow.setSize(width, height); glWindow.setVisible(true); + animator.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); animator.start(); - while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getDuration()<duration) { + while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) { Thread.sleep(100); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/GLSLMiscHelper.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/GLSLMiscHelper.java index de6b91242..1638d69dd 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/GLSLMiscHelper.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/GLSLMiscHelper.java @@ -34,11 +34,15 @@ import com.jogamp.opengl.util.glsl.ShaderState; import javax.media.opengl.GL; import javax.media.opengl.GL2ES2; import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLContext; import javax.media.opengl.GLProfile; import org.junit.Assert; public class GLSLMiscHelper { + public static final int frames_perftest = 10000; // frames + public static final int frames_warmup = 500; // frames + public static GLWindow createWindow() { GLProfile glp = GLProfile.get(GLProfile.GL2ES2); GLCapabilities caps = new GLCapabilities(glp); @@ -46,9 +50,13 @@ public class GLSLMiscHelper { window.setSize(800, 600); window.setVisible(true); Assert.assertTrue(window.isNativeValid()); - window.display(); - Assert.assertTrue(window.isRealized()); - Assert.assertTrue(window.getContext().isCreated()); + Assert.assertTrue(window.isRealized()); + GLContext context = window.getContext(); + Assert.assertNotNull(context); + context.setSynchronized(true); + context.makeCurrent(); // native context creation + context.release(); + Assert.assertTrue(context.isCreated()); return window; } @@ -72,9 +80,13 @@ public class GLSLMiscHelper { System.err.println("screen #"+num); if(preEnable) { vertices.enableBuffer(gl, true); - Assert.assertEquals(vertices.getVBOName(), gl.glGetBoundBuffer(GL.GL_ARRAY_BUFFER)); + // invalid - Assert.assertEquals(vertices.getVBOName(), gl.glGetBoundBuffer(GL.GL_ARRAY_BUFFER)); colors.enableBuffer(gl, true); - Assert.assertEquals(colors.getVBOName(), gl.glGetBoundBuffer(GL.GL_ARRAY_BUFFER)); + // invalid - Assert.assertEquals(colors.getVBOName(), gl.glGetBoundBuffer(GL.GL_ARRAY_BUFFER)); + // + // Above assertions are invalid, since GLSLArrayHandler will not bind the VBO to target + // if the VBO is already bound to the attribute itself. + // validateGLArrayDataServerState(..) does check proper VBO to attribute binding. } Assert.assertTrue(vertices.enabled()); Assert.assertTrue(colors.enabled()); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java index 09e6f4e8c..126e10f06 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java @@ -52,8 +52,6 @@ import org.junit.Test; */ public class TestGLSLShaderState01NEWT extends UITestCase { static long durationPerTest = 10; // ms - static int frames_perftest = 5000; // frames - static int frames_warmup = 100; // frames static final int vertices0_loc = 1; static final int colors0_loc = 2; @@ -63,7 +61,6 @@ public class TestGLSLShaderState01NEWT extends UITestCase { // preset .. GLWindow window = GLSLMiscHelper.createWindow(); GLContext context = window.getContext(); - context.setSynchronized(true); context.makeCurrent(); GL2ES2 gl = context.getGL().getGL2ES2(); @@ -188,7 +185,6 @@ public class TestGLSLShaderState01NEWT extends UITestCase { // preset .. GLWindow window = GLSLMiscHelper.createWindow(); GLContext context = window.getContext(); - context.setSynchronized(true); context.makeCurrent(); GL2ES2 gl = context.getGL().getGL2ES2(); @@ -245,13 +241,11 @@ public class TestGLSLShaderState01NEWT extends UITestCase { GLSLMiscHelper.displayVCArrays(window, gl, toggleEnable, vertices0, colors0, toggleEnable, 1, 0); // warmup .. - for(frames=0; frames<frames_warmup; frames++) { - GLSLMiscHelper.displayVCArraysNoChecks(window, gl, toggleEnable, vertices0, colors0, toggleEnable); + for(frames=0; frames<GLSLMiscHelper.frames_warmup; frames++) { GLSLMiscHelper.displayVCArraysNoChecks(window, gl, toggleEnable, vertices0, colors0, toggleEnable); } // measure .. - for(frames=0; frames<frames_perftest; frames++) { - GLSLMiscHelper.displayVCArraysNoChecks(window, gl, toggleEnable, vertices0, colors0, toggleEnable); + for(frames=0; frames<GLSLMiscHelper.frames_perftest; frames++) { GLSLMiscHelper.displayVCArraysNoChecks(window, gl, toggleEnable, vertices0, colors0, toggleEnable); } final long t1 = System.currentTimeMillis(); @@ -275,7 +269,6 @@ public class TestGLSLShaderState01NEWT extends UITestCase { // preset .. GLWindow window = GLSLMiscHelper.createWindow(); GLContext context = window.getContext(); - context.setSynchronized(true); context.makeCurrent(); GL2ES2 gl = context.getGL().getGL2ES2(); @@ -340,12 +333,12 @@ public class TestGLSLShaderState01NEWT extends UITestCase { long t0 = System.currentTimeMillis(); int frames; // warmup .. - for(frames=0; frames<frames_warmup; frames++) { + for(frames=0; frames<GLSLMiscHelper.frames_warmup; frames+=2) { GLSLMiscHelper.displayVCArraysNoChecks(window, gl, true, vertices0, colors0, true); GLSLMiscHelper.displayVCArraysNoChecks(window, gl, true, vertices1, colors1, true); } // measure .. - for(frames=0; frames<frames_perftest; frames++) { + for(frames=0; frames<GLSLMiscHelper.frames_perftest; frames+=2) { GLSLMiscHelper.displayVCArraysNoChecks(window, gl, true, vertices0, colors0, true); GLSLMiscHelper.displayVCArraysNoChecks(window, gl, true, vertices1, colors1, true); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java index 7f41dbf30..57fc9a885 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java @@ -52,8 +52,6 @@ import org.junit.Test; */ public class TestGLSLShaderState02NEWT extends UITestCase { static long durationPerTest = 10; // ms - static int frames_perftest = 5000; // frames - static int frames_warmup = 100; // frames static final int vertices0_loc = 1; static final int colors0_loc = 2; @@ -63,7 +61,6 @@ public class TestGLSLShaderState02NEWT extends UITestCase { // preset .. GLWindow window = GLSLMiscHelper.createWindow(); GLContext context = window.getContext(); - context.setSynchronized(true); context.makeCurrent(); GL2ES2 gl = context.getGL().getGL2ES2(); @@ -212,7 +209,6 @@ public class TestGLSLShaderState02NEWT extends UITestCase { // preset .. GLWindow window = GLSLMiscHelper.createWindow(); GLContext context = window.getContext(); - context.setSynchronized(true); context.makeCurrent(); GL2ES2 gl = context.getGL().getGL2ES2(); @@ -287,12 +283,12 @@ public class TestGLSLShaderState02NEWT extends UITestCase { long t0 = System.currentTimeMillis(); int frames; // warmup .. - for(frames=0; frames<frames_warmup; frames++) { + for(frames=0; frames<GLSLMiscHelper.frames_warmup; frames+=2) { GLSLMiscHelper.displayVCArraysNoChecks(window, gl, true, vertices0, colors0, true); GLSLMiscHelper.displayVCArraysNoChecks(window, gl, true, vertices1, colors1, true); } // measure .. - for(frames=0; frames<frames_perftest; frames+=2) { + for(frames=0; frames<GLSLMiscHelper.frames_perftest; frames+=4) { // SP0 vertices0.setLocation(-1); colors0.setLocation(-1); @@ -338,9 +334,16 @@ public class TestGLSLShaderState02NEWT extends UITestCase { } if(wait) { while(-1 == System.in.read()) ; + TestGLSLShaderState02NEWT tst = new TestGLSLShaderState02NEWT(); + try { + tst.testShaderState01PerformanceDouble(); + } catch (Exception e) { + e.printStackTrace(); + } + } else { + String tstname = TestGLSLShaderState02NEWT.class.getName(); + org.junit.runner.JUnitCore.main(tstname); + System.err.println("main - end"); } - String tstname = TestGLSLShaderState02NEWT.class.getName(); - org.junit.runner.JUnitCore.main(tstname); - System.err.println("main - end"); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLSimple01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLSimple01NEWT.java index ed2f5d3cb..778f758b0 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLSimple01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLSimple01NEWT.java @@ -33,6 +33,7 @@ import com.jogamp.opengl.test.junit.util.GLSLSimpleProgram; import com.jogamp.opengl.test.junit.util.UITestCase; +import javax.media.opengl.FPSCounter; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLContext; import javax.media.opengl.GLProfile; @@ -117,9 +118,10 @@ public class TestGLSLSimple01NEWT extends UITestCase { window.addGLEventListener(new RedSquare0()); Animator animator = new Animator(window); + animator.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); animator.start(); Assert.assertEquals(true, animator.isAnimating()); - while(animator.isAnimating() && animator.getDuration()<durationPerTest) { + while(animator.isAnimating() && animator.getTotalFPSDuration()<durationPerTest) { Thread.sleep(100); } Assert.assertEquals(true, animator.isAnimating()); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestShaderCompilationBug459AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestShaderCompilationBug459AWT.java index e7f376e3e..5a3c1ef0c 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestShaderCompilationBug459AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestShaderCompilationBug459AWT.java @@ -30,6 +30,7 @@ package com.jogamp.opengl.test.junit.jogl.glsl; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.util.Animator; +import javax.media.opengl.FPSCounter; import javax.media.opengl.GL2GL3; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; @@ -135,9 +136,10 @@ public class TestShaderCompilationBug459AWT extends UITestCase { Animator animator = new Animator(glCanvas); frame.setVisible(true); + animator.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); animator.start(); - while(animator.isAnimating() && animator.getDuration()<duration) { + while(animator.isAnimating() && animator.getTotalFPSDuration()<duration) { Thread.sleep(100); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen01GLPBufferNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen01GLPBufferNEWT.java index 6a02bc03b..40ea6848a 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen01GLPBufferNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen01GLPBufferNEWT.java @@ -92,7 +92,7 @@ public class TestOffscreen01GLPBufferNEWT extends UITestCase { WindowUtilNEWT.setDemoFields(demo, window, glWindow, false); glWindow.addGLEventListener(demo); - while ( glWindow.getTotalFrames() < 2) { + while ( glWindow.getTotalFPSFrames() < 2) { glWindow.display(); } @@ -187,7 +187,7 @@ public class TestOffscreen01GLPBufferNEWT extends UITestCase { glWindows[i].addGLEventListener(demos[i]); } - while ( glWindows[0].getTotalFrames() < 2) { + while ( glWindows[0].getTotalFPSFrames() < 2) { for(i=0; i<winnum; i++) { glWindows[i].display(); } @@ -240,7 +240,7 @@ public class TestOffscreen01GLPBufferNEWT extends UITestCase { glWindows[i].addGLEventListener(demos[i]); } - while ( glWindows[0].getTotalFrames() < 2) { + while ( glWindows[0].getTotalFPSFrames() < 2) { for(i=0; i<winnum; i++) { glWindows[i].display(); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen02BitmapNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen02BitmapNEWT.java index d92b4ffbf..cc6e9b26d 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen02BitmapNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen02BitmapNEWT.java @@ -101,7 +101,7 @@ public class TestOffscreen02BitmapNEWT extends UITestCase { WindowUtilNEWT.setDemoFields(demo, window, glWindow, false); glWindow.addGLEventListener(demo); - while ( glWindow.getTotalFrames() < 2) { + while ( glWindow.getTotalFPSFrames() < 2) { glWindow.display(); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/WindowUtilNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/WindowUtilNEWT.java index 4420a5107..199b094f2 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/WindowUtilNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/WindowUtilNEWT.java @@ -100,7 +100,7 @@ public class WindowUtilNEWT { System.err.println("+++++++++++++++++++++++++++"); } - while ( windowOffScreen.getTotalFrames() < frames) { + while ( windowOffScreen.getTotalFPSFrames() < frames) { windowOffScreen.display(); } windowOffScreen.removeAllSurfaceUpdatedListener(); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle01NEWT.java index 9343e2dd8..c5e7582d4 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle01NEWT.java @@ -118,7 +118,7 @@ public class TestDisplayLifecycle01NEWT extends UITestCase { Assert.assertEquals(false,window.isVisible()); // lazy native creation sequence: Display, Screen and Window - Assert.assertEquals(0, window.getTotalFrames()); + Assert.assertEquals(0, window.getTotalFPSFrames()); window.setVisible(true); Assert.assertEquals(screen,window.getScreen()); @@ -130,14 +130,14 @@ public class TestDisplayLifecycle01NEWT extends UITestCase { Assert.assertEquals(true,screen.isNativeValid()); Assert.assertEquals(true,window.isNativeValid()); Assert.assertEquals(true,window.isVisible()); - System.err.println("Frames for setVisible(true) 1: "+window.getTotalFrames()); - Assert.assertTrue(0 < window.getTotalFrames()); + System.err.println("Frames for setVisible(true) 1: "+window.getTotalFPSFrames()); + Assert.assertTrue(0 < window.getTotalFPSFrames()); - while(window.getDuration()<1*durationPerTest) { + while(window.getTotalFPSDuration()<1*durationPerTest) { window.display(); Thread.sleep(100); } - System.err.println("duration: "+window.getDuration()); + System.err.println("duration: "+window.getTotalFPSDuration()); // just make the Window invisible window.setVisible(false); @@ -145,19 +145,19 @@ public class TestDisplayLifecycle01NEWT extends UITestCase { Assert.assertEquals(false,window.isVisible()); // just make the Window visible again - window.resetCounter(); - Assert.assertEquals(0, window.getTotalFrames()); + window.resetFPSCounter(); + Assert.assertEquals(0, window.getTotalFPSFrames()); window.setVisible(true); Assert.assertEquals(true,window.isNativeValid()); Assert.assertEquals(true,window.isVisible()); - System.err.println("Frames for setVisible(true) 1: "+window.getTotalFrames()); - Assert.assertTrue(0 < window.getTotalFrames()); + System.err.println("Frames for setVisible(true) 1: "+window.getTotalFPSFrames()); + Assert.assertTrue(0 < window.getTotalFPSFrames()); - while(window.getDuration()<2*durationPerTest) { + while(window.getTotalFPSDuration()<2*durationPerTest) { window.display(); Thread.sleep(100); } - System.err.println("duration: "+window.getDuration()); + System.err.println("duration: "+window.getTotalFPSDuration()); // destruction .. window.destroy(); @@ -172,12 +172,12 @@ public class TestDisplayLifecycle01NEWT extends UITestCase { Assert.assertEquals(true, window.isValid()); Assert.assertEquals(false,window.isNativeValid()); Assert.assertEquals(false,window.isVisible()); - window.resetCounter(); - Assert.assertEquals(0, window.getTotalFrames()); + window.resetFPSCounter(); + Assert.assertEquals(0, window.getTotalFPSFrames()); // a display call shall not change a thing window.display(); - Assert.assertEquals(0, window.getTotalFrames()); + Assert.assertEquals(0, window.getTotalFPSFrames()); Assert.assertEquals(false,window.isNativeValid()); Assert.assertEquals(false,window.isVisible()); @@ -193,14 +193,14 @@ public class TestDisplayLifecycle01NEWT extends UITestCase { Assert.assertEquals(true,screen.isNativeValid()); Assert.assertEquals(true,window.isNativeValid()); Assert.assertEquals(true,window.isVisible()); - System.err.println("Frames for setVisible(true) 2: "+window.getTotalFrames()); - Assert.assertTrue(0 < window.getTotalFrames()); + System.err.println("Frames for setVisible(true) 2: "+window.getTotalFPSFrames()); + Assert.assertTrue(0 < window.getTotalFPSFrames()); - while(window.getDuration()<1*durationPerTest) { + while(window.getTotalFPSDuration()<1*durationPerTest) { window.display(); Thread.sleep(100); } - System.err.println("duration: "+window.getDuration()); + System.err.println("duration: "+window.getTotalFPSDuration()); // destruction .. window.destroy(); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle02NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle02NEWT.java index d17c5f025..3691941ed 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle02NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle02NEWT.java @@ -106,7 +106,7 @@ public class TestDisplayLifecycle02NEWT extends UITestCase { Assert.assertEquals(false,window.isVisible()); // lazy native creation sequence: Display, Screen and Window - Assert.assertEquals(0, window.getTotalFrames()); + Assert.assertEquals(0, window.getTotalFPSFrames()); window.setVisible(true); Assert.assertEquals(screen,window.getScreen()); @@ -119,14 +119,14 @@ public class TestDisplayLifecycle02NEWT extends UITestCase { Assert.assertEquals(true,screen.isNativeValid()); Assert.assertEquals(true,window.isNativeValid()); Assert.assertEquals(true,window.isVisible()); - System.err.println("Frames for setVisible(true) 1: "+window.getTotalFrames()); - Assert.assertTrue(0 < window.getTotalFrames()); + System.err.println("Frames for setVisible(true) 1: "+window.getTotalFPSFrames()); + Assert.assertTrue(0 < window.getTotalFPSFrames()); - while(window.getDuration()<1*durationPerTest) { + while(window.getTotalFPSDuration()<1*durationPerTest) { window.display(); Thread.sleep(100); } - System.err.println("duration: "+window.getDuration()); + System.err.println("duration: "+window.getTotalFPSDuration()); // just make the Window invisible window.setVisible(false); @@ -134,19 +134,19 @@ public class TestDisplayLifecycle02NEWT extends UITestCase { Assert.assertEquals(false,window.isVisible()); // just make the Window visible again - window.resetCounter(); - Assert.assertEquals(0, window.getTotalFrames()); + window.resetFPSCounter(); + Assert.assertEquals(0, window.getTotalFPSFrames()); window.setVisible(true); Assert.assertEquals(true,window.isNativeValid()); Assert.assertEquals(true,window.isVisible()); - System.err.println("Frames for setVisible(true) 1: "+window.getTotalFrames()); - Assert.assertTrue(0 < window.getTotalFrames()); + System.err.println("Frames for setVisible(true) 1: "+window.getTotalFPSFrames()); + Assert.assertTrue(0 < window.getTotalFPSFrames()); - while(window.getDuration()<2*durationPerTest) { + while(window.getTotalFPSDuration()<2*durationPerTest) { window.display(); Thread.sleep(100); } - System.err.println("duration: "+window.getDuration()); + System.err.println("duration: "+window.getTotalFPSDuration()); // destruction.. ref count down, but keep all window.destroy(); @@ -164,12 +164,12 @@ public class TestDisplayLifecycle02NEWT extends UITestCase { Assert.assertEquals(false,window.isNativeValid()); Assert.assertEquals(false,window.isVisible()); - window.resetCounter(); - Assert.assertEquals(0, window.getTotalFrames()); + window.resetFPSCounter(); + Assert.assertEquals(0, window.getTotalFPSFrames()); // a display call shall not change a thing window.display(); - Assert.assertEquals(0, window.getTotalFrames()); + Assert.assertEquals(0, window.getTotalFPSFrames()); Assert.assertEquals(false,window.isNativeValid()); Assert.assertEquals(false,window.isVisible()); @@ -187,14 +187,14 @@ public class TestDisplayLifecycle02NEWT extends UITestCase { Assert.assertEquals(true,screen.isNativeValid()); Assert.assertEquals(true,window.isNativeValid()); Assert.assertEquals(true,window.isVisible()); - System.err.println("Frames for setVisible(true) 2: "+window.getTotalFrames()); - Assert.assertTrue(0 < window.getTotalFrames()); + System.err.println("Frames for setVisible(true) 2: "+window.getTotalFPSFrames()); + Assert.assertTrue(0 < window.getTotalFPSFrames()); - while(window.getDuration()<1*durationPerTest) { + while(window.getTotalFPSDuration()<1*durationPerTest) { window.display(); Thread.sleep(100); } - System.err.println("duration: "+window.getDuration()); + System.err.println("duration: "+window.getTotalFPSDuration()); // destruction + invalidate, ie Display/Screen will be unreferenced window.invalidate(); @@ -255,7 +255,7 @@ public class TestDisplayLifecycle02NEWT extends UITestCase { Assert.assertEquals(false,window2.isVisible()); // lazy native creation sequence: Display, Screen and Window - Assert.assertEquals(0, window1.getTotalFrames()); + Assert.assertEquals(0, window1.getTotalFPSFrames()); window1.setVisible(true); Assert.assertEquals(1,Display.getActiveDisplayNumber()); @@ -267,10 +267,10 @@ public class TestDisplayLifecycle02NEWT extends UITestCase { Assert.assertEquals(true,screen.isNativeValid()); Assert.assertEquals(true,window1.isNativeValid()); Assert.assertEquals(true,window1.isVisible()); - System.err.println("Frames for setVisible(true) 1: "+window1.getTotalFrames()); - Assert.assertTrue(0 < window1.getTotalFrames()); + System.err.println("Frames for setVisible(true) 1: "+window1.getTotalFPSFrames()); + Assert.assertTrue(0 < window1.getTotalFPSFrames()); - Assert.assertEquals(0, window2.getTotalFrames()); + Assert.assertEquals(0, window2.getTotalFPSFrames()); window2.setVisible(true); Assert.assertEquals(1,Display.getActiveDisplayNumber()); @@ -282,14 +282,14 @@ public class TestDisplayLifecycle02NEWT extends UITestCase { Assert.assertEquals(true,screen.isNativeValid()); Assert.assertEquals(true,window2.isNativeValid()); Assert.assertEquals(true,window2.isVisible()); - System.err.println("Frames for setVisible(true) 2: "+window2.getTotalFrames()); - Assert.assertTrue(0 < window2.getTotalFrames()); + System.err.println("Frames for setVisible(true) 2: "+window2.getTotalFPSFrames()); + Assert.assertTrue(0 < window2.getTotalFPSFrames()); - while(window1.getDuration()<1*durationPerTest) { + while(window1.getTotalFPSDuration()<1*durationPerTest) { window1.display(); Thread.sleep(100); } - System.err.println("duration: "+window1.getDuration()); + System.err.println("duration: "+window1.getTotalFPSDuration()); // just make the Window invisible window1.setVisible(false); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java b/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java index 047df5cf7..31170d32d 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java @@ -133,10 +133,10 @@ public class TestFocus01SwingAWTRobot extends UITestCase { Assert.assertTrue(AWTRobotUtil.toFront(robot, frame1)); int wait=0; - while(wait<awtWaitTimeout/100 && glWindow1.getTotalFrames()<1) { Thread.sleep(awtWaitTimeout/10); wait++; } - System.err.println("Frames for initial setVisible(true): "+glWindow1.getTotalFrames()); + while(wait<awtWaitTimeout/100 && glWindow1.getTotalFPSFrames()<1) { Thread.sleep(awtWaitTimeout/10); wait++; } + System.err.println("Frames for initial setVisible(true): "+glWindow1.getTotalFPSFrames()); Assert.assertTrue(glWindow1.isVisible()); - Assert.assertTrue(0 < glWindow1.getTotalFrames()); + Assert.assertTrue(0 < glWindow1.getTotalFPSFrames()); // Continuous animation .. Animator animator = new Animator(glWindow1); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java b/src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java index 15e4c3ad8..8242ebb32 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java @@ -164,10 +164,10 @@ public class TestFocus02SwingAWTRobot extends UITestCase { Assert.assertTrue(AWTRobotUtil.toFront(robot, jFrame1)); int wait=0; - while(wait<awtWaitTimeout/100 && glWindow1.getTotalFrames()<1) { Thread.sleep(awtWaitTimeout/10); wait++; } - System.err.println("Frames for initial setVisible(true): "+glWindow1.getTotalFrames()); + while(wait<awtWaitTimeout/100 && glWindow1.getTotalFPSFrames()<1) { Thread.sleep(awtWaitTimeout/10); wait++; } + System.err.println("Frames for initial setVisible(true): "+glWindow1.getTotalFPSFrames()); Assert.assertTrue(glWindow1.isVisible()); - Assert.assertTrue(0 < glWindow1.getTotalFrames()); + Assert.assertTrue(0 < glWindow1.getTotalFPSFrames()); // Continuous animation .. Animator animator1 = new Animator(glWindow1); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows01NEWT.java index 5be97714d..2d0007ecb 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows01NEWT.java @@ -91,12 +91,12 @@ public class TestGLWindows01NEWT extends UITestCase { glWindow.setSize(width, height); - Assert.assertEquals(0, glWindow.getTotalFrames()); + Assert.assertEquals(0, glWindow.getTotalFPSFrames()); glWindow.setVisible(true); Assert.assertEquals(true,glWindow.isVisible()); Assert.assertEquals(true,glWindow.isNativeValid()); - System.out.println("Frames for initial setVisible(true): "+glWindow.getTotalFrames()); - Assert.assertTrue(0 < glWindow.getTotalFrames()); + System.out.println("Frames for initial setVisible(true): "+glWindow.getTotalFPSFrames()); + Assert.assertTrue(0 < glWindow.getTotalFPSFrames()); // // Create native OpenGL resources .. XGL/WGL/CGL .. @@ -195,7 +195,7 @@ public class TestGLWindows01NEWT extends UITestCase { for(state=0; state*100<durationPerTest; state++) { Thread.sleep(100); } - System.out.println("duration: "+window.getDuration()); + System.out.println("duration: "+window.getTotalFPSDuration()); destroyWindow(window); } @@ -211,7 +211,7 @@ public class TestGLWindows01NEWT extends UITestCase { for(state=0; state*100<durationPerTest; state++) { Thread.sleep(100); } - System.out.println("duration: "+window.getDuration()); + System.out.println("duration: "+window.getTotalFPSDuration()); destroyWindow(window); } @@ -226,7 +226,7 @@ public class TestGLWindows01NEWT extends UITestCase { for(state=0; state*100<durationPerTest; state++) { Thread.sleep(100); } - System.out.println("duration: "+window.getDuration()); + System.out.println("duration: "+window.getTotalFPSDuration()); destroyWindow(window); } @@ -263,8 +263,8 @@ public class TestGLWindows01NEWT extends UITestCase { for(state=0; state*100<durationPerTest; state++) { Thread.sleep(100); } - System.out.println("duration1: "+window1.getDuration()); - System.out.println("duration2: "+window2.getDuration()); + System.out.println("duration1: "+window1.getTotalFPSDuration()); + System.out.println("duration2: "+window2.getTotalFPSDuration()); destroyWindow(window1); destroyWindow(window2); @@ -325,8 +325,8 @@ public class TestGLWindows01NEWT extends UITestCase { for(state=0; state*100<durationPerTest; state++) { Thread.sleep(100); } - System.out.println("duration1: "+window1.getDuration()); - System.out.println("duration2: "+window2.getDuration()); + System.out.println("duration1: "+window1.getTotalFPSDuration()); + System.out.println("duration2: "+window2.getTotalFPSDuration()); // It is observed that some X11 drivers, eg ATI, fglrx 8.78.6, // are quite sensitive to multiple Display connections (NEWT Display -> X11 Display). diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows02NEWTAnimated.java b/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows02NEWTAnimated.java index 6582a96c0..f7aab9efa 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows02NEWTAnimated.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows02NEWTAnimated.java @@ -118,8 +118,9 @@ public class TestGLWindows02NEWTAnimated extends UITestCase { Assert.assertNotNull(caps); GLWindow window = createWindow(null, caps, width, height, true /* onscreen */, false /* undecorated */); Animator animator = new Animator(window); + animator.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); Assert.assertTrue(animator.start()); - while(animator.isAnimating() && animator.getDuration()<durationPerTest) { + while(animator.isAnimating() && animator.getTotalFPSDuration()<durationPerTest) { Thread.sleep(100); } destroyWindow(window); @@ -133,8 +134,9 @@ public class TestGLWindows02NEWTAnimated extends UITestCase { Assert.assertNotNull(caps); GLWindow window = createWindow(null, caps, width, height, true /* onscreen */, false /* undecorated */); Animator animator = new Animator(window); + animator.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); Assert.assertTrue(animator.start()); - while(animator.isAnimating() && animator.getDuration()<durationPerTest) { + while(animator.isAnimating() && animator.getTotalFPSDuration()<durationPerTest) { Thread.sleep(100); } destroyWindow(window); @@ -162,6 +164,7 @@ public class TestGLWindows02NEWTAnimated extends UITestCase { window2.setPosition(screen.getWidth()-width, 0); Animator animator = new Animator(); + animator.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); Assert.assertEquals(false, animator.isStarted()); Assert.assertEquals(false, animator.isAnimating()); Assert.assertEquals(false, animator.isPaused()); @@ -181,7 +184,7 @@ public class TestGLWindows02NEWTAnimated extends UITestCase { Assert.assertEquals(true, animator.isAnimating()); Assert.assertEquals(false, animator.isPaused()); - while(animator.isAnimating() && animator.getDuration()<durationPerTest) { + while(animator.isAnimating() && animator.getTotalFPSDuration()<durationPerTest) { Thread.sleep(100); } window1.invalidate(); @@ -189,7 +192,7 @@ public class TestGLWindows02NEWTAnimated extends UITestCase { Assert.assertEquals(true, animator.isAnimating()); Assert.assertEquals(false, animator.isPaused()); - while(animator.isAnimating() && animator.getDuration()<2*durationPerTest) { + while(animator.isAnimating() && animator.getTotalFPSDuration()<2*durationPerTest) { Thread.sleep(100); } window2.invalidate(); @@ -242,7 +245,7 @@ public class TestGLWindows02NEWTAnimated extends UITestCase { Assert.assertEquals(true, animator.isAnimating()); Assert.assertEquals(false, animator.isPaused()); - while(animator.isAnimating() && animator.getDuration()<durationPerTest) { + while(animator.isAnimating() && animator.getTotalFPSDuration()<durationPerTest) { Thread.sleep(100); } destroyWindow(window1); @@ -250,7 +253,7 @@ public class TestGLWindows02NEWTAnimated extends UITestCase { Assert.assertEquals(true, animator.isAnimating()); Assert.assertEquals(false, animator.isPaused()); - while(animator.isAnimating() && animator.getDuration()<2*durationPerTest) { + while(animator.isAnimating() && animator.getTotalFPSDuration()<2*durationPerTest) { Thread.sleep(100); } destroyWindow(window2); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestListenerCom01AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestListenerCom01AWT.java index b2068d976..41f0563ac 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestListenerCom01AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestListenerCom01AWT.java @@ -109,8 +109,9 @@ public class TestListenerCom01AWT extends UITestCase { frame.setVisible(true); Animator animator1 = new Animator(glWindow); + animator1.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); animator1.start(); - while(animator1.isAnimating() && animator1.getDuration()<durationPerTest) { + while(animator1.isAnimating() && animator1.getTotalFPSDuration()<durationPerTest) { Thread.sleep(100); width+=10; height+=10; frame.setSize(width, height); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestRemoteGLWindows01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestRemoteGLWindows01NEWT.java index 6b501e31d..57e69afc8 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestRemoteGLWindows01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestRemoteGLWindows01NEWT.java @@ -34,6 +34,7 @@ import org.junit.BeforeClass; import org.junit.Test; import javax.media.opengl.*; + import com.jogamp.opengl.util.Animator; import com.jogamp.newt.*; @@ -136,9 +137,10 @@ public class TestRemoteGLWindows01NEWT extends UITestCase { Assert.assertEquals(true,window2.isVisible()); animator.add(window2); + animator.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); animator.start(); - while(animator.getDuration()<durationPerTest) { + while(animator.getTotalFPSDuration()<durationPerTest) { Thread.sleep(100); } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java index 5173d0f22..d1c82ba34 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java @@ -62,15 +62,10 @@ public class TestParenting01NEWT extends UITestCase { @Test public void testWindowParenting01CreateVisibleDestroy() throws InterruptedException { - int x = 0; - int y = 0; - Assert.assertEquals(0,Display.getActiveDisplayNumber()); Display display = null; Screen screen = null; - NEWTEventFiFo eventFifo = new NEWTEventFiFo(); - GLWindow glWindow1 = GLWindow.create(glCaps); Assert.assertNotNull(glWindow1); Assert.assertEquals(false, glWindow1.isVisible()); @@ -113,12 +108,12 @@ public class TestParenting01NEWT extends UITestCase { Assert.assertEquals(0,Display.getActiveDisplayNumber()); // visible test - Assert.assertEquals(0, glWindow1.getTotalFrames()); - Assert.assertEquals(0, glWindow2.getTotalFrames()); + Assert.assertEquals(0, glWindow1.getTotalFPSFrames()); + Assert.assertEquals(0, glWindow2.getTotalFPSFrames()); glWindow1.setVisible(true); - System.err.println("Frames for setVisible(true): A1: "+glWindow1.getTotalFrames()+", B1: "+glWindow2.getTotalFrames()); - Assert.assertTrue(0 < glWindow1.getTotalFrames()); - Assert.assertTrue(0 < glWindow2.getTotalFrames()); + System.err.println("Frames for setVisible(true): A1: "+glWindow1.getTotalFPSFrames()+", B1: "+glWindow2.getTotalFPSFrames()); + Assert.assertTrue(0 < glWindow1.getTotalFPSFrames()); + Assert.assertTrue(0 < glWindow2.getTotalFPSFrames()); Assert.assertEquals(true, glWindow1.isVisible()); Assert.assertEquals(true, glWindow1.isNativeValid()); @@ -138,38 +133,40 @@ public class TestParenting01NEWT extends UITestCase { Assert.assertEquals(false, glWindow2.isVisible()); Assert.assertEquals(true, glWindow2.isNativeValid()); - glWindow1.resetCounter(); - glWindow2.resetCounter(); - Assert.assertEquals(0, glWindow1.getTotalFrames()); - Assert.assertEquals(0, glWindow2.getTotalFrames()); + glWindow1.resetFPSCounter(); + glWindow2.resetFPSCounter(); + Assert.assertEquals(0, glWindow1.getTotalFPSFrames()); + Assert.assertEquals(0, glWindow2.getTotalFPSFrames()); glWindow1.setVisible(true); - System.err.println("Frames for setVisible(true): A2: "+glWindow1.getTotalFrames()+", B2: "+glWindow2.getTotalFrames()); - Assert.assertTrue(0 < glWindow1.getTotalFrames()); - Assert.assertTrue(0 < glWindow2.getTotalFrames()); + System.err.println("Frames for setVisible(true): A2: "+glWindow1.getTotalFPSFrames()+", B2: "+glWindow2.getTotalFPSFrames()); + Assert.assertTrue(0 < glWindow1.getTotalFPSFrames()); + Assert.assertTrue(0 < glWindow2.getTotalFPSFrames()); Assert.assertEquals(true, glWindow1.isVisible()); Assert.assertEquals(true, glWindow1.isNativeValid()); Assert.assertEquals(true, glWindow2.isVisible()); Assert.assertEquals(true, glWindow2.isNativeValid()); - glWindow1.resetCounter(); - glWindow2.resetCounter(); + glWindow1.resetFPSCounter(); + glWindow2.resetFPSCounter(); Animator animator1 = new Animator(glWindow1); + animator1.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); animator1.start(); Assert.assertEquals(true, animator1.isAnimating()); Assert.assertEquals(false, animator1.isPaused()); Assert.assertNotNull(animator1.getThread()); Animator animator2 = new Animator(glWindow2); + animator2.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); animator2.start(); Assert.assertEquals(true, animator2.isAnimating()); Assert.assertEquals(false, animator2.isPaused()); Assert.assertNotNull(animator2.getThread()); - while(animator1.isAnimating() && animator1.getDuration()<durationPerTest) { + while(animator1.isAnimating() && animator1.getTotalFPSDuration()<durationPerTest) { Thread.sleep(100); } - System.err.println("Frames for setVisible(true): A3: "+glWindow1.getTotalFrames()+", B3: "+glWindow2.getTotalFrames()); - Assert.assertTrue(0 < glWindow1.getTotalFrames()); - Assert.assertTrue(0 < glWindow2.getTotalFrames()); + System.err.println("Frames for setVisible(true): A3: "+glWindow1.getTotalFPSFrames()+", B3: "+glWindow2.getTotalFPSFrames()); + Assert.assertTrue(0 < glWindow1.getTotalFPSFrames()); + Assert.assertTrue(0 < glWindow2.getTotalFPSFrames()); Assert.assertEquals(true, animator1.pause()); Assert.assertEquals(false, animator1.isAnimating()); @@ -180,8 +177,8 @@ public class TestParenting01NEWT extends UITestCase { Assert.assertEquals(true, animator2.isPaused()); Assert.assertNotNull(animator2.getThread()); - glWindow1.resetCounter(); - glWindow2.resetCounter(); + glWindow1.resetFPSCounter(); + glWindow2.resetFPSCounter(); Assert.assertEquals(true, animator1.resume()); Assert.assertEquals(true, animator1.isAnimating()); Assert.assertEquals(false, animator1.isPaused()); @@ -191,9 +188,9 @@ public class TestParenting01NEWT extends UITestCase { Assert.assertEquals(false, animator2.isPaused()); Assert.assertNotNull(animator2.getThread()); Thread.sleep(waitAbout10FramesAt30fps); - System.err.println("Frames for setVisible(true): A4: "+glWindow1.getTotalFrames()+", B4: "+glWindow2.getTotalFrames()); - Assert.assertTrue(0 < glWindow1.getTotalFrames()); - Assert.assertTrue(0 < glWindow2.getTotalFrames()); + System.err.println("Frames for setVisible(true): A4: "+glWindow1.getTotalFPSFrames()+", B4: "+glWindow2.getTotalFPSFrames()); + Assert.assertTrue(0 < glWindow1.getTotalFPSFrames()); + Assert.assertTrue(0 < glWindow2.getTotalFPSFrames()); animator1.stop(); Assert.assertEquals(false, animator1.isAnimating()); @@ -245,19 +242,19 @@ public class TestParenting01NEWT extends UITestCase { Assert.assertEquals(0,Display.getActiveDisplayNumber()); // recreation .. - glWindow1.resetCounter(); - glWindow2.resetCounter(); - Assert.assertEquals(0, glWindow1.getTotalFrames()); - Assert.assertEquals(0, glWindow2.getTotalFrames()); + glWindow1.resetFPSCounter(); + glWindow2.resetFPSCounter(); + Assert.assertEquals(0, glWindow1.getTotalFPSFrames()); + Assert.assertEquals(0, glWindow2.getTotalFPSFrames()); glWindow1.setVisible(true); Assert.assertEquals(true, glWindow1.isVisible()); Assert.assertEquals(true, glWindow1.isNativeValid()); Assert.assertEquals(true, glWindow2.isVisible()); Assert.assertEquals(true, glWindow2.isNativeValid()); - System.err.println("Frames for setVisible(true): A3: "+glWindow1.getTotalFrames()+", B3: "+glWindow2.getTotalFrames()); - Assert.assertTrue(0 < glWindow1.getTotalFrames()); - Assert.assertTrue(0 < glWindow2.getTotalFrames()); + System.err.println("Frames for setVisible(true): A3: "+glWindow1.getTotalFPSFrames()+", B3: "+glWindow2.getTotalFPSFrames()); + Assert.assertTrue(0 < glWindow1.getTotalFPSFrames()); + Assert.assertTrue(0 < glWindow2.getTotalFPSFrames()); Assert.assertEquals(1,display.getReferenceCount()); Assert.assertEquals(true,display.isNativeValid()); @@ -312,15 +309,10 @@ public class TestParenting01NEWT extends UITestCase { * @param reparentRecreate true, if the followup reparent should utilize destroy/create, instead of native reparenting */ protected void testWindowParenting02ReparentTop2WinImpl(boolean reparentRecreate) throws InterruptedException { - int x = 0; - int y = 0; - Assert.assertEquals(0,Display.getActiveDisplayNumber()); Display display1 = null; Screen screen1 = null; - NEWTEventFiFo eventFifo = new NEWTEventFiFo(); - GLWindow glWindow1 = GLWindow.create(glCaps); glWindow1.setTitle("testWindowParenting02ReparentTop2Win"); glWindow1.setSize(640, 480); @@ -354,7 +346,7 @@ public class TestParenting01NEWT extends UITestCase { Assert.assertEquals(false,screen1.isNativeValid()); Assert.assertEquals(0,Display.getActiveDisplayNumber()); - Assert.assertEquals(0, glWindow1.getTotalFrames()); + Assert.assertEquals(0, glWindow1.getTotalFPSFrames()); glWindow1.setVisible(true); Assert.assertEquals(1,display1.getReferenceCount()); Assert.assertEquals(true,display1.isNativeValid()); @@ -364,10 +356,10 @@ public class TestParenting01NEWT extends UITestCase { Assert.assertEquals(true,screen1.isNativeValid()); Assert.assertEquals(1,Display.getActiveDisplayNumber()); Assert.assertEquals(true, glWindow1.isVisible()); - System.err.println("Frames for setVisible(true) A1: "+glWindow1.getTotalFrames()); - Assert.assertTrue(0 < glWindow1.getTotalFrames()); + System.err.println("Frames for setVisible(true) A1: "+glWindow1.getTotalFPSFrames()); + Assert.assertTrue(0 < glWindow1.getTotalFPSFrames()); - Assert.assertEquals(0, glWindow2.getTotalFrames()); + Assert.assertEquals(0, glWindow2.getTotalFPSFrames()); glWindow2.setVisible(true); Assert.assertEquals(1,display1.getReferenceCount()); @@ -378,31 +370,33 @@ public class TestParenting01NEWT extends UITestCase { Assert.assertEquals(true,screen1.isNativeValid()); Assert.assertEquals(1,Display.getActiveDisplayNumber()); Assert.assertEquals(true, glWindow2.isVisible()); - System.err.println("Frames for setVisible(true) B1: "+glWindow2.getTotalFrames()); - Assert.assertTrue(0 < glWindow1.getTotalFrames()); + System.err.println("Frames for setVisible(true) B1: "+glWindow2.getTotalFPSFrames()); + Assert.assertTrue(0 < glWindow1.getTotalFPSFrames()); Animator animator1 = new Animator(glWindow1); + animator1.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); animator1.start(); Animator animator2 = new Animator(glWindow2); + animator2.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); animator2.start(); int state = 0; int reparentAction; - while(animator1.isAnimating() && animator1.getDuration()<3*durationPerTest) { + while(animator1.isAnimating() && animator1.getTotalFPSDuration()<3*durationPerTest) { Thread.sleep(durationPerTest); switch(state) { case 0: // glWindow2 -- child --> glWindow1: compatible Assert.assertEquals(true, glWindow2.isVisible()); - System.err.println("Frames(1) "+glWindow2.getTotalFrames()); + System.err.println("Frames(1) "+glWindow2.getTotalFPSFrames()); reparentAction = glWindow2.reparentWindow(glWindow1, reparentRecreate); - System.err.println("Frames(2) "+glWindow2.getTotalFrames()); + System.err.println("Frames(2) "+glWindow2.getTotalFPSFrames()); Assert.assertTrue(Window.ReparentAction.ACTION_INVALID < reparentAction); Assert.assertEquals(true, glWindow2.isVisible()); Assert.assertEquals(true, glWindow2.isNativeValid()); Assert.assertSame(glWindow1,glWindow2.getParent()); - System.err.println("Frames for reparentWindow(parent, "+reparentRecreate+"): "+reparentAction+", B2: "+glWindow2.getTotalFrames()); - Assert.assertTrue(0 < glWindow2.getTotalFrames()); + System.err.println("Frames for reparentWindow(parent, "+reparentRecreate+"): "+reparentAction+", B2: "+glWindow2.getTotalFPSFrames()); + Assert.assertTrue(0 < glWindow2.getTotalFPSFrames()); Assert.assertEquals(1,display1.getReferenceCount()); Assert.assertEquals(true,display1.isNativeValid()); @@ -425,8 +419,8 @@ public class TestParenting01NEWT extends UITestCase { Assert.assertEquals(true, glWindow2.isVisible()); Assert.assertEquals(true, glWindow2.isNativeValid()); Assert.assertNull(glWindow2.getParent()); - System.err.println("Frames for reparentWindow(parent, "+reparentRecreate+"): "+reparentAction+", B3: "+glWindow2.getTotalFrames()); - Assert.assertTrue(0 < glWindow2.getTotalFrames()); + System.err.println("Frames for reparentWindow(parent, "+reparentRecreate+"): "+reparentAction+", B3: "+glWindow2.getTotalFPSFrames()); + Assert.assertTrue(0 < glWindow2.getTotalFPSFrames()); Assert.assertEquals(1,display1.getReferenceCount()); Assert.assertEquals(true,display1.isNativeValid()); @@ -519,11 +513,6 @@ public class TestParenting01NEWT extends UITestCase { } protected void testWindowParenting03ReparentWin2TopImpl(boolean reparentRecreate) throws InterruptedException { - int x = 0; - int y = 0; - - NEWTEventFiFo eventFifo = new NEWTEventFiFo(); - Assert.assertEquals(0,Display.getActiveDisplayNumber()); Display display1 = null; Screen screen1 = null; @@ -566,12 +555,12 @@ public class TestParenting01NEWT extends UITestCase { Assert.assertSame(screen1,glWindow2.getScreen()); Assert.assertSame(display1,glWindow2.getScreen().getDisplay()); - Assert.assertEquals(0, glWindow1.getTotalFrames()); - Assert.assertEquals(0, glWindow2.getTotalFrames()); + Assert.assertEquals(0, glWindow1.getTotalFPSFrames()); + Assert.assertEquals(0, glWindow2.getTotalFPSFrames()); glWindow1.setVisible(true); - System.err.println("Frames for setVisible(): A1: "+glWindow1.getTotalFrames()+", B1: "+glWindow2.getTotalFrames()); - Assert.assertTrue(0 < glWindow2.getTotalFrames()); - Assert.assertTrue(0 < glWindow1.getTotalFrames()); + System.err.println("Frames for setVisible(): A1: "+glWindow1.getTotalFPSFrames()+", B1: "+glWindow2.getTotalFPSFrames()); + Assert.assertTrue(0 < glWindow2.getTotalFPSFrames()); + Assert.assertTrue(0 < glWindow1.getTotalFPSFrames()); Assert.assertEquals(1,display1.getReferenceCount()); Assert.assertEquals(true,display1.isNativeValid()); @@ -584,13 +573,15 @@ public class TestParenting01NEWT extends UITestCase { Assert.assertEquals(1,Display.getActiveDisplayNumber()); Animator animator1 = new Animator(glWindow1); + animator1.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); animator1.start(); Animator animator2 = new Animator(glWindow2); + animator2.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); animator2.start(); int state = 0; int reparentAction; - while(animator1.isAnimating() && animator1.getDuration()<3*durationPerTest) { + while(animator1.isAnimating() && animator1.getTotalFPSDuration()<3*durationPerTest) { Thread.sleep(durationPerTest); switch(state) { case 0: @@ -599,8 +590,8 @@ public class TestParenting01NEWT extends UITestCase { Assert.assertTrue(Window.ReparentAction.ACTION_INVALID < reparentAction); Assert.assertEquals(true, glWindow2.isVisible()); Assert.assertEquals(true, glWindow2.isNativeValid()); - System.err.println("Frames for reparentWindow(parent, "+reparentRecreate+"): "+reparentAction+", B2: "+glWindow2.getTotalFrames()); - Assert.assertTrue(0 < glWindow2.getTotalFrames()); + System.err.println("Frames for reparentWindow(parent, "+reparentRecreate+"): "+reparentAction+", B2: "+glWindow2.getTotalFPSFrames()); + Assert.assertTrue(0 < glWindow2.getTotalFPSFrames()); Assert.assertNull(glWindow2.getParent()); Assert.assertSame(screen1,glWindow2.getScreen()); Assert.assertSame(display1,glWindow2.getScreen().getDisplay()); @@ -612,8 +603,8 @@ public class TestParenting01NEWT extends UITestCase { Assert.assertTrue(Window.ReparentAction.ACTION_INVALID < reparentAction); Assert.assertEquals(true, glWindow2.isVisible()); Assert.assertEquals(true, glWindow2.isNativeValid()); - System.err.println("Frames for reparentWindow(parent, "+reparentRecreate+"): "+reparentAction+", B3 "+glWindow2.getTotalFrames()); - Assert.assertTrue(0 < glWindow2.getTotalFrames()); + System.err.println("Frames for reparentWindow(parent, "+reparentRecreate+"): "+reparentAction+", B3 "+glWindow2.getTotalFPSFrames()); + Assert.assertTrue(0 < glWindow2.getTotalFPSFrames()); Assert.assertSame(glWindow1,glWindow2.getParent()); Assert.assertSame(screen1,glWindow2.getScreen()); Assert.assertSame(display1,glWindow2.getScreen().getDisplay()); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aAWT.java index 424fff0e2..3046eb061 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aAWT.java @@ -123,8 +123,9 @@ public class TestParenting01aAWT extends UITestCase { Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); Animator animator1 = new Animator(glWindow1); + animator1.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); animator1.start(); - while(animator1.isAnimating() && animator1.getDuration()<durationPerTest) { + while(animator1.isAnimating() && animator1.getTotalFPSDuration()<durationPerTest) { Thread.sleep(100); } animator1.stop(); @@ -180,8 +181,9 @@ public class TestParenting01aAWT extends UITestCase { Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); Animator animator1 = new Animator(glWindow1); + animator1.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); animator1.start(); - while(animator1.isAnimating() && animator1.getDuration()<durationPerTest) { + while(animator1.isAnimating() && animator1.getTotalFPSDuration()<durationPerTest) { Thread.sleep(100); } animator1.stop(); @@ -215,10 +217,11 @@ public class TestParenting01aAWT extends UITestCase { frame.add(newtCanvasAWT); Animator animator1 = new Animator(glWindow1); + animator1.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); animator1.start(); Assert.assertEquals(true, animator1.isStarted()); Assert.assertEquals(true, animator1.isAnimating()); - while(animator1.isAnimating() && animator1.getDuration()<durationPerTest) { + while(animator1.isAnimating() && animator1.getTotalFPSDuration()<durationPerTest) { Thread.sleep(100); } @@ -251,10 +254,11 @@ public class TestParenting01aAWT extends UITestCase { Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); Animator animator1 = new Animator(glWindow1); + animator1.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); animator1.start(); int state = 0; - while(animator1.isAnimating() && animator1.getDuration()<3*durationPerTest) { + while(animator1.isAnimating() && animator1.getTotalFPSDuration()<3*durationPerTest) { Thread.sleep(durationPerTest); switch(state) { case 0: @@ -306,10 +310,11 @@ public class TestParenting01aAWT extends UITestCase { Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); Animator animator1 = new Animator(glWindow1); + animator1.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); animator1.start(); int state = 0; - while(animator1.isAnimating() && animator1.getDuration()<3*durationPerTest) { + while(animator1.isAnimating() && animator1.getTotalFPSDuration()<3*durationPerTest) { Thread.sleep(durationPerTest); switch(state) { case 0: @@ -372,10 +377,11 @@ public class TestParenting01aAWT extends UITestCase { Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); Animator animator1 = new Animator(glWindow1); + animator1.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); animator1.start(); int state = 0; - while(animator1.isAnimating() && animator1.getDuration()<3*durationPerTest) { + while(animator1.isAnimating() && animator1.getTotalFPSDuration()<3*durationPerTest) { Thread.sleep(durationPerTest); switch(state) { case 0: diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java index dde125330..80b7647ae 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java @@ -70,11 +70,6 @@ public class TestParenting01cSwingAWT extends UITestCase { @Test public void testWindowParenting01CreateVisibleDestroy1() throws InterruptedException, InvocationTargetException { - int x = 0; - int y = 0; - - NEWTEventFiFo eventFifo = new NEWTEventFiFo(); - /** * JFrame . JPanel . Container . NewtCanvasAWT . GLWindow */ @@ -88,7 +83,9 @@ public class TestParenting01cSwingAWT extends UITestCase { setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); Animator animator1 = new Animator(glWindow1); + animator1.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); animator1.start(); + final GLWindow _glWindow1 = glWindow1; final GLRunnable _glRunnable = new GLRunnableDummy(); Thread disturbanceThread = new Thread(new Runnable() { @@ -143,7 +140,7 @@ public class TestParenting01cSwingAWT extends UITestCase { // visible test Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); - while(animator1.isAnimating() && animator1.getDuration()<durationPerTest) { + while(animator1.isAnimating() && animator1.getTotalFPSDuration()<durationPerTest) { Thread.sleep(100); } System.out.println("Demos: 2 - StopAnimator"); @@ -184,11 +181,6 @@ public class TestParenting01cSwingAWT extends UITestCase { @Test public void testWindowParenting05ReparentAWTWinHopFrame2Frame() throws InterruptedException, InvocationTargetException { - int x = 0; - int y = 0; - - NEWTEventFiFo eventFifo = new NEWTEventFiFo(); - /** * JFrame . JPanel . Container . NewtCanvasAWT . GLWindow */ @@ -202,7 +194,9 @@ public class TestParenting01cSwingAWT extends UITestCase { setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); Animator animator1 = new Animator(glWindow1); + animator1.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); animator1.start(); + final GLWindow _glWindow1 = glWindow1; final GLRunnable _glRunnable = new GLRunnableDummy(); Thread disturbanceThread = new Thread(new Runnable() { @@ -266,7 +260,6 @@ public class TestParenting01cSwingAWT extends UITestCase { final NewtCanvasAWT _newtCanvasAWT = newtCanvasAWT; final JFrame _jFrame1 = jFrame1; - final JPanel _jPanel1 = jPanel1; final Container _container1 = container1; final JFrame _jFrame2 = jFrame2; final JPanel _jPanel2 = jPanel2; @@ -275,7 +268,7 @@ public class TestParenting01cSwingAWT extends UITestCase { Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); int state = 0; - while(animator1.isAnimating() && animator1.getDuration()<3*durationPerTest) { + while(animator1.isAnimating() && animator1.getTotalFPSDuration()<3*durationPerTest) { Thread.sleep(durationPerTest); switch(state) { case 0: diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java index 7da30cf18..adfdc68f7 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java @@ -29,30 +29,20 @@ package com.jogamp.opengl.test.junit.newt.parenting; import java.lang.reflect.*; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; import org.junit.Assert; -import org.junit.Before; import org.junit.BeforeClass; -import org.junit.After; -import org.junit.AfterClass; import org.junit.Test; -import java.awt.Button; import java.awt.BorderLayout; -import java.awt.Canvas; import java.awt.Container; import java.awt.Dimension; import java.awt.Frame; import java.awt.Label; import javax.media.opengl.*; -import javax.media.nativewindow.*; import com.jogamp.opengl.util.Animator; -import com.jogamp.opengl.util.FPSAnimator; import com.jogamp.newt.*; import com.jogamp.newt.event.*; import com.jogamp.newt.opengl.*; @@ -84,13 +74,8 @@ public class TestParenting03AWT extends UITestCase { } public void testWindowParenting1AWTOneNewtChild() throws InterruptedException, InvocationTargetException { - int x = 0; - int y = 0; - - NEWTEventFiFo eventFifo = new NEWTEventFiFo(); - GLWindow glWindow1 = GLWindow.create(glCaps); - glWindow1.enablePerfLog(true); + glWindow1.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); glWindow1.setUndecorated(true); NewtCanvasAWT newtCanvasAWT1 = new NewtCanvasAWT(glWindow1); newtCanvasAWT1.setPreferredSize(size); @@ -124,7 +109,6 @@ public class TestParenting03AWT extends UITestCase { cont1.setLayout(new BorderLayout()); cont1.add(newtCanvasAWT1, BorderLayout.CENTER); cont1.setVisible(true); - final Container f_cont1 = cont1; Frame frame1 = new Frame("AWT Parent Frame"); frame1.setLayout(new BorderLayout()); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03bAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03bAWT.java index 34d95d8ee..9aec5d80d 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03bAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03bAWT.java @@ -29,30 +29,20 @@ package com.jogamp.opengl.test.junit.newt.parenting; import java.lang.reflect.*; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; import org.junit.Assert; -import org.junit.Before; import org.junit.BeforeClass; -import org.junit.After; -import org.junit.AfterClass; import org.junit.Test; -import java.awt.Button; import java.awt.BorderLayout; -import java.awt.Canvas; import java.awt.Container; import java.awt.Dimension; import java.awt.Frame; import java.awt.Label; import javax.media.opengl.*; -import javax.media.nativewindow.*; import com.jogamp.opengl.util.Animator; -import com.jogamp.opengl.util.FPSAnimator; import com.jogamp.newt.*; import com.jogamp.newt.event.*; import com.jogamp.newt.opengl.*; @@ -82,13 +72,8 @@ public class TestParenting03bAWT extends UITestCase { } public void testWindowParenting1AWTTwoNewtChilds() throws InterruptedException, InvocationTargetException { - int x = 0; - int y = 0; - - NEWTEventFiFo eventFifo = new NEWTEventFiFo(); - GLWindow glWindow1 = GLWindow.create(glCaps); - glWindow1.enablePerfLog(true); + glWindow1.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); glWindow1.setUndecorated(true); NewtCanvasAWT newtCanvasAWT1 = new NewtCanvasAWT(glWindow1); newtCanvasAWT1.setPreferredSize(size); @@ -119,7 +104,7 @@ public class TestParenting03bAWT extends UITestCase { animator1.start(); GLWindow glWindow2 = GLWindow.create(glCaps); - glWindow2.enablePerfLog(true); + glWindow2.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); glWindow2.setUndecorated(true); NewtCanvasAWT newtCanvasAWT2 = new NewtCanvasAWT(glWindow2); newtCanvasAWT2.setPreferredSize(size); @@ -153,7 +138,6 @@ public class TestParenting03bAWT extends UITestCase { cont1.setLayout(new BorderLayout()); cont1.add(newtCanvasAWT1, BorderLayout.CENTER); cont1.setVisible(true); - final Container f_cont1 = cont1; Container cont2 = new Container(); cont2.setLayout(new BorderLayout()); |