Help Showing FPS
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!
because as i said the code is weird, i want a new simple code snippet if any sweat person can give me!
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
Check out "CD3DApplication::UpdateStats()" in d3dapp.cpp
--
Simon O''Connor
ex -Creative Asylum
Programmer &
Microsoft MVP
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!
what''s this, i have the files even in same directory some times it didn''t find them aslo!
Heres what I use, it''s common.
-UltimaX-
"You wished for a white christmas... Now go shovel your wishes!"
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!
Is there any function to convert FPS float to a char??
THANKS!
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().
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement