Ab3d.DXEngine Users Guide



This overview shows some basic information about using DXViewportView and describes its main properties.

3D scene in WPF application is shown inside a DXViewportView object. The DXViewportView object represents a DirectX view of the Viewport3D object.


When DXViewportView is defined in XAML, the Viewport3D is set as content of DXViewportView object. For example:

<dxControls:DXViewportView PresentationType="DirectXImage">
        <visuals:BoxVisual3D CenterPosition="30 10 30" Size="20 20 20" Material="Blue" />
                <GeometryModel3D ...

The content defined in XAML is actually set to the DXViewportView's Viewport3D property. This is seen when DXViewportView is defined in code. For example:

    var wpfViewport3D = new Viewport3D();
    var dxViewportView = new DXViewportView();
    dxViewportView.Viewport3D = wpfViewport3D;


PresentationType property defines how the rendered scene is shown in WPF application (or how the scene is composed with other layout elements). The property can be set to one of the two possible values: DirectXImage and DirectXOverlay.

When PresentationType is set to DirectXOverlay, then DXViewportView shows the 3D scene in a similar way as 3D games show their 3D graphics to the screen. In this mode the DXViewportView uses the so called SwapChain that is connected to its own part of the screen (its own hWnd) and contains two buffers - one front buffer that is visible to the screen and one back buffer that is used to render the scene to. When the rendering to the back buffer is completed, a Present method on SwapChain is called and the buffers are switched. This shows the newly rendered scene. Using the SwapChain is the most usual way of rendering 3D graphics with DirectX. This way of rendering provides the best performance. Also most of the graphics debugging tools like Visual Studio Graphics Debugger and NSight work only in this rendering mode. But a big disadvantage of this mode is that the area that displays the 3D graphics cannot be used by any other content - it is not possible to render any WPF or WinForms control over the 3D content.

Therefore DXViewportView also supports the DirectXImage presentation type. In this mode, DXEngine renders the 3D scene into a special buffer (texture) on the graphics card. This buffer is then used by WPF's D3DImage control that can be composed with other WPF elements just as a standard Image element. In this case other WPF controls can be drawn over 3D rendered scene. Also the scene can have transparent background so WPF objects behind the 3D scene can be visible (this is not possible when using SwapChain). The special buffer is initialized in such a way that it can be shared between DirectX 11 (rendered) and DirectX 9 (used by WPF) so that the buffer can stay in the graphics card's memory. A disadvantage of this rendering mode is that the performance of it is slightly worse than when using DirectXOverlay (but usually this is not noticeable). Another disadvantage is that graphics debugging tools usually cannot work in this mode.

DirectXImage is also used as the default value for PresentationType property.

You can read more about using PresentationType in its PresentationType reference section.


BackgroundColor defines a WPF Color that is used to paint the background of the 3D scene. By default its value is set to Colors.Transparent. This means that the actual background of the 3D scene will be defined by the WPF elements defined behind the DXViewportView element. But note that this will only work when PresentationType is set to DirectXImage. When PresentationType is set to DirectXOverlay, the WPF elements behind DXViewportView cannot be seen and this will make the background black instead of transparent.

To see how to define what type of rendering (hardware accelerated, software, WPF 3D), which graphics adapter (graphics card) and what quality settings will be used by DXEngine see the DXEngine Initialization section.