Managed GUI for DirectX C++ Game Engine?


J

John Hann

Hi,

A friend of mine is in the process of building a 3d game engine using
native DirectX in C++. I would like to contribute to the development of
an editor for this engine, but I would prefer to develop it in C#. We've
discussed the possibility of creating a COM-based interface to the
engine that the editor could use from C#, and I think that would work
well for most tasks.

However, I'm not quite sure how I would go about developing a WinForms
GUI that would include the engine as a native DirectX control. Could
anyone offer some advice on this? We would like to keep the low level
details of rendering, culling strategies, scene graph composition, etc.
in the actual engine, and have the editor simply drive the engine with
high level commands. Any thoughts?

Thanks,
John
 
Ad

Advertisements

N

Nicholas Paldino [.NET/C# MVP]

John,

There are two ways I can think of making this happen. The first is to
expose the engine as an ActiveX control, and then add a reference to it in
your project, creating an ActiveX host and interop wrapper.

The second way is to create a managed wrapper, which exposes a managed
interface which you can just use natively in .NET code.

Hope this helps.
 
J

John Hann

Nicholas,

Thank you for your input, it definitely helps. With the ActiveX/COM
approach, I think you get everything except the ability to display the
output of the engine in the C# interface. I don't know how a C# app
would host an ActiveX control that is rendering to a native DirectX
Surface. Do you know of any techniques for presenting legacy custom VB
controls (say, an editable dataview) in a C# UI? If there are any, I
would think that the integration points would be similar.

One possibility I've considered is implementing a method in the C# GUI
that the engine could call whenever it completes the rendering of a
frame. This could be implemented in a COM-callable wrapper. If the
engine can render to standard memory buffer, that buffer could be passed
to the GUI for rendering via Managed DirectX. I think this *could* work,
but isn't exactly elegant.

Another approach would be to get the C++ engine to write to directly to
a Managed DirectX device declared in the C# UI. I think that Managed
DirectX is simply a C# abstraction layer that interfaces with the native
APIs. If that is true, one would think that you could get a reference to
the native DirectX device and expose it though COM. Your thoughts?
 
Ad

Advertisements

N

Nicholas Paldino [.NET/C# MVP]

John,

Actually, you don't need C#/.NET to do anything. Why not just create an
ActiveX control (which has its own rendering surface) which is a layer on
top of your engine? Then, you import this ActiveX control into your
project, and it will just work.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top