Use the renderer in different UI technologies - RolandKoenig/SeeingSharp GitHub Wiki

Use the renderer in different UI technologies

Regardless which UI framework you use, you have always specific controls (like SeeingSharpRendererControl in Windows.Forms). All these controls reference to a corresponding RenderLoop object, which is a common abstraction for each view. Most of the synchronization between UI and rendering is done here. One example: If you want to check which object is currently below the curser, you use the method PickObjectAsync of the RenderLoop class. One additional example: You want to update/change the scene or camera which is bound to your view? Use the properties of the RenderLoop for that.

Each view control like SeingSharpRendererControl creates its own corresponding RenderLoop automatically for you. Additionally, by default a new Scene and a new Camera is created per RenderLoop, but you are free to exchange them.

The picture below shows the relationships between the described objects. Additonally, here comes the EngineMainLoop class into view. Normally, you don't have to care about this singleton object. It is the main point where SeeingSharp synchronizes all threads, schedules rendering and so on.

Binding of view specific controls to the rendering engine

Windows.Forms

Here you can simply use the SeeingSharpRendererControl. Drag it onto your UserControl or Form and place it as you like. The control initializes itself automatically when the control is displayed. Ready.. that's it. After done so, you can access/change the Scene and Camera directly on the SeeingSharpRendererControl. Do also look at the RenderLoop property because it contains some additional functionalities like Picking, taking Screenshots and such like.

WPF

Just like the above one exception one thing: You have to use the SeeingSharpRendererElement here, which integrates directly into the rendering process of WPF.

WinRT

You have two options on WinRT to host Seeing# content:

  • Use the SwapChainBackgroundPanel
  • Use the SwapChainPanel

Both are equal to the solutions on WPF/WinRT with some small differences. These panels here do both inherit from Grid, so you can place more child control directly on them. If you use SwapChainBackgroundPanel, then please note that this one can only be on the TopLevel location of your Xaml stack! SwapChainPanel came with Windows 8.1 and removed this restriction. All other things work on WinRT just like on the other platforms.