How to calculate and print FPS?

Started by
0 comments, last by Wavewash 23 years, 3 months ago
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
Advertisement
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
The last truth is that there is no magic(Feist)

This topic is closed to new replies.

Advertisement