Managed C++

So I understand Managed C# is the primo langauge for Game Studio Express but would it be possible, either when it comes out or eventually, to use Managed C++ with it too?

It really bothers me I'd have use C# over C++ for the Game Studio...

[242 byte] By [Evermind] at [2008-3-3]
# 1
In version 1, we are only supporting C#. Other languages may well be

added later: this very much depends on your feedback so please do let

us know which languages are most important to you.

So what does "only supporting C#" actually mean?

On Windows, the XNA Framework assemblies are just regular managed DLLs,

so you could reference them from a Managed C++ or VB .NET project and

use our API without any trouble.

But if you want to use IDE features like the game component designer or

the content pipeline, those are currently only available inside C#

Express. You could use C# Express to build your game content and then

some other version of Visual Studio to build the code, but that

wouldn't exactly be convenient!

On Xbox, things are more limited. Both Visual Basic and Managed C++

depend on runtime components which we have not yet had time to port to

the Xbox version of CLR, so you cannot use these languages at all to

develop Xbox games.

ShawnHargreaves at 2007-8-30 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 2
I had funny feelings about C# before I used it. When i got into it I found it is much like Java and there was not much to hate. Some people think that if they code XNA in managed c++ it will run faster than c#, I would think it would run the same if they are both runned managed.
aka_Big_Wurm at 2007-8-30 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 3
I'm glad that you're comfortable with C#. You are correct, if the assembly is entirely managed, then managed C++ is no faster than C#.
RobUnoki at 2007-8-30 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 4

I do think that I would prefer coding C# over C++. But there is such a huge code base in C++ so I think that it has to be the second language to be adapted by the XNA Studio.

Is there a C++ to managed C# conversion guide?

Regards

Joachim

exal at 2007-8-30 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 5
Thank you for your reply, your answer was very informative.

By "game content" you're refering to things like Art assets? Can you explain what the game component designer is (and why I may want to use it)?

Personally I would prefer C++, not because of any deep aversion towards C#, but for very practical reasons. Beyond the performance implications my concerns are similar to exal's, in that I have a vast array of different libaries and utilities I've created using C++ in mind and spending the time to port those over to C# would be very detrimental time wise. Porting hundreds of thousands of lines C++ code to C# would be a big pain and would completely turn me away from the prospect of developing for Game Studio. On the other hand, allowing me to do something similar to what vertigo did with the Quake 2 Managed C++ project would be perfectly acceptable.

As far as performance, I would generally prefer the increased efficiency of C++ but obviously I'm not crazy about performance in opposition to a strong feature set (or I'd be asking for C :-). Managed C++ would be perfectly fine in my eyes as long as tools support was geared towards both languages.

Evermind at 2007-8-30 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 6

Yes, by content we mean art assets, but also potentially sounds, physics data, AI information, etc. Basically everything that isn't your code.

The component designer is similar in concept to things like the WinForms or Avalon component support in Visual Studio. It makes it possible to package up reusable code components, which can then be dropped into your project using the VS UI, properties configured in the UI, and VS will generate suitable code to set up each component. Basically a very quick and easy way to get code from different sources set up and ready to work together. We're packaging up the graphics device as a component, which lets you use the VS properties UI to set things like the default resolution, color depth, and fullscreen vs. windowed, and we have demos of many additional components like a framerate display, main menu screen, free look camera, etc.

Regarding performance, I think you'll find C# and Managed C++ to be very similar if not identical.

Point taken about wanting to access existing codebases: this is definately something we will bear in mind for the future.

ShawnHargreaves at 2007-8-30 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 7

What about common open source C++ libraries for collision detection and physics simulation?

I'm developing Bullet Physics Library, targeting improvements over Open Dynamics Engine (ODE) by supporting convex hull and continuous collision detection (time of impact/sweep).

Should we wait until we can have a C# wrapper for those existing C++ libraries? Is there a special repository for shared/common libraries for physics, sound etc?

Erwin Coumans

http://bullet.sourceforge.net

erwincoumans at 2007-8-30 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 8
This answer is different on our two platforms.

On Windows, the best approach is to use Managed C++ to make a managed

wrapper around the existing native C++ code, so you can call that from

your C# game. This is very easy to do:, as the CLR team do a lot of

magic behind the scenes to make it work like you'd expect without any

hassle.

On Xbox, there is currently no way for you to use or call into Managed

C++, so the only option is to rewrite the entire library in C#. That's

not actually as horrific as it may sound: Garage Games did exactly this

for their entire Torque engine and Marble Blast game code, and didn't

find it anywhere near as painful as they were expecting.

We're fully aware that this situation isn't perfect, though. Please

keep the feedback coming if this is an important issue for you - the

more we know about what you guys want, the better a job we can do when

it comes to defining the feature set for version 2!

ShawnHargreaves at 2007-8-30 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 9

Shawn Hargreaves wrote:
On Xbox, there is currently no way for you to use or call into Managed C++, so the only option is to rewrite the entire library in C#. That's not actually as horrific as it may sound: Garage Games did exactly this for their entire Torque engine and Marble Blast game code, and didn't find it anywhere near as painful as they were expecting.

Are there any tools that helps converting a C++ codebase into C#?

Do you have any links/books/recommendations that help converting C++ to C# for developers whose primary focus is not C#? Also, having to deal with an additional codebase adds maintenance :) Is there anyone who autogenerates C++ and C# with high level tools (like C++ autogeneration from UML tools like the roundtrip in Rational Rose)? Perhaps it's not so painful after all, but for SDK's who are still under development, anything that can be autogenerated can free up time that can be spend developing (fixing bugs, adding features). For multiplatform codebases, even autogeneration of projectfiles saves time. For that I'm now using CMake for example.

Thanks,

Erwin

erwincoumans at 2007-8-30 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 10

I'm currently in love with a tool called .NET Reflector: http://www.aisto.com/roeder/dotnet/. If you have a non-obfuscated assembly, this can decompile it into C#, VB, or the old-style (nasty version 1) managed C++ syntax.

One approach would be to compile the existing native code using Managed C++, then use Reflector to decompile it into C#. I doubt this would work quite well enough to be an automatic process, but it would certainly be a great way of seeing what kind of things needed to change and getting used to how C# works.

I actually use Reflector all the time in place of regular documentation, as it's such a powerful and quick way of seeing what's going on inside an assembly!

ShawnHargreaves at 2007-8-30 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 11
Personally I'd rather write in VB and I suspect there are a lot of amateurs out there that would prefer it just because of the simpler syntax.
DodgingRain at 2007-8-30 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 12
There's no reason why you couldn't do this for the basic chunks of code, then convert it to C# using one of the web site converters. It wouldn't be the cleanest nor most complete solution, but it would enable you to see the C# version of what you write in VB. You could also do the reverse - take the code in one of the Starter Kits, translate it into VB, and take a look at it and copy it for your projects.
JimPerry at 2007-8-30 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...