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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| 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) ]"); } });
fpsCounter.start()
fpsCounter.nextFrame();
|
P.S. sorry for not removing the netbeans code folding tags..
