da Vinci

I am delighted with Windows Presentation Foundation. There are automative layout, animation and so on in there.. Still it's slower then XNA after all. I have to visualize CAD-geometry. I tried to use WPF directly and failed. It was too slow.

I can host an WinForms control and initialize XNA on it. But WindowsFormHost have a lot of problems and doesn't suit at all.

I see another way to solve this problem. I want to extend WPF. For example I would inherit Brush or another class to draw the content myself using XNA. How I can do something like this



Re: Windows Presentation Foundation (WPF) XNA (Managed DirectX) inside WPF

da Vinci

Anyone, give me any idea..



Re: Windows Presentation Foundation (WPF) XNA (Managed DirectX) inside WPF

SerialSeb

Simply put, it cannot be done. WPF is a directX surface, just like XNA, and there is no interop scenarios supported at the moment.

Hosting your XNA design through a HwndSource or an Winforms interop scenario is your only option. What issues do you see with WindowsFormsHost






Re: Windows Presentation Foundation (WPF) XNA (Managed DirectX) inside WPF

da Vinci

 SerialSeb wrote:
Simply put, it cannot be done. WPF is a directX surface, just like XNA, and there is no interop scenarios supported at the moment.

I realized it, I think about something like rendering to texture and linking the result with Brush or something like this... Why not At least I can copy content of the texture (or a surface) to BitmapSource and after that use it as a background, but it's slow (although I didn't try it, I hope there is the best way to do it).

 





Re: Windows Presentation Foundation (WPF) XNA (Managed DirectX) inside WPF

Jordan Parker - MSFT

You can't derive from any of the drawing primitives like Brush. They're all either sealed on have internal base ctors.

True, WPF3D doesn't scale well to huge amounts of data but your scenario might still be possible with some creative thinking. Can you describe how big your scene was and how you were drawing it For example, the Scripps Research Institute is using us to visualize large molecules: http://channel9.msdn.com/Showpost.aspx postid=213957





Re: Windows Presentation Foundation (WPF) XNA (Managed DirectX) inside WPF

Robert Hartley

One of the problems that I've noticed with the WindowsFormsHost is that it can have potentially poor performance when sizing. For example I created following project application:

<Window Loaded="Window_Loaded">
<UniformGrid x:Name="grid">
</UniformGrid>
</Window>

void Window_Loaded(object sender, RoutedEventArgs e)
{
for (int i=0; i<36; i++)
{
WindowsFormsHost host = new WindowsFormsHost();
host.Child = new Control();
grid.Children.Add(host);

}

}

As you can see it's pretty simple. But when you resize the app, it resizes terribly! Now, do the same thing but replace the WindowsFormsHosts with say WPF Rectangles or something, and it resizes beautifully. This performance issue is one reason to steer clear of the WindowsFormsHost...






Re: Windows Presentation Foundation (WPF) XNA (Managed DirectX) inside WPF

SerialSeb

As others have pointed out, it's not doable out of the box, and the way you describe will absolutely run as a dog as you'd end up copying memory from video to system to video again.

I doubt you'll reach the kind of speed you want by using that technique. And if you're dealing with XNA you probably want the power of immediate mode so a retained mode world is not going to give you the best performance.

I'd suggest putting numbers down of the kind of ocmplexity you face and what your performance constraints are, and decide from there.