Immediate mode rendering in WPF 🚀

Refers to Eyeshot 10.0.991 and greater.

im.png


The 3D graphics drawing in the Eyeshot native WPF control is not as fast as the Windows Forms one. Basically, we all need to blame Microsoft and their D3DImage WPF control implementation. The main reason behind this issue is the number of additional passes that D3DImage WPF control needs to do to allow composition with the rest of the WPF elements.

A more technical discussion can be found on the threads below:


Today, we can offer a workaround to push the WPF control frame rate to the limit: Immediate mode rendering. It can be controlled using the following property (available only in Eyeshot WPF control):

ViewportLayout.Renderer = rendererType.OpenGL;

or

ViewportLayout.Renderer = rendererType.Direct3D;

Clearly, with WPF immediate mode, you will not be able to combine (overlap or blend) the Eyeshot control with any other WPF control of your application.

 

Current Limitations

  • Drag & drop
  • Dock & undock
  • Context Menu
  • Custom mouse cursors
  • GridSplitter (see CopyAndPaste sample)
  • Missing "Preview" native mouse events (e.g. PreviewMouseDown)

 

Code Fixes

Listed below are some tricks to make your code work also with the Immediate mode rendering.

Replace

RenderContextUtility.ConvertPoint(e.GetPosition(viewportLayout))

with

RenderContextUtility.ConvertPoint(viewportLayout.GetMousePosition(e))

 

Replace

if (e.LeftButton == MouseButtonState.Pressed && e.ClickCount == 2)

with

if (e.ChangedButton == System.Windows.Input.MouseButton.Left && viewportLayout.GetMouseClicks(e) == 2)

 

Replace

viewportLayout.Focus()

with

viewportLayout.SetFocus()

For the context menu, you can define it via XAML and enable it in this way:

using System.Windows.Controls;
using System.Windows.Input;

public class MyModel : devDept.Eyeshot.Model
{                             
    protected override void OnMouseDown(MouseButtonEventArgs e)
    {
        if (e.ChangedButton == System.Windows.Input.MouseButton.Right && ContextMenu != null)
        {
            ContextMenu.Visibility = System.Windows.Visibility.Visible;
            ContextMenu.IsOpen = true;
        }
        else
        {        
            base.OnMouseDown(e);
        }            
    }
}
Was this article helpful?
2 out of 2 found this helpful
Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.