Skip to main content

History: Mogre and WPF

Preview of version: 15

WPF


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.

Methods of Combining WPF and Mogre


There are several ways of using WPF and Mogre together. Note that most are in an experimental state.

Mogre In WPF


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


Take a screenshot of individual WPF visuals, and render them as textures onto entities in Ogre or Mogre.

Pros:

  • WPF is only rendered as often as you want, which can help performance.
  • You can use Ogre to create GUIs in 3D space

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.)
  • It is up to you to arrange widgets and program interactivity with WPF elements.
  • No interactive open source implementation is known.

Interaction with Mogre


... how interaction works (Add both ways, which was describes by Hormis) ...

Example projects

See also


Further information


Technical documentation


Also see


GUI alternatives

  • Miyagi - Pure C# GUI system
  • MyGUI - This GUI system has a .NET wrapper, which can be used for Mogre
  • GUI - An overview for Ogre GUI systems

History

Information Version
Sat 19 of May, 2012 01:09 GMT-0000 Meharin Added WPF Drawing Performance link 25
Tue 08 of May, 2012 05:44 GMT-0000 Meharin added link: Rendering a WPF Container to Bitmap 24
Thu 03 of May, 2012 09:09 GMT-0000 Meharin Added link for http://www.thejoyofcode.com/Generating_images_using_WPF_on_the_Server.aspx 23
Tue 01 of May, 2012 23:51 GMT-0000 Meharin 22
Tue 01 of May, 2012 23:45 GMT-0000 Meharin Added heading for WPF perf links, added a link for VS2010 blog 21
Tue 01 of May, 2012 23:29 GMT-0000 Meharin Added WPF Cached Composition link 20
Tue 01 of May, 2012 23:00 GMT-0000 Meharin Edited: rephrasing. Removed a duplicate Con 19
Tue 01 of May, 2012 22:04 GMT-0000 Beauty style changes 18
Tue 01 of May, 2012 21:58 GMT-0000 Beauty added screenshots + table of contents 17
Tue 01 of May, 2012 21:35 GMT-0000 Beauty added links + tiny text additions 16
Tue 01 of May, 2012 19:13 GMT-0000 Meharin Removed a stray url 15
Tue 01 of May, 2012 19:06 GMT-0000 Meharin 14
Tue 01 of May, 2012 19:03 GMT-0000 Meharin Added a link, fixed WPF On Mogre title 13
Tue 01 of May, 2012 19:00 GMT-0000 Meharin Added overlay technique to header 12
Tue 01 of May, 2012 18:58 GMT-0000 Meharin Added WPF D3D guts link 11
Tue 01 of May, 2012 18:55 GMT-0000 Meharin Added links 10
Tue 01 of May, 2012 18:42 GMT-0000 Meharin Moved WPF on Mogre up. More edits. 9
Tue 01 of May, 2012 18:37 GMT-0000 Meharin Editing 8
Tue 01 of May, 2012 18:28 GMT-0000 Meharin Added initial set of main project/article links 7
Tue 01 of May, 2012 18:27 GMT-0000 Meharin Took out links, replaced with a description and initial pros and cons 6
Tue 01 of May, 2012 18:15 GMT-0000 Meharin Initial update: added the main initial links 5
Tue 01 of May, 2012 17:58 GMT-0000 Meharin Added Methods of combining 4
Tue 01 of May, 2012 17:57 GMT-0000 Meharin 3
Tue 01 of May, 2012 17:56 GMT-0000 Meharin Added an initial description of WPF 2
Tue 01 of May, 2012 13:07 GMT-0000 Beauty NEW PAGE 1