WPF vs XNA for rendering thousands of sprites

I need to display thousands of ellipses connected by lines. What would be the best way (in terms of performance) to make it inside a WPF application. Is WPF canvas painting much worse than XNA painting?

Actually, the hidden question is: is it possible to do some xna rendering inside the WPF host? I saw several examples that used a borderless window border, but no native deviation ...

Thank you Aurelien

+7
c # wpf xna
source share
4 answers

If you do it right, you can get quite high performance in WPF rendering, which has an advantage that you don’t have to take as a result of interacting with WPF-XNA. You can visualize (and animate) a very large number of visual effects if you use low-level WPF rendering APIs such as CompositionTarget.Rendering and DrawingContext . You can also take advantage of the new function Function cached composition in .net 4.0. There are many more, just take this as a starting point.

+2
source share

I successfully “integrated” XNA with WPF by first creating an XNA scene for the WinForms control and then placing that control in WPF using the WindowsFormsHost control .

+2
source share

I just found this article in CodeProject:

We want to integrate our XNA scene into the WPF user interface just like we integrate a canvas or any widget. But the best way to view a 3D scene in XNA is to include it in a window. It is not possible to get a handle to any WPF control, as it can be done using WinForm. The trick then is to rewrite the part of the XNA structure revolving around the Game class. The goal is to inherit the new Game class from Panel (in our case, Canvas) in order to include it in the WPF visual tree. The visual borders of the panel will be the viewing area of ​​the XNA scene. However, we just said that it is not possible to get a visual control descriptor that does not inherit from Window. How do we now show 3D with XNA? We just show a window with no border above the panel. This window will always be on top if the application has focus, and the panel is visible and will be hidden in this case. Similarly, when the panel is not visible, we will stop the activity of the game.

This thread on Microsoft forums discusses this and one poster:

The conclusions then are that you can have XNA rendering in WPF form without any problems, but you should avoid using the Game and GraphicsDeviceManager classes, since the latter needs to run an instance of the game (the constructor is defined as the new GraphicsDeviceManager (game)), and the Game class provides no way to determine the window in which it is displayed.

So, it seems that this is possible, but requires some work on the XNA part of the equation.

+1
source share

Remember, however, that XNA applications will not work on systems without at least a 1.1 shader GPU.

+1
source share

All Articles