Hi everybody,
How can I calculate the fps in a game?
I don’t understand how can I enable the key repeat usign only SDL api…
any one can help me?
tnx
How can I calculate the fps in a game?
get timer before a frame (timer = A)
get timer before next frame (timer = B)
fps = 1 / (B - A)
Hi everybody,
How can I calculate the fps in a game?
Count the number of frames and divide by the number of seconds it took
to draw them. Frames/seconds == frames per second == fps
I don’t understand how can I enable the key repeat usign only SDL api…
http://sdldoc.csn.ul.ie/sdlenablekeyrepeat.php If that doesn’t do it for
you, I don’t know what can.
any one can help me?
tnx
Bob PendletonOn Tue, 2003-07-08 at 16:05, NighTiger wrote:
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl
–
±----------------------------------+
- Bob Pendleton: independent writer +
- and programmer. +
- email: Bob at Pendleton.com +
- web: www.GameProgrammer.com +
±----------------------------------+
“Bob Pendleton” wrote in message
news:mailman.1057700344.27358.sdl at libsdl.org…
Hi everybody,
How can I calculate the fps in a game?Count the number of frames and divide by the number of seconds it took
to draw them. Frames/seconds == frames per second == fps
Just to add to what bob said: you should take a sample (ie 10 frames).
Something like this.
sample = 10; //sample every 10 frames
//This will need to be called once at the start as well.
void reset()
{
count = 0;
time = getTime();
}
void draw()
{
drawframe();
count++;
if (count == sample)
{
fps = count/(getTime()-time);
reset();
}
}
If you don’t take a sample, your results will:
- be counting the fps for the entire program, so eventually, it’ll get
stuck on some number and generally you don’t want to take inital program
delays into account. - will eventually overflow the number count.> On Tue, 2003-07-08 at 16:05, NighTiger wrote:
I don’t understand how can I enable the key repeat usign only SDL api…
http://sdldoc.csn.ul.ie/sdlenablekeyrepeat.php If that doesn’t do it for
you, I don’t know what can.any one can help me?
tnxBob Pendleton
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl
–
±----------------------------------+
- Bob Pendleton: independent writer +
- and programmer. +
- email: Bob at Pendleton.com +
- web: www.GameProgrammer.com +
±----------------------------------+