Skip to content

Commit

Permalink
Only print fps when necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
bxt committed Apr 23, 2012
1 parent ca47a2e commit 2f91d12
Showing 1 changed file with 6 additions and 1 deletion.
Expand Up @@ -9,6 +9,7 @@ public class FpsPrinter extends FpsCounter implements Drawable {

private int every = 40;
private final NumberFormat format = new DecimalFormat("###.#");
private String previousOutput = null;

private PApplet p;

Expand All @@ -26,7 +27,11 @@ public FpsPrinter(int every, PApplet p) {
@Override
public void draw() {
if(p.frameCount % every == 0) {
PApplet.println(format.format(getAvgFps(p.frameCount)) + " fps");
String output = format.format(getAvgFps(p.frameCount)) + " fps";
if(!output.equals(previousOutput)) {
PApplet.println(output);
previousOutput = output;
}
}
}

Expand Down

0 comments on commit 2f91d12

Please sign in to comment.