Jump to content
  • Advertisement
Sign in to follow this  
DrEvil

[.net] Tools for a C++ game

This topic is 4583 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!