Yet another FPS Counter

yet another fps counter (see attached file)

maybe the simplest way to use it is by showing the fps in the frame title, example code goes like this:


// construction

final JFrame frame = ..;
        
final FPSCounter fpsCounter = new FPSCounter();
        
fpsCounter.addFPSCounterListener(new FPSCounter.Listener() {
            
    private NumberFormat nf = NumberFormat.getNumberInstance();
    private String oldTitle = frame.getTitle() + " \t ";
            
    public void averageFramesElapsed(FPSCounter.Event e) {
          frame.setTitle(oldTitle + "[ FPS: " + nf.format(e.getAverageFps()) + "(AVG)  " + nf.format(e.getAggregateFps()) + "(AGG) ]");
   }
});

// init, e.g. jogls init method
fpsCounter.start()

// every frame, e.g. jogls display method
fpsCounter.nextFrame();

P.S. sorry for not removing the netbeans code folding tagsā€¦ ::slight_smile: