Write in C++ and expose to C# or write directly in C#?

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.

  • Write the engine and a CLI wrapper in C++
  • Write the whole thing directly in C#, no C++
  • Write in C++ and use Mono to load C# Code / Assemblies into the engine.
  • No C#
  • ... 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?


    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#.


    Tao框架已经死了,请尝试OpenTK


    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).

    链接地址: http://www.djcxy.com/p/47338.html

    上一篇: 如何调试KVO

    下一篇: 用C ++编写并暴露给C#或直接在C#中编写?