Jump to content
  • Advertisement
Sign in to follow this  
frupert

Frames

This topic is 5489 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

How do I detect how many frames per second the game user has got, I noticed that the DirectX examples use it but I dont know how to.

Share this post


Link to post
Share on other sites
Advertisement
There are quite a few ways.

1) calculate the time (in seconds) between each frame, then invert it. Cons-Requires good timer, hard to read when it flickers thew frames so fast.

2)count each frame, then figure out how many have been drawn after each second/tenth of a second/any amount of time. Pros-Easy to use, fairly accurate, less accurate timer is still OK.

I'm sure there are other ways and permutations of these, but these are the two I see most often. I prefer the second, it is easier, and makes much more sense to me. You should try both methods (plus anyone elses suggestions) and figure out which one works best for you.

Share this post


Link to post
Share on other sites
Quote:
Original post by frupert
yeah but how do you find out how many frames you have done so far?


depending on what language you are using, I am sure you have access to some sort of semi decent timer. For the 2nd choice, it should have a latency of no more than around 10 ms to be very accurate. In windows, timeGetTime, GetTickCount, and Environment.GetTickCount (.NET only) should get the job done. Hre is some basic code:


//Run this stuff every frame

if (currentTime - lastTimeCheck >= 1000) // <--assuming the resolution is in ms
{
fps = frames;
frames = 0;
lastTimeCheck = currentTime;
}
frames++;





substitute "currentTime" with whatever function you plan on using (Check google for tutorials on them). Run that bit of code every frame (usually in your game loop, or in the OnPaint override if you are using .NET), and it will store the current Frames per second in the variable fps, which you can do whatever with.

[Edited by - Sr_Guapo on September 8, 2004 5:56:56 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!