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

I do a bit of research before I write my own 2D (and possibly some kind of 3D) game engine. I made the engine before using C # and XNA, but this time I want to switch to a cross-platform, creating my new C ++ engine using opengl, etc.

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

So, I have several options.

  • Write a CLI engine and shell in C ++
  • Write it all right in C #, not C ++
  • Sign up for C ++ and use Mono to load C # code / assemblies into the engine.
  • No with#
  • ... Maybe something that I have not thought about

I think I need speed for culling, scenario material, matrix calculations, particle systems, etc.

Wat - the pros and cons? What do you suggest?

+7
c # wrapper c ++ - cli game-engine
source share
3 answers

If you want to use cross platform, you cannot use C ++ / CLI. This is not supported on any platform other than Windows.

To say that for the cross platform, I either used C # with Tao , or used C ++ to make the engine a library, and using Platform Invoke to “use” the library from your C # code. This will provide you with the speed and control needed for the core (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 #.

+2
source share

Tao structure is dead, try OpenTK instead

+1
source share

Optimized C ++ code will be much faster (20% in my case for ODE in 32-bit and almost 40% in 64-bit mode, C # is slower in 64-bit than C # in 32-bit, but this another message). I would use heavy math in the C ++ library (integration, differential equations, etc.).

+1
source share

All Articles