Tutorials Forums
     Tutorials Videos
        Sign Up Now For FREE
Welcome, Guest
Username Password: Remember me

Increase Performances when Using D3DImage in WPF
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: Increase Performances when Using D3DImage in WPF

Increase Performances when Using D3DImage in WPF 24 Feb 2010 23:04 #281

Hello,

Often when you read articles explaining how to use a D3DImage in your WPF application you use code which directly handle the CompositorTarget.Rendering event by updating the 3D world... This can lead to performance problems.

For example in my application, WPF refresh the display with a FPS of 160 : the handler which recreate the 3D image is then call 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 :
public void createTheRenderingWithCorrectFPS(int whichFPS){
DispatcherTimer _timer = new DispatcherTimer();
_timer.Interval = new TimeSpan(1000 /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...
  • mnjon
  • OFFLINE
  • CE Staff
  • Posts: 78
  • Karma: 40
CodersEngine
  • Page:
  • 1
Moderators: mnjon
Time to create page: 0.26 seconds