Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Increase Performances when Using D3DImage in WPF

0.00/5 (No votes)
18 Sep 2010 1  
Increase Performances when Using D3DImage in WPF
Often when you read articles explaining how to use a D3DImage in your WPF application, you use code which directly handles the CompositorTarget.Rendering event by updating the 3D world... This can lead to performance problems.

For example in my application, WPF refreshes the display with a FPS of 160: the handler which recreates the 3D image is then called 160 times a second. No need to refresh this often.

The solution I used is to create a Timer which will do it at the FPS I want. Let's say 30FPS for example:

C#
public void createTheRenderingWithCorrectFPS(int whichFPS){
   DispatcherTimer _timer = new DispatcherTimer();
   _timer.Interval = TimeSpan.FromMilliseconds(1000d / whichFPS);
   _timer.Start();
   _timer.Tick += new EventHandler(_timer_Tick);
}
void _timer_Tick(object sender, EventArgs e)
{
   //Refresh the 3D scene
}


This enables your application to be really more reactive especially that you need to be on the main thread to update the 3D scene...

Do you know a better way?

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here