Thought for the Dazed

I've had to give up that Distance Learning course as I was having trouble seeing the teacher.

Flickr
www.flickr.com
RobMiles' items Go to RobMiles' photostream
Twitter
C# Yellow Book

Search entire site
« How can I do Data Binding in a Windows Phone Application? | Main | How do I get the IP address of my Windows Phone Emulator? »
Thursday
Apr012010

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

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
All HTML will be escaped. Hyperlinks will be created for URLs automatically.