org.xith3d.loop
Class DefaultFPSLimiter

java.lang.Object
  extended by org.xith3d.loop.DefaultFPSLimiter
All Implemented Interfaces:
FPSLimiter

public class DefaultFPSLimiter
extends java.lang.Object
implements FPSLimiter

The default implementation of FPSLimiter. It guarantees, that the CPU load is kept at a minimum, while animation might be juddering.


Constructor Summary
DefaultFPSLimiter()
           
 
Method Summary
static DefaultFPSLimiter getInstance()
           
 long limitFPS(long frameIdx, long frameTime, long minFrameTime, org.jagatoo.util.timing.TimerInterface timer)
          Limits the FPS to a known value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultFPSLimiter

public DefaultFPSLimiter()
Method Detail

getInstance

public static final DefaultFPSLimiter getInstance()

limitFPS

public long limitFPS(long frameIdx,
                     long frameTime,
                     long minFrameTime,
                     org.jagatoo.util.timing.TimerInterface timer)
Limits the FPS to a known value.

Specified by:
limitFPS in interface FPSLimiter
Parameters:
frameIdx - the index of the current frame (zero-based)
frameTime - the time needed to render the current frame (in nano-seconds)
minFrameTime - the minimal frame-time (in nano-seconds) If each frame would take exactly minFrameTime, the desired FPS would be exactly matched.
timer - a TimerInterface to retrieve the current time
Returns:
the wait-time, that is virtually added to the frame-time.