简体   繁体   中英

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.

  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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM