Jump to content
  • Advertisement

Archived

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

DivineLight

Help Showing FPS

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

Please can anyone tell me a way to easily show FPS of my application, i have source code but i can''t understand their code to show FPS, please explain it clearly! Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Yes i checked it but i can''t understand because it updates many things else framerate, and it requires "dxutil.h" when i click Project on Menu then "Add to Project" and then files and then i include "dxutil.cpp & dxutil.h" but when i compile it says FatalError, cannot include file dxutil.h,
what''s this, i have the files even in same directory some times it didn''t find them aslo!

Share this post


Link to post
Share on other sites
Heres what I use, it''s common.


static float Frame = 0.0f;
static float LastTime = 0.0f;
float CurrentTime = GetTickCount() * 0.001f;

++Frame;
if(CurrentTime - LastTime > 1.0f)
{
FPS = Frame / (CurrentTime - LastTime);
LastTime = CurrentTime;
Frame = 0;
}


-UltimaX-

"You wished for a white christmas... Now go shovel your wishes!"

Share this post


Link to post
Share on other sites
All went fine but i how to display the FPS to the screen, when i want to write it using DirectFont object it says cannot conver parameter one from float to char, same is the case with writing it to log!

Is there any function to convert FPS float to a char??

THANKS!

Share this post


Link to post
Share on other sites
Yeah, here you go:


char strFPS[15];
static float Frame = 0.0f;
static float LastTime = 0.0f;
float CurrentTime = GetTickCount() * 0.001f;
//--

++Frame;
if(CurrentTime - LastTime > 1.0f)
{
FPS = Frame / (CurrentTime - LastTime);
LastTime = CurrentTime;
sprintf(strFPS, "FPS: %.02f", FPS);
Frame = 0;
}

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Just use sprintf() to convert from floating to char string. For example, sprintf( szFPS, "FPS: %f", fFPS ). Or make FPS an int and use itoa().

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Dang! Beat me to it. :-)

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!