Sign in to follow this  
DrEvil

[.net] Tools for a C++ game

Recommended Posts

Suppose you have your game engine written entirely in C++, and running on C++ on the target platforms, such as consoles. Suppose you want to use C# for your tools. It's seems completely impractical to wrap everything to expose to C#, so I'm curious about another alternative. Suppose your engine is message based. It seems to me the better solution would be to do the entire tool GUI in C#, and communicate with the engine(dll) entirely through the messages. My question is, is it difficulty to allow the dll(which uses DX9) access to the C# render windows in the C# application for doing various rendering to different windows.? Basically the C# app tell the engine dll, render to this HWND or whatever? Thanks

Share this post


Link to post
Share on other sites
We're writing all of our tools in c# but have not found a suitable method for linking to unmanaged c++ short of writing managed c++ wrappers. You could write your c++ code in such a way that you could compile it with /clr enabled and having everything exposed to any .NET language. This would take quite a bit of macro magic to work though...

In our engine I've found that writing the wrapper classes is not nearly as difficult or time consuming as you first think it is. For example, all of our input is done through a singleton class, all our device specific classes are hidden. To move to c# all we had to do was write one wrapper for our singleton, and our entire input system was exposed.

Share this post


Link to post
Share on other sites
I'm not real worried about exposing functionality, writing a few wrappers is fine, I'm more wondering about how to let the unmanaged engine(d3d9) render into a C# gui element.

Share this post


Link to post
Share on other sites
The .Net Control class has a Handle property, which is the HWND (window handle) for that control. You might have to set some other properties on your form to disable the default painting procedure, but you ought to be able to render onto it using that handle.

Share this post


Link to post
Share on other sites
You can write a P/Invoke library (.NET) manually or by using SWIG, which would call certain methods and functions in your unmanaged library (your DLL). Here is a good article introducing what you'd be working with.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this