HGE goes WPF!
I’m, currently making small PC game using HGE. It’s a simple game engine, based on DirectX, written in C++ (source code also available). This engine is exactly what I need now: smart and simple.
And right now I decided to make a level editor for my game. And I really DO want to make it in WPF, but I don’t want to double everything from C++ to C#. I came to idea to make a C# wrapper for my game classes, and host entire game including HGE part in a WPF application.
So, first part of it was: how to put HGE in a child window in WPF application. It was quite easy because of good explanation of child-mode work on HGE website, and using some old WPF tricks.
I needed to make 2 things:
1. Create a C++ dll, compiled as managed code (/clr). This library contains a class (I named it as HGEProxy) that initializes and manages HGE. This class is visible for all .Net applications with references to this dll.
2. On WPF side: to create my own subclass for
HwndHost class that initializes HGEProxy instance and manages HGE’s child window. And than host in some UI element inside WPF window.
To make it the example little bit interactive, I added a list of WPF standard colors (taken from properties of
System.Windows.Media.Colors class) and use a selection of this list as a source for some text inside HGE window.