Sign in to follow this  
Paul C Skertich

Level Editors in C++ or C# - what is your preference?

Recommended Posts

What is your preference when you create a level editor? C++ or C#? I maanged to get a custom managed assembly C++ DLL file to work in C#. It Initialized DirectX Successfully but when I call upon loading the shaders - BOOM huge crater in the road. The custom DIrectX Assembly DLL file works good initializing and rendering blue screen but once attempting to load hlsl file comes into play - it gets crazy. I looked at SharpDX and it looks nice, but I want to learn more about conversion from C++ to C# and what not.

Thanks for the great help everyone. I'm also doing reading in C++ \ CLI book. I haven't programmed in C++ since I was 9 years old. Quick C was the first C Programming language I learned. Before that was qbasic.

Thanks again for responses.

Share this post


Link to post
Share on other sites
Personally I prefer to embed my level editors in the game engine for true WYSIWYG and fast edit and test cycles, so ideally I would use the same language that I am developing my game/engine in.

If you are going with a stand-alone editor, then I would probably prefer C# because the language features typically make working with GUI applications much easier. Although if you are talking about managed C++ vs C#, then the difference is a bit less as Microsoft's Managed C++ has a few of those features as well, but not all.

Share this post


Link to post
Share on other sites
I think the problem has nothing to do with languages or API.
Changing the language won't magically solve a problem that you can't understand. You should dig into your problem without blaming the API.

Share this post


Link to post
Share on other sites
THanks for the replies. From a C++ .NET aspect I was able to get a simple texture cube working. I additionally had to change the managed assembly to CLR from OLDSYNTAX. With C++ .NET I was able to load the shaders and texture successfully. In C# I was having issues knowing how to convert a LPCWSTR to a char *. I looked deep in that matter. However, I'm taking more swings at the problem because I think that should still work in C#. Last note, C++ .NET is just like C# but a bit different I noticed. Like you don't have to place the carets to indicate a handle and it automatically takes the namespaces. Like in C++ I noticed that for a button click it would be System::Object ^ Sender, .... Once I get pass that conversion of LPCWSTR (const wchar_t) to a char* then I'll be good. So thanks for the replies! Hope everyone's having a awesome day!

Share this post


Link to post
Share on other sites
I used to be a proponent of using C# and .NET to build my tools because of the simplicity of the WinForms system. However, once my projects started to get bigger it introduced the really huge pain of having to maintain wrapper code so my C++ code could be used inside a .NET environment.

Since I really didn't want to live with this situation I took the time to properly learn how to work with the Qt library, and I haven't looked back since.
Once you get familiar with how Qt works - like the signal-slot mechanism, MOC and metadata, etc. - it really becomes as easy as developing your GUI applications with winforms. Qt provides an excellent set of tools, and provides the means for integration of these tools with Visual Studio through a plug-in.
Qt is also much much more than just a GUI library, and it is available for all major platforms.

One minor downside is that the Qt library is absolutely massive, and they provide no binary distributions for x64 (on windows at least, not sure about linux) so you have to compile the library yourself, which can take up most of your day depending on your machine.

You'll have to develop a custom widget to get DirectX to play nicely with Qt though, but that shouldn't be too much of a problem

Share this post


Link to post
Share on other sites
I initially wrote my editor using C# WinForms that drilled into my C++ engine. I had a WinForms panel bind an opengl rendering context for drawing - the idea was to have all the heavy lifting be done in C++ while C# would handle the front end. I used SWIG to bind my C++ code to C# wrapper. It took a while to get working properly, but I thought it was a very good solution.

Then I had to actually use the system. Wrapping tons of the C++ engine, was way too much boilerplate code than I wanted to deal with. There wasn't a clear definition between who owned objects (editor or engine)... and things became a headache quickly.

While I still have a codebase based on this architecture, I've now rewritten my own immediate mode GUI and doing everything in a single C++ application. It's a lot less boilerplate and it's a lot easier to manage.

Share this post


Link to post
Share on other sites
I strongly believe that your level editor (or any other graphic tools related to your engine) should use your actual engine.
If it's meant to be used with it, then it should work with it, hence I'd use the same language.

I really don't see the point of changing the language. The only possible reason would be that perhaps GUI's are more manageable in other languages (eg. visual basic).

Now the pros of using the same language & engine are immediately recognizable. There is no porting to be done, and you are strictly building a new application using your engine. You'd only have to work with the application logic instead of redoing a lot of low-level programming. WYSIWYG becomes much easier to implement, and the resulting application should just be logic that assembles pieces of a puzzle together and previews it using your rendering engine. Adding features to your engine, means you are doing it in one place only, which makes extending tools pretty easy.

Seriously though... tools like a level editor for your engine should use your engine. Now more trivial tools such as asset convertors (eg. .obj -> your file format) could be done in whatever language you desire.

Good luck.

Share this post


Link to post
Share on other sites
I agree with you all! Using C# for a C++ Engine - gave me head aches. I noticed alot of conversion process and just plain old sillyness. So, I'm now in the preccess of re-creating the editor in C++ .NET. The only issue I have with C++ is that in visual basic 2010 the automatic syntax doen't pop up like in C#. I'm heading to microsoft website to see if there is a autocomplete for C++ .NET. I could've sworn there was. I do notice the Visual Studio 2012 helps alot with C++ .NET because of the autocomplete.

So, thanks to everyone that posted! I'll let everyone know how the process is coming along in my journal.

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