Click or drag to resize
Ab4d.SharpEngine logo

SharpEngineSceneView Class

SharpEngineSceneView is a control that can show a 3D scene that is defined by the Scene and SceneView objects. See remarks for more info.
Inheritance Hierarchy
SystemObject
  System.Windows.ThreadingDispatcherObject
    System.WindowsDependencyObject
      System.Windows.MediaVisual
        System.WindowsUIElement
          System.WindowsFrameworkElement
            Ab4d.SharpEngine.WpfSharpEngineSceneView

Namespace: Ab4d.SharpEngine.Wpf
Assembly: Ab4d.SharpEngine.Wpf (in Ab4d.SharpEngine.Wpf.dll) Version: 2.0.8956+4c7684e186ca1be74e7a284fbe739d9a1b843d3c
Syntax
C#
public class SharpEngineSceneView : FrameworkElement, 
	ISharpEngineSceneView, IComponentBase

The SharpEngineSceneView type exposes the following members.

Constructors
 NameDescription
Public methodSharpEngineSceneView Creates the SharpEngineSceneView object (PresentationType is set to SharedTexture). This also creates the Scene and SceneView objects. The VulkanDevice is automatically created when this control is loaded. To manually create or set the VulkanDevice, call the Initialize method.
Public methodSharpEngineSceneView(PresentationTypes) Creates the SharpEngineSceneView object and sets the PresentationType property. This also creates the Scene and SceneView objects. The VulkanDevice is automatically created when this control is loaded. To manually create or set the VulkanDevice, call the Initialize method.
Top
Properties
 NameDescription
Public propertyBackgroundColor Gets or sets a background color for SharpEngineSceneView. Default color is Transparent.
Public propertyCreateOptions Gets the EngineCreateOptions that were used to create the VulkanInstance and VulkanDevice.
Protected propertyd3dImageSource 
Public propertyDisableWpfResizingOfRenderedImage Gets or sets a Boolean that specifies if WPF can use linear filtering to resize the rendered image so that it fits the area to a subpixel values. Default value is true which shows a cleared rendered image because the exact same image is shows as rendered by SharpEngine. This property can be set to false to exactly match (to subpixel value) the size of the rendered image and exactly align it to other WPF objects. This may produce more blurred image.
Public propertyDpiScaleX Gets or sets a float that represents a DPI scale factor in X direction: 1 means 96 DPI, 1.5 means 144 DPI, etc. This value is used in line and pixel rendering and scales the line thickness or size of pixels.
Public propertyDpiScaleY Gets or sets a float that represents a DPI scale factor in Y direction: 1 means 96 DPI, 1.5 means 144 DPI, etc. This value is used in line and pixel rendering and scales the line thickness or size of pixels.
Public propertyGpuDevice Gets the graphics device object (VulkanDevice).
Public propertyId Gets a unique id of this resource
Public propertyIsDisposed Gets a Boolean that specifies if this resource has been disposed.
Public propertyIsDisposing Gets a Boolean that specifies if this resource is currently being disposed (the current code is executing inside Dispose method).
Public propertyIsUsingAdditionalDirectX11SharedTexture Gets a Boolean that specified if additional DirectX 11 shared texture needs to be used to copy Vulkan texture to WPF's DirectX 9 texture. This may be needed when using Intel GPU because Intel's Vulkan driver may not allow copying Vulkan texture to DirectX 9 texture.
Public propertyIsUsingSharedTextureForIntegratedIntelGpu This property is used only when integrated Intel graphics card is used. When set to true, then SharedTexture is used. This may require additional DirectX 11 texture (because Intel's Vulkan driver may not allow copying Vulkan texture to DirectX 9 texture) and therefore may have worse performance than using WritableBitmap. When set to false (by default), then WritableBitmap is used. This property can be set before this SharpEngineSceneView is initialized.
Protected propertyoverlayHost Used OverlayHost control (set only when OverlayTexture PresentationType is used)
Public propertyPreferredMultiSampleCount PreferredMultiSampleCount can be set before the SceneView is initialized and defines the multi-sampling count (MSAA) that will be used if supported by the device. After initializing the SceneView, the actually used multi-sampling count is set to the UsedMultiSampleCount property.
Public propertyPresentationType Presentation type defines how the rendered 3D scene will be presented to the platform. Default value is SharedTexture.
Public propertyScene Gets the Scene that defines the 3D objects.
Public propertySceneView Gets the SceneView that renders the Scene to this control.
Public propertyStopRenderingWhenHidden Gets or sets a Boolean that specifies if rendering is stopped when this control is hidden (IsVisible goes to false). Default value is true.
Protected propertyVisualChildrenCount Gets the number of visual child elements within this element.
(Overrides FrameworkElementVisualChildrenCount)
Public propertyWaitForVSync Gets or sets a Boolean that specifies if the SceneView is waiting for a v-sync provided by the surface. This property is used only when OverlayTexture is used as a PresentationType.
Protected propertywriteableBitmap 
Top
Methods
 NameDescription
Protected methodArrangeOverrideArranges and sizes the child Image control.
(Overrides FrameworkElementArrangeOverride(Size))
Public methodDispose Disposes all resources that were created by this SharpEngineSceneView.
Protected methodDispose(Boolean) 
Protected methodFinalize Destructor
(Overrides ObjectFinalize)
Protected methodGetVisualChildReturns the child Image control.
(Overrides FrameworkElementGetVisualChild(Int32))
Public methodInitialize Initialize method initializes the engine by using the CreateOptions from this SharpEngineSceneView.
Public methodInitialize(ActionEngineCreateOptions) Initialize method initializes the engine by using EngineCreateOptions that are defined by the provided configureAction.
Public methodInitialize(EngineCreateOptions) Initialize method initializes the engine by using the specified EngineCreateOptions.
Public methodInitialize(VulkanDevice) Initialize method initializes the engine by using the specified VulkanDevice object.
Protected methodIsDesignTime Returns if the control is running in design time.
Public methodStatic memberIsPresentationTypePossible Returns true when the specified presentationType may be supported by this SharpEngineSceneView control. To check if the presentationType is possible on the current or specific GpuDevice call the IsPresentationTypeSupported(PresentationTypes) or IsPresentationTypeSupported(PresentationTypes, String) or IsPresentationTypeSupported(PresentationTypes, VulkanDevice, String) methods.
Public methodIsPresentationTypeSupported(PresentationTypes) Returns true when the specified presentationType is supported on the current GpuDevice. This method must not be called before the GpuDevice is created (before SharpEngineSceneView is initialized).
Public methodIsPresentationTypeSupported(PresentationTypes, String) Returns true when the specified presentationType is supported on the current GpuDevice. When presentation type is not supported, a string with additional information is set to the additionalInfo parameter. This method must not be called before the GpuDevice is created (before SharpEngineSceneView is initialized).
Public methodIsPresentationTypeSupported(PresentationTypes, VulkanDevice, String) Returns true when the specified presentationType is supported on the specified GpuDevice. When presentation type is not supported, a string with additional information is set to the additionalInfo parameter.
Protected methodMeasureOverride Updates the UIElement.DesiredSize of the child Image control.
(Overrides FrameworkElementMeasureOverride(Size))
Protected methodOnDisposed OnDisposed
Protected methodOnDisposing OnDisposing
Protected methodOnGpuDeviceCreated OnGpuDeviceCreated
Protected methodOnGpuDeviceCreationFailed OnGpuDeviceCreationFailed
Protected methodOnPresentationTypeChanged OnPresentationTypeChanged
Protected methodOnRenderSizeChanged OnRenderSizeChanged
(Overrides FrameworkElementOnRenderSizeChanged(SizeChangedInfo))
Protected methodOnSceneRendered OnSceneRendered
Protected methodOnSceneUpdating OnSceneUpdating
Protected methodOnSceneViewInitialized OnSceneViewInitialized
Protected methodOnViewSizeChanged OnViewSizeChanged
Public methodRenderScene RenderScene renders the scene. The method first calls the SceneUpdating event. If forceRender is false then the scene is rendered only if there are any changes in the Scene or SceneView. If forceUpdate is true then the RenderingLayers are always regenerated (otherwise RenderingLayers are regenerated only when this is required because the changes require that).
Public methodRenderToBitmap(Boolean) RenderToBitmap method renders the current scene to a new WPF's WriteableBitmap. To reuse the WriteableBitmap, call the method that takes the WriteableBitmap by ref. See also the RenderToXXXX methods in the SceneView object.
Public methodRenderToBitmap(WriteableBitmap, Boolean) RenderToBitmap method renders the current scene to the specified WPF's WriteableBitmap. If the WriteableBitmap is null of its size is not the same as the size of the SceneView, then the WriteableBitmap is resized. See also the RenderToXXXX methods in the SceneView object.
Top
Events
 NameDescription
Public eventDisposed Occurs when this instance is fully disposed. The value of the parameter is the same the disposing parameter in the Dispose(bool) method.
Public eventDisposing Occurs when this instance is starting to be disposed. The value of the parameter is the same the disposing parameter in the Dispose(bool) method.
Public eventGpuDeviceCreated Called after the GpuDevice object was created. If device creation has failed, then GpuDeviceCreationFailed event is triggered.
Public eventGpuDeviceCreationFailed Called when the device creation has failed. User can set the IsHandled property to true to prevent showing error text that is shown by SharpEngineSceneView.
Public eventPresentationTypeChanged Called when the selected PresentationType is not supported and was changed to a fallback PresentationType. The event parameter may provide some additional information about the reason for change.
Public eventSceneRendered Called after the scene has been rendered.
Public eventSceneUpdating Called when the scene is being updated and before it is rendered. The event is called at the beginning of the RenderScene(Boolean, Boolean) method. This event can be used to update the animations.
Public eventSceneViewInitialized Called after the SceneView object have been initialized (have a valid view size and the back buffers were created).
Public eventViewSizeChanged Called when the size of the rendering area is changed. The event is also called after the back buffers are initialized for the first time.
Top
Fields
 NameDescription
Public fieldStatic memberBackgroundColorProperty BackgroundColorProperty
Public fieldStatic memberRequiredDeviceExtensionNamesForSharedTexture RequiredDeviceExtensionNames is a static List that contains the Vulkan device extension names that are required to use SharedTexture as presentation type. This list must be set before the VulkanDevice is created.
Protected fieldrootBorder rootBorder defines the Border WPF element that is used to host Image with source set to D3DImage (for shared texture) or to WritableBitmap.
Top
Remarks

SharpEngineSceneView is a control that can show a 3D scene that is defined by the Scene and SceneView objects.

To add SceneNode objects to the Scene add them to the RootNode object. Lights can be added to the Lights collection. Camera can be set to the Camera property.

The SharpEngineSceneView automatically creates a GpuDevice when the control is loaded. To manually create or set the GpuDevice, call the Initialize method. GpuDeviceCreated and GpuDeviceCreationFailed events can be used to be notified when the GpuDevice is created or when the creation failed.

SharpEngineSceneView can use different presentation types that are defined by PresentationType property.

By default, the PresentationType is set to SharedTexture that can combine the rendered 3D scene with other UI controls and can preserve the data for the rendered texture on the graphics card.

When this mode is not supported on the UI framework or operating system, then WriteableBitmap is used. This presentation type is available on all UI frameworks and operating systems. It can still combine the 3D scene with other UI controls, but the rendered texture need to be copied to the main CPU memory to create a WritableBitmap.

The presentation type that provides the best performance is OverlayTexture. The drawback of this mode is that there the 3D scene is always rendered on top of other UI controls. This presentation type is not available on all platforms.

To check if other presentation type is supported, call IsPresentationTypeSupported(PresentationTypes) method. If selected presentation type is not supported, then WriteableBitmap will be used as fallback.

See Also