Jump to content
  • Advertisement
Sign in to follow this  
arjansingh00

DirectX C++ Engine and C# WPF Editor/GUI

This topic is 742 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

So I have render engine that I want to make a Level Editor for, the engine is written in C++ and I want the GUI to be in C#. I am aware this can be done using a C++/CLI wrapper. But I want to start off simple with just passing the HWND of the DirectX Engine to a C# Panel to be rendered there, I can implement other functionality later. I am clueless on how to make a start on this project and was wondering if anybody had any working samples I can take a look at to see how this is implemented. Any guidance or advice would also be great! :) I know there are C# DirectX wrappers like SlimDX available but I want the engine to be written in C++. 

Share this post


Link to post
Share on other sites
Advertisement

My advice would actually be not to go this way because of the complexities. Some of the problems you're going to have to solve with a C# editor are:

 

- What represents your objects in your C# editor?

- How are you going to get your editor to tell your C++ runtime what to do?

   - If you do it over the network you're going to have to have some way of packing up data and sending it over and then unpacking it on the other side.

   - If you do it with a C++/CLI you can end up wrapping alot of C++ classes with C++/CLI equivalents leading to duplication of code and a lot of maintenance.

- What do you do if the C++ engine crashes, how does the editor handle this case?

- WPF is not beginner friendly, i personally detested it when i was using it, but this is purely a personal opinion.

- Its more difficult to get fancy editor features like asset previews working, at a later date.

- I've seen projects using this approach get extremely complex.

 

 

I'd like to propose that you do what Unreal does which is to write your editor UI in C++ using your rendering API to draw it. This has the following good and bad points:

 

+ There is no duplication of classes for the interop with C#.

+ There is no need for network communication or data packing and unpacking.

+ If it crashes you're in the same process and can therefore debug it more easily. With the C# approach this can be trickier depending on your setup.

+ No WPF, again personal.

+ You can do all of the fancy editing features you want because you're in full control.

+ It can still be complex but in my experience less so.

 

- Alot of work to write a custom UI solution, will take a little while to see the fruits of your labor. Its totally worth it IMO though.

- Don't have the reliability of established frameworks like .net.

- If it crashes the whole editor goes down but generally you shouldnt be crashing anyways.

 

So in summary I'm personally not an advocate of wrapping C++ libraries for use in C# unless absolutely necessary and having worked on several different types of editors that have done it in various ways, the most flexible and exciting approach is as i've recommended here but it is quite a bit of work up front.

 

Hope that gives you some ideas, 

Edited by Dave

Share this post


Link to post
Share on other sites

Thank you for the reply :)! I was considering doing what Unreal Engine 4 does for it's UI (what you recommended above) they call it 'slate' right? It seems the right way to go for doing something like this, but a few companies I hope to work at in the near future do it through the C++/CLI method (which is a pain in the ass). I don't want to make an entire level editor with all the functionality something like CryEngine or Unreal would have, but just to learn and understand how the C++/CLI approach would work. I really just want to implement something really simple, basically set an engine's HWND (that renders a solid color, nothing to fancy) to a C# Panel. If you could give any guidance, advice or sample code that would help me make a start on the project.

Share this post


Link to post
Share on other sites

You've already started a thread for this: http://www.gamedev.net/topic/679550-how-to-render-my-directx-c-engine-to-a-c-panel/ and this is the second time you've tried to start a duplicate; please don't do that, just use your original thread.

 

It might help if you demonstrated what you've tried already, as generally you're coming off as asking somebody to write the whole thing for you by not showing any of your own work beyond vague assertions that "I've tried that"or "I've done that and it didn't work" or the like. Many people find that attitude off-putting.

Share this post


Link to post
Share on other sites

This topic is 742 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.

Guest
This topic is now closed to further replies.
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!