Archived

This topic is now archived and is closed to further replies.

fps calculation: where to set starting and end point

This topic is 5886 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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;
[/CODE]

Or something like that...

[CODE]
void actualize_fps()
{
FPS=frames;
frames=0;
}
[/CODE]

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--

Share this post


Link to post
Share on other sites
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 -

Share this post


Link to post
Share on other sites
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
}

Share this post


Link to post
Share on other sites