Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 411
WoutervD Avatar asked Aug 10 '10 19:08

WoutervD


People also ask

Can I convert C++ to C?

It is possible to implement all of the features of ISO Standard C++ by translation to C, and except for exception handling, it typically results in object code with efficiency comparable to that of the code generated by a conventional C++ compiler.

What is extern used for in C?

the extern keyword is used to extend the visibility of variables/functions. Since functions are visible throughout the program by default, the use of extern is not needed in function declarations or definitions. Its use is implicit. When extern is used with a variable, it's only declared, not defined.

What is the input and output in C?

In every C program, three basic functions take place – accepting of data as input, the processing of data, and the generation of output. The acceptance of data refers to input and the presentation of data refers to the output. The C program accepts input from the keyboard and displays output on the screen.


2 Answers

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

like image 133
Reed Copsey Avatar answered Sep 28 '22 18:09

Reed Copsey


Tao framework is dead, try OpenTK instead

like image 23
Stefan Ebner Avatar answered Sep 28 '22 18:09

Stefan Ebner