How do I create a Frame Counter in my Program?
A frame counter will give you a feel for the graphical performance of your program. It simply tells you how many frames per second are being displayed. Creating a frame counter for a Silverlight application is easy, simply add this line to the constructor of your main page class:
Application.Current.Host.Settings.EnableFrameRateCounter = true;
The program will now display a frame counter in the top of the screen.
If you are writing XNA you will need to implement a frame counter of your own. You can use my sample here if you prefer. This creates a simple particle system, you can change the number of particles and watch what happens to the frame counter in the top left hand corner.
Note that the frame counter resets some of the rendering properties when it uses SpriteBatch to draw the text. You might find that it makes your 3D games look wrong if you add it to them. The solution is to make sure that you reset all your render properties before each draw, and not just at the start of the program.
Reader Comments