Constant framerate in WPF for game

It is impossible to get a constant framerate in WPF. WPF is based on the idea of dynamic frame rates and this makes it near useless for any game development.

Some related information:

Why is Frame Rate in WPF Irregular and Not Limited To Monitor Refresh?

http://rhnatiuk.wordpress.com/2008/12/21/wpf-video-playback-problems/

As others have pointed out the solution is, unfortunately, not to use WPF for game development.

I have worked with WPF animations extensively and it is an absolute pain to get anything to smoothly animate in WPF (if you do want to do this I've written down a few best practices here).

I am sure there are many other reasons why WPF is not good for game development. One example is that you cannot create a full screen application in WPF as WPF apps are always windowed. This means that you could not change the resolution for your game to make it smooth in full screen which effectively means that you could not create a full screen game in WPF and expect good results.

If you are serious about your game or game development in general and this is not just a prototype or just-for-fun then I recommend that you ditch WPF and use something else, otherwise you just set yourself up for disappointment and sub-par quality.


Even if you don't want to go with XNA for game development consider reading on how time management is done there - fixed frame rate is not necessary equal or required to stable game time. Try to base your physics on game time (which may be the same as real time or computed based on real time delatas - i.e. if you want to have "fast forward" mode or pause the game) instead of frame rate.

Following 2 links discuss "game time", "real time" and related concepts: http://blogs.msdn.com/shawnhar/archive/2007/07/25/understanding-gametime.aspx, http://blogs.msdn.com/shawnhar/archive/2007/11/23/game-timing-in-xna-game-studio-2-0.aspx

Tags:

C#

Wpf

Rendering