colorful fps counters

This commit is contained in:
yugecin
2017-01-17 21:06:59 +01:00
parent 580b4142f6
commit 14c8fba9cb
2 changed files with 36 additions and 7 deletions

View File

@@ -81,6 +81,9 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
public int mouseX;
public int mouseY;
private int targetUpdatesPerSecond;
public int targetUpdateInterval;
private int targetRendersPerSecond;
public int targetRenderInterval;
public int targetBackgroundRenderInterval;
@@ -118,13 +121,24 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
};
this.nativeDisplayMode = Display.getDisplayMode();
targetRenderInterval = 16; // ~60 fps
setUPS(1000);
setFPS(60);
targetBackgroundRenderInterval = 41; // ~24 fps
lastFrame = getTime();
delta = 1;
renderDelta = 1;
}
public void setUPS(int ups) {
targetUpdatesPerSecond = ups;
targetUpdateInterval = 1000 / targetUpdatesPerSecond;
}
public void setFPS(int fps) {
targetRendersPerSecond = fps;
targetRenderInterval = 1000 / targetRendersPerSecond;
}
public void init(Class<? extends OpsuState> startingState) {
state = instanceContainer.provide(startingState);
state.enter();
@@ -177,7 +191,7 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
}
Display.processMessages();
Display.sync(1000); // TODO add option to change this, to not eat CPUs
Display.sync(targetUpdatesPerSecond);
}
teardown();
}