From 1ad8c39df6b097c80ba7a85badf555e7f669cc3f Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 24 Apr 2010 05:11:29 +0200 Subject: NEWT/AWT Interoperability - Moved all event classes to com.jogamp.newt.event and the new AWT event helper to com.jogamp.newt.awt.event - Added NewtAdapter for convenience - Added AWTAdapter for - Using AWT agnostic NEWT event listener see com.jogamp.test.junit.jogl.demos.gl2.gears.TestGearsNEWT even for AWT see com.jogamp.test.junit.jogl.demos.gl2.gears.TestGearsAWT (Nice idea by mbien) - Forwarding AWT events to NEWT (refactoring) Misc - GLDrawableFactory.shutdown() is now protected and called by the JVM shutdown hook. Hence removing the validate(). --- src/jogl/classes/com/jogamp/opengl/util/Animator.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/jogl/classes/com/jogamp/opengl/util') diff --git a/src/jogl/classes/com/jogamp/opengl/util/Animator.java b/src/jogl/classes/com/jogamp/opengl/util/Animator.java index 30be0bd90..9bef8e9c3 100755 --- a/src/jogl/classes/com/jogamp/opengl/util/Animator.java +++ b/src/jogl/classes/com/jogamp/opengl/util/Animator.java @@ -154,12 +154,19 @@ public class Animator { impl.display(this, ignoreExceptions, printExceptions); } + private long startTime = 0; + private long curTime = 0; + private int totalFrames = 0; + class MainLoop implements Runnable { public void run() { try { if(DEBUG) { System.out.println("Animator started: "+Thread.currentThread()); } + startTime = System.currentTimeMillis(); + curTime = startTime; + while (!shouldStop) { // Don't consume CPU unless there is work to be done if (drawables.size() == 0) { @@ -173,6 +180,8 @@ public class Animator { } } display(); + curTime = System.currentTimeMillis(); + totalFrames++; if (!runAsFastAsPossible) { // Avoid swamping the CPU Thread.yield(); @@ -191,6 +200,11 @@ public class Animator { } } + public long getStartTime() { return startTime; } + public long getCurrentTime() { return curTime; } + public long getDuration() { return curTime-startTime; } + public int getTotalFrames() { return totalFrames; } + /** Starts this animator. */ public synchronized void start() { if (thread != null) { -- cgit v1.2.3