Jump to content
  • Advertisement

Archived

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

walantis

fps calculation: where to set starting and end point

This topic is 6106 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
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.

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

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

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!