From 0e3c55427eb3c56557e42dd3a21aa159e47243de Mon Sep 17 00:00:00 2001 From: Mark Slee Date: Fri, 28 Jun 2013 10:53:12 -0700 Subject: [PATCH] Add framerate UI and control on -/+ keys --- SugarCubes.pde | 2 +- _Internals.pde | 13 +++++++++++-- _Overlay.pde | 9 +++++++-- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/SugarCubes.pde b/SugarCubes.pde index 3f6cc8f..5504001 100644 --- a/SugarCubes.pde +++ b/SugarCubes.pde @@ -1,7 +1,7 @@ /** * +-+-+-+-+-+ +-+-+-+-+-+ * / /| |\ \ - * / / + <+ \ \ + * / / + + \ \ * +-+-+-+-+-+ | +-+-+-+-+ | +-+-+-+-+-+ * | | + / \ + | | * + THE + / / \ \ + CUBES + diff --git a/_Internals.pde b/_Internals.pde index 0249603..5603698 100644 --- a/_Internals.pde +++ b/_Internals.pde @@ -33,7 +33,8 @@ import rwmidi.*; final int VIEWPORT_WIDTH = 900; final int VIEWPORT_HEIGHT = 700; -final int TARGET_FRAMERATE = 45; + +int targetFramerate = 30; int startMillis, lastMillis; GLucose glucose; @@ -58,7 +59,7 @@ void setup() { // Initialize the Processing graphics environment size(VIEWPORT_WIDTH, VIEWPORT_HEIGHT, OPENGL); - frameRate(TARGET_FRAMERATE); + frameRate(targetFramerate); noSmooth(); // hint(ENABLE_OPENGL_4X_SMOOTH); // no discernable improvement? logTime("Created viewport"); @@ -155,6 +156,14 @@ void keyPressed() { mappingTool.keyPressed(); } switch (key) { + case '-': + case '_': + frameRate(--targetFramerate); + break; + case '=': + case '+': + frameRate(++targetFramerate); + break; case 'd': debugMode = !debugMode; println("Debug output: " + (debugMode ? "ON" : "OFF")); diff --git a/_Overlay.pde b/_Overlay.pde index d33e4a1..827223a 100644 --- a/_Overlay.pde +++ b/_Overlay.pde @@ -70,7 +70,12 @@ abstract class OverlayUI { textFont(titleFont); textAlign(LEFT); fill(#666666); - text("FPS: " + (((int)(frameRate * 10)) / 10.), 4, height-6); + text("FPS: " + (((int)(frameRate * 10)) / 10.), 4, height-6); + text("Target (-/+):", 50, height-6); + fill(#000000); + rect(104, height-16, 20, 12); + fill(#666666); + text("" + targetFramerate, 108, height-6); } protected int drawObjectList(int yPos, String title, Object[] items, Method stateMethod) { @@ -148,7 +153,7 @@ abstract class OverlayUI { return (mouseY - firstItemY) / lineHeight; } - abstract public void draw(); + abstract public void draw(); abstract public void mousePressed(); abstract public void mouseDragged(); abstract public void mouseReleased(); -- 2.34.1