glateur
19-11-2009 11:34:29
Hi all,
I've been porting my code to WPF (don't ask), and I'd obviously like Mogre to come along. I have a custom OgrePanel class (deriving from System.Windows.Forms.Panel), which is used as a 3D viewing panel and has some tools associated with it.
There seem to be 2 ways to go about this:
1. Host the OgrePanel in a WPF window using a WindowsFormsHost object (in WindowsFormsIntegration.dll).
I have this working, and it appears to be working fine. I should perhaps point out that I was not able to do this in xaml, due to my assembly not being 'strongly named'. I don't really know what that means, but it has to do with the namespaces available to the CLR not being available as X(A)ML namespaces. Anyway, it means you lose the ability to design your window entirely visually (using the Toolbox), which is a pity but not really dramatic in my case.
I'm under the impression that, to compile a strongly named assembly (OgrePanel.dll), all the assemblies it references (this includes Mogre.dll) also have to be strongly named. I think this requires Mogre to be recompiled from source. This is talked about in this post (in a different context, though):
http://www.ogre3d.org/addonforums/viewtopic.php?f=8&t=6518&p=38325&hilit=sign#p38325
It seems like it's quite straightforward to recompile Mogre as a strongly named assembly (especially see the comment made by Marioko in the post above). I've succeeded in compiling Mogre from source (see this post: http://www.ogre3d.org/addonforums/viewtopic.php?f=8&t=11457). If someone (Marioko?) can offer some clear instructions on how to do this, I'm quite willing to give it a try and let you know how that goes. It's quite a lengthy process compiling Mogre from source, so I'd prefer not to have to try 10 times before getting it right.
2. Making a 'true' WPF Mogre control
This is discussed in this entry on codeproject (Mogre 1.4):
http://www.codeproject.com/KB/WPF/OgreInTheWpf.aspx
I can't really follow all the details, but it comes down to having a OgreImage object, based on WPF ImageSource and D3DImage (which appears to suggest it might be limited to DirectX rendering). The core part of this is written in C++, which scared me right off, so I haven't tried this out. Also, the author himself (a good fellow named Leslie Godwin) doesn't seem to be sure this is the 'proper' way of doing this.
So my question would be: what do you guys think is the best way to proceed? I have a working solution, so I could just leave it at that and concentrate on the more important tasks at hand. On the other hand, it seems like A Bad (and Unpractical) Thing to have your WPF application hosting WinForms controls, so eventually something will have to come along to address this issue. Is there any such a thing in any pipeline?
Any ideas, anecdotes or suggestions highly appreciated!
g
I've been porting my code to WPF (don't ask), and I'd obviously like Mogre to come along. I have a custom OgrePanel class (deriving from System.Windows.Forms.Panel), which is used as a 3D viewing panel and has some tools associated with it.
There seem to be 2 ways to go about this:
1. Host the OgrePanel in a WPF window using a WindowsFormsHost object (in WindowsFormsIntegration.dll).
I have this working, and it appears to be working fine. I should perhaps point out that I was not able to do this in xaml, due to my assembly not being 'strongly named'. I don't really know what that means, but it has to do with the namespaces available to the CLR not being available as X(A)ML namespaces. Anyway, it means you lose the ability to design your window entirely visually (using the Toolbox), which is a pity but not really dramatic in my case.
I'm under the impression that, to compile a strongly named assembly (OgrePanel.dll), all the assemblies it references (this includes Mogre.dll) also have to be strongly named. I think this requires Mogre to be recompiled from source. This is talked about in this post (in a different context, though):
http://www.ogre3d.org/addonforums/viewtopic.php?f=8&t=6518&p=38325&hilit=sign#p38325
It seems like it's quite straightforward to recompile Mogre as a strongly named assembly (especially see the comment made by Marioko in the post above). I've succeeded in compiling Mogre from source (see this post: http://www.ogre3d.org/addonforums/viewtopic.php?f=8&t=11457). If someone (Marioko?) can offer some clear instructions on how to do this, I'm quite willing to give it a try and let you know how that goes. It's quite a lengthy process compiling Mogre from source, so I'd prefer not to have to try 10 times before getting it right.
2. Making a 'true' WPF Mogre control
This is discussed in this entry on codeproject (Mogre 1.4):
http://www.codeproject.com/KB/WPF/OgreInTheWpf.aspx
I can't really follow all the details, but it comes down to having a OgreImage object, based on WPF ImageSource and D3DImage (which appears to suggest it might be limited to DirectX rendering). The core part of this is written in C++, which scared me right off, so I haven't tried this out. Also, the author himself (a good fellow named Leslie Godwin) doesn't seem to be sure this is the 'proper' way of doing this.
So my question would be: what do you guys think is the best way to proceed? I have a working solution, so I could just leave it at that and concentrate on the more important tasks at hand. On the other hand, it seems like A Bad (and Unpractical) Thing to have your WPF application hosting WinForms controls, so eventually something will have to come along to address this issue. Is there any such a thing in any pipeline?
Any ideas, anecdotes or suggestions highly appreciated!
g