Help Showing FPS

Started by
17 comments, last by DivineLight 20 years, 9 months ago
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!
>>>Syntax is same, Thinking is Different<<<
Advertisement
HINT: Why don''t you post code that you''d like people to explain.
because as i said the code is weird, i want a new simple code snippet if any sweat person can give me!
>>>Syntax is same, Thinking is Different<<<
There is source code to display the frame rate in the sample framework of the DirectX SDK.

Check out "CD3DApplication::UpdateStats()" in d3dapp.cpp


--
Simon O''Connor
ex -Creative Asylum
Programmer &
Microsoft MVP

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

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!
>>>Syntax is same, Thinking is Different<<<
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!"
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!
>>>Syntax is same, Thinking is Different<<<
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;}
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().
Dang! Beat me to it. :-)

This topic is closed to new replies.

Advertisement