Archived

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

Wavewash

How to calculate and print FPS?

Recommended Posts

I was wondering how a person would go about calculating the FPS and then printing them in a Direct3d application for dx8. My program doesn''t use the class that all the sample programs use, so it makes it difficult for me. I am having a lot of trouble with this. Any help would be appreciated. ~Wave

Share this post


Link to post
Share on other sites
To calculate your framerate you have to count the time that passed while rendering your scene. Just store the current time (TimeGetTime()) at the beginning of each frame and at the end of the frame. Now take the difference. Because the values are so small and change a lot there is another possibilty.
You store your time. Now at the end of the frame you check if there is one second gone since the time you stored your value. If not, just increase a frame counter (just an integer). If there is one second gone just look at your frame counter. Now you have the number of frames drawn in one second. This is your fps.
Now to the drawing problem.
I would suggest using DrawText for debugging issues. I would not recommend using it in the final product(just to slow), but for debug it is ok. You have to create a font handle (look at the help file). And then just call DrawText from your Direct3DDevice.

Yoshi

Share this post


Link to post
Share on other sites