Skip to main content
History: Mogre and WPF
View published page
Source of version: 25
(current)
{maketoc} !WPF [http://en.wikipedia.org/wiki/Windows_Presentation_Foundation|WPF] (Windows Presentation Foundation) is a modern SDK created by Microsoft for building GUIs in Windows. Many powerful Windows applications today, including Visual Studio 2010 and later, are built using WPF. WPF makes it easy to create sophisticated GUI controls that are composed of other controls. It also has support for animation, styling, and data binding. It optionally supports a declarative UI layout through a XML format called XAML. UI toolkits for games are often simpler and less featureful than desktop-grade UI toolkits. Incorporating WPF into a Mogre application allows a developer to have a sophisticated UI and leverage the vast wealth of WPF resources available. __Example screenshoots:__ {DIV()}{IMG(fileId="2128", thumb="n", rel="box[g]", width="250", align="left", stylebox="border")}{IMG}{DIV} {DIV()}{IMG(fileId="2129", thumb="n", rel="box[g]", width="250", align="left", stylebox="border")}{IMG}{DIV} {DIV()}{IMG(fileId="2130", thumb="n", rel="box[g]", width="804", align="left", stylebox="border")}{IMG}{DIV} %clear% %%% !Methods of Combining WPF and Mogre There are several ways of using WPF and Mogre together. Note that most are in an experimental state. Here are the possibilities: !!__Mogre In WPF__ [http://msdn.microsoft.com/en-us/library/system.windows.interop.d3dimage.aspx|D3DImage] is a WPF control that shows a Direct3D texture inside WPF. It can be set to use a texture that Mogre renders to. __Pros:__ * The result is a fully interactive WPF application with all WPF features supported. * The Mogre scene can be partially transparent, with WPF elements behind it. Partially transparent WPF elements can be placed on top of the Mogre scene. __Cons:__ * WPF controls the rendering loop * WPF's rendering loop is locked at Vsync (e.g. 60FPS) Approaches to implementation: * Single vs Double buffering * Timing of Ogre rendering ** CompositionTarget.Rendering event ** DispatcherInactive event ** DispatcherTimer ** Timer ** Loop in separate thread !!__WPF on Mogre__ (Overlay technique) This approach takes two Windows windows: the top is mostly transparent and contains some WPF controls, while the bottom is a typical Mogre window. The positions of the two windows are synced, and input from the user can go to either window. __Pros:__ * Mogre Rendering rate is not constrained to WPF rendering, as it is in the 'Mogre In WPF' approach. __Cons:__ * It can be tricky to cleanly keep two windows in sync, with input working nicely between the two. !!__WPF in Mogre__ Capture a screenshot of individual WPF visuals and render them as textures onto entities in Ogre or Mogre. __Pros:__ * You can position GUI elements in 3D space as Ogre Scene Nodes * You have full control over when WPF is rendered to an Ogre scene, which might facilitate high performance scenarios. __Cons:__ * It is up to you to arrange WPF controls on the screen. (Perhaps this is simpler if you capture an entire WPF window.) * It is up to you to handle input to make the WPF elements interactive. (Not an issue if you only use WPF as a HUD that requires no input.) * No open source implementation is known that provides interactivity. !Interaction with Mogre ... how interaction works (Add both ways, which was describes by Hormis) ... !Example projects * __Mogre In WPF__: ** Article with sample: [http://www.codeproject.com/Articles/29190/Blend-the-OGRE-Graphics-Engine-into-your-WPF-proje|Blend the OGRE Graphics Engine into your WPF projects] ** Project: [https://bitbucket.org/JaredThirsk/mogreinwpf/wiki/Home|MogreInWpf] ** Project: [https://bitbucket.org/Hormis/doublebufferedd3dimage/|Double buffered D3DImage] technique. D3DImage based Mogre and WPF interop at high FPS. * __WPF On Mogre__ (Overlay technique): A WPF window is layered on top of a standard WinForms window. ** Project: [https://bitbucket.org/Hormis/windowsinput/|Windowsinput by Hormis] * __WPF In Mogre__: ** Article: [http://www.grumpydev.com/2009/01/03/taking-wpf-screenshots/|Taking WPF Screenshots] ** Article with sample: [http://www.codeproject.com/Articles/59790/Use-a-screenshot-of-a-WPF-visual-as-a-texture-in-M|Use a screenshot of a WPF visual as a texture in Mogre] ** Article with sample: [http://jmorrill.hjtcentral.com/Home/tabid/428/EntryId/438/How-to-get-access-to-WPF-s-internal-Direct3D-guts.aspx|How to get access to WPF’s internal Direct3D guts] ** Article: [http://www.thejoyofcode.com/Generating_images_using_WPF_on_the_Server.aspx|Generating images using WPF on the Server] ** Article: [http://www.west-wind.com/weblog/posts/2007/Sep/10/Rendering-a-WPF-Container-to-Bitmap|Rendering a WPF Container to Bitmap] !See also __Further information__ Forum threads: * [http://www.ogre3d.org/addonforums/viewtopic.php?f=8&t=14869|Mogre with WPF GUI] * [http://www.ogre3d.org/forums/viewtopic.php?f=11&t=44263|Blending OGRE (via MOGRE) into a WPF application] * [http://www.ogre3d.org/addonforums/viewtopic.php?f=8&t=14094|Ogre with wpf client] * [http://www.ogre3d.org/addonforums/viewtopic.php?f=8&t=13316|Deciding on MOgre ... about WPF, alternative C# engines, etc] __WPF + Direct3D Performance Tips__ * [http://msdn.microsoft.com/en-us/library/cc656910.aspx|Performance Considerations for Direct3D9 and WPF Interoperability] (MSDN) * [http://msdn.microsoft.com/en-us/library/cc656710.aspx|WPF and Direct3D9 Interoperation] (MSDN) __WPF Performance Tips__ * [http://msdn.microsoft.com/en-us/library/aa970683.aspx|Optimizing WPF Application Performance] * [http://blogs.msdn.com/b/visualstudio/archive/2010/03/02/wpf-in-visual-studio-2010-part-2-performance-tuning.aspx|WPF in Visual Studio 2010 – Part 2 : Performance tuning] * [http://blogs.msdn.com/b/llobo/archive/2009/11/10/new-wpf-features-cached-composition.aspx|New WPF Features: Cached Composition] - (Idea to consider: use this approach to capture interactive WPF entities?) * [http://www.kynosarges.de/WpfPerformance.html|WPF Drawing Performance] - Great benchmarks and discussion of pens, brushes, freezable, and antialiasing within WPF * [http://www.jeremiahmorrill.com/2011/02/14/a-critical-deep-dive-into-the-wpf-rendering-system/|A critical deep dive into the WPF rendering system] (This was a great article, but it looks like the domain is gone. If you find a cached version please post it here.) __Other Technical Information__ * [http://www.gamedev.net/topic/325525-howto-lock-texture-created-as-render-target-d3dusage_rendertarget/|Howto lock texture created as render target (D3DUSAGE_RENDERTARGET)?] * [http://www.windows-api.com/microsoft/Win32-DirectX-Graphics/32966299/no-textures-with-d3dpoolmanaged-under-vista.aspx|C++/VB - No textures with D3DPOOL_MANAGED under Vista?] __Also useful__ * [https://bitbucket.org/JaredThirsk/ogre-d3d9ex/wiki/Home|OGRE Direct3D 9Ex plugin] - important for improving rendering performance for the ''Mogre in WPF'' approach. * ((Prototype steps of GUI development)) __GUI alternatives__ * ((Miyagi)) - Pure C# GUI system * ((MyGUI)) - This GUI system has a .NET wrapper, which can be used for Mogre * ((-GUI|GUI)) - An overview for Ogre GUI systems
Search by Tags
Search Wiki by Freetags
Latest Changes
Compiled API Reference
Overlay Editor
Introduction - JaJDoo Shader Guide - Basics
RT Shader System
RapidXML Dotscene Loader
One Function Ogre
One Function Ogre
...more
Search
Find
Online Users
121 online users
OGRE Wiki
Support and community documentation for Ogre3D
Ogre Forums
ogre3d.org
Log in
Username
Password
CapsLock is on.
Remember me (for 1 year)
Log in