Jump to content
  • Advertisement
Sign in to follow this  
salvenger

SDL get FPS (C#)

This topic is 3005 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 abouts would I go to get the fps using SDL?
If you need more information, please do ask.

Thanks in advance.
Salvenger

Share this post


Link to post
Share on other sites
Advertisement
Your FPS is the inverse of the time elapsed between this frame and the last frame. SDL_GetTicks() gives you the current timestamp, in milliseconds. Go from there.

Share this post


Link to post
Share on other sites
Sorry I don't know C# but generally you need to

-choose how often you want to poll fps

-get an initial time variable T0

-increment a frame counter after every render

-assign SDL_GetTicks() to a current time variable t

-check the time passed (t - T0)
if it is greater than the polling time you chose, FPS is just the frames divided by time passed in seconds ( / 1000 because SDL_GetTicks is in ms): that is FPS = frames/((t-T0) / 1000).

-when that is calculated, do whatever you want with your FPS value, set T0 = t and frames = 0

i'm not sure where i got this from, i think it's from a nehe tutorial maybe, i found the same code i'm using in another thread on here

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.

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!