views:

135

answers:

3

Hello!

I am doing a bit of research before I am going to write my own 2D (and maybe some 3D) game engine. I have made an engine before using C# and XNA but I want to go cross platform this time by making my new engine in C++ using opengl etc.

But ... I still want the fast iteration times from C# and have access to the game engine there.

So I have a few options here.

  1. Write the engine and a CLI wrapper in C++
  2. Write the whole thing directly in C#, no C++
  3. Write in C++ and use Mono to load C# Code / Assemblies into the engine.
  4. No C#
  5. ... Probably something I didnt think of yet

I think I do need the speed for culling, scenegraph stuff, Matrix calculations, particle systems etc.

Wat are the Pros and Cons? What do you suggest?

+2  A: 

If you want cross platform, you can't use C++/CLI. This isn't supported on any platforms other than Windows.

That being said, for cross platform, I'd either use C# with Tao, or use C++ to make the engine a library, and the use Platform Invoke to "use" the library from within your C# code. This will provide you the speed and control you need in the core engine (C++), with the flexibility of game design in C#.

This provides a clean, cross platform means of developing a game engine that can be exposed to C#.

Reed Copsey
Hmm Tao is a little stale looking (no updates in 5 years!) and their domain (http://taoframework.com) has been taken over by a squatter... Is it still current or has it fallen out of date?
FrustratedWithFormsDesigner
If you split the engine code into C++, make sure you're not making unnecessarily 'chatty' calls across the the native/managed boundary.
Mark Simpson
@FrustratedWithFormsDesigner: It's in the mono core now, though. Since it's a direct OpenGL wrapper, and very stable, it's still a good option. Otherwise, you can use OpenTK, but that includes other things as well (which may be useful for a game engine).
Reed Copsey
I am really leaning towards writing and engine library using C++ and use Platform Invoke. I will be doing some experiments with P/Invoke first before diving in.Thanks for the suggestions :)
WoutervD
@WoutervD: If you want a C++ engine, and want cross platform, this is the only real option. All C++ calls from C# will need to be done using P/Invoke, since C++/CLI is windows only.
Reed Copsey
A: 

Tao framework is dead, try OpenTK instead

Stefan Ebner
+1  A: 

Optimized C++ code will be significantly faster (20% in my case for ODE's in 32-bit, and almost 40% in 64-bit; C# is slower in 64-bit than C# in 32-bit, but that's another post). I would take advantage of heavy math in a C++ library (integration, differential equations, etc).

Jess