fps calculation: where to set starting and end point

Started by
5 comments, last by walantis 22 years, 5 months ago
hello, i know how to calculate the fps in my mainloop...but i don''t know where to place the starting and the end points to get the time. at the moment i store the time before clearing and after blitting my buffer. thus, my fps is very low ( <= 19 fps ). i tested this in software, ie no hardware acceleration apis etc. example: for (; { gettime(t1) clear() events() blit() gettime(t2) fps = 1.0 / (t2 - t1) } did i misunderstand something ? please help me, thanks
Advertisement
Yes, you have it in the right place, and the 19FPS doesn''t come from the gettime() functions, but it''s your other game related code, so go check that out.
There''s also another method of calculating the FPS. I don''t know what you''re exactly programming with, but I assume that your compiler supports timers/interrupts or threads or something like that.

You need two variables:

int frames;int FPS;


Or something like that...

void actualize_fps(){  FPS=frames;  frames=0;}


The function needs to be called automatically every second.
Everytime you call the -Routine, increment frames by one.
Everything you have to do is draw the FPS onto the screen then...

Maybe that helps.

Yours,

Indeterminatus

--si tacuisses, philosophus mansisses--
Indeterminatus--si tacuisses, philosophus mansisses--
Another way of calculating FPS is to precalculate them

For example:

int iFps=100;
“If you try and please everyone, you won’t please anyone.”
quote:
Another way of calculating FPS is to precalculate them

For example:

int iFps=100;


Priceless tip, my engine has been using int iFps = 10000; for a while now... so smooth and silky, you wouldn''t believe your eyes...

------------
- outRider -
It was just an example After all I didnt want his engine to be as good as mine, otherwise I would have said :

int iFPS=100000;
“If you try and please everyone, you won’t please anyone.”
You should only time it AT ONE SPOT if you you want to actually measure the frame-rate - otherwise you''re timing only a portion of the framerate.

while(!exit)
{
timesnap := gettime();
fps = calcframerate(timeprev, timesnap);
timeprev = timesnap;

//Game goes here
}
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara

This topic is closed to new replies.

Advertisement