frameRate when noLoop() is set is kind of high

edited November 2013 in Questions about Code

Hello, I found that when noLoop() is set, the frameRate is about 15 fps. I figured the framerate would be zero or close to it. Does anyone know why? See code below for a simple sketch that displays the framerate on the window's title:

// Console update
int cnt;
void setup(){
  noLoop();
  cnt = 0;
  size (400,100);
}
void draw(){
  String msg = ("framerate= " + int(frameRate));
  frame.setTitle(msg);
}

Answers

  • If I had to guess, it is to detect loop() being called after

  • Answer ✓

    processing.org/reference/frameRate.html

    The initial value is 10 fps and is updated with each frame. The value is averaged over several frames, and so will only be accurate after the draw function has run 5-10 times.

    So it looks like the initial value has been changed to 15.

    Add this piece of code to your sketch and see how frameRate approaches zero by each click.

    void mousePressed() {
      redraw();
    }
    
  • Answer ✓

    The frameRate variable adjusts dynamically, the actual frame rate is 0 in your program but the variable won't have that value because you're no allowing it to adjust. If you also print the frameCount, you'll see that it's not updating.

  • Got it. I didn't know about frameCount...learn something new every day $-)

Sign In or Register to comment.