comparison examples/java3d/FPS.java @ 1:5df24c91468d

Oh my what a mess.
author samer
date Fri, 05 Apr 2019 16:26:00 +0100
parents
children
comparison
equal deleted inserted replaced
0:bf79fb79ee13 1:5df24c91468d
1 import javax.media.j3d.*;
2 import javax.vecmath.*;
3 import java.util.Enumeration;
4
5 final class FPS extends Behavior {
6
7 protected int nFrames;
8 protected long startTime;
9 protected final WakeupCondition w;
10
11 public FPS(int nFrames){
12 this.nFrames=nFrames;
13 w=new WakeupOnElapsedFrames(nFrames);
14 }
15
16 public FPS(){
17 this(100);
18 }
19
20 public void initialize(){
21 setSchedulingBounds(new BoundingSphere(new Point3d(),1000));
22 startTime=System.currentTimeMillis();
23 wakeupOn(w);
24 }
25
26 public void processStimulus(Enumeration criteria){
27 long time=System.currentTimeMillis();
28 System.err.println("fps: "+ 1000 * (double) nFrames / (double) (time-startTime));
29 startTime=time;
30 wakeupOn(w);
31 }
32 }