I'm trying to display the FPS for a Viewport3D.
Doing some searching, I came across CompositionTarget.Rendering, but this seems to give different results to the FPS displayed in the "WPF Performance suite" tool.
When using CompositionTarget.Rendering, I get a steady 60 fps being displayed until i interact with the viewport camera, (in response to mouse/keyboard events) then the fps shoots up to between 150 and 200 fps, while the "WPF Performance suite" tool still displays a steady 60 fps.
I assume this is because the "WPF Performance suite" tool displays the accurate FPS, ie whenever the WPF team actually call Present on the backbuffer, while the CompositionTarget.Rendering is the fps thats updated internally, but not representative of the real fps.
I'd like to display something more in line with the "WPF Performance suite" tool, how can I achieve this?
Im using CompositionTarget.Rendering as follows -
Viewport3D()
{
CompositionTarget.Rendering += (s, a) =>
{
++m_frames;
};
DispatcherTimer fpsTimer = new DispatcherTimer();
fpsTimer.Interval = TimeSpan.FromSeconds(1);
fpsTimer.Tick += (s, a) =>
{
m_fpsText.Text = string.Format("FPS:{0}", m_frames);
m_frames = 0;
};
fpsTimer.Start();
}