We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › calculating suitable framerates
Page Index Toggle Pages: 1
calculating suitable framerates (Read 348 times)
calculating suitable framerates
Apr 26th, 2006, 5:32pm
 
Hi there,

I want to determine my monitors current refresh rate and then provide framerate(x) within my applet a suitable value so that my rapidly moving graphics do not stutter (i.e. x should be some multiple of my monitors refresh rate).

Is this possible?!  Would appreciate your help.  Thanks, Andy.

PS I have actually found a tutorial for how to do this in JAVA, but unfortunately it's quite beyond my current programming skills (see the active rendering section here: http://www.tc.umn.edu/~boyac003/Guide/guideMain.pdf).
Re: calculating suitable framerates
Reply #1 - Apr 26th, 2006, 9:10pm
 
Take a look at this.

http://en.wikipedia.org/wiki/Refresh_rate

It really depends on what you've got, and that's not going to be the same as anyone else who might run your applet.

The other thing to remember is that I doubt Applets are very high on the list of priorities and other tasks may intrude on their CPU allocation and cause a judder, as well as the computational time of your sketch itself being variable depending on what you're doing.

framerate(n) will let you set the framerate and compensate for some of this.

I guess the export as APP also makes a significant difference.

I'm guessing most of this by the way, so don't take it as gospel. I still think everything runs like a C64!

Try something like this in your code if you want to calculate the avergage fps of a sketch.

Code:


int rate_total =0;
int frames =0;

void setup() {

size (400, 400);
framerate(50); // You'll be lucky to maintain this!
}

void draw() {

rate_total += framerate();
frames++;
}

public void stop() {

println( rate_total / frames + " fps");
super.stop();

}

Page Index Toggle Pages: 1