473,657 Members | 2,479 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Intergrating C++ into C#. Suggestions? Game Development.

Tom
I have had a reoccurring issue with movement to C# and I was wondering
if any C# gurus can give me any suggestions to this problem. Lately I
have be running into companies with large c++ code repositories that
are interested in leveraging the power of C# development. However
Throwing away the c++ code is just not an option. Most of this is in
regards to the gaming industry where the base C++ code needs to be
run on something like a PlayStation, where you still want to be able
to use your code in Development tools on the PC. As you could imagine
these tools are VERY complex and would greatly benefit from the managed
environment.

If you boil it down here is really the problem. Let's say I have a c++
class Vehicle.

class Vehicle:public GameObject
{
public:
float m_speed;
float m_mass;
PropritaryStrin gType m_name;
}

This class is needed by the system at run time which CANNOT be managed
under any circumstances (I don't foresee a CLR interpreter for the
Playstation or GameCube any time soon). Also a lot of this code needs
to also run in tools like 3dSMax or Maya;

However when I am building content I would like to leverage the things
in C# like the PropertyGrid for automatic UI, and serialization. Not to
mention just getting it into C# so all the PC app development can
happen there.

In the past this was done with a MFC layer built on top of the game
code. In general you would build some proprietary Reflection system
into your c++ libraries and write some wild MFC UI Generator to
generate code. This has many downsides if you could imagine. These UI
generators are usually unstable and not as functional as the C# built
in systems, and usually take months to build and maintain.

One of the main issues that have to be solved is, only 1 point to
maintain the code. This code is being maintained by lot's of people
most of which will never even have VS.NET installed. i.e. maintaining
a parallel class hierarchy in c# is out of the question.

The objects members need to somehow be converted to Properties for
exposure to controls such as the PropertyGrid.

Being able to call methods on these objects is essential too. We are
not just pushing around data there is usually some sort of simulation
going on in these tools.

I have thought of many different ways to do this, but none are really
"Clean", and this stops many developers in this community for adopting
this technology, Imprisoning them in the world of MFC.
Jul 21 '05 #1
11 1922
One of the main issues that have to be solved is, only 1 point to
maintain the code. This code is being maintained by lot's of people
most of which will never even have VS.NET installed. i.e. maintaining
a parallel class hierarchy in c# is out of the question.

The objects members need to somehow be converted to Properties for
exposure to controls such as the PropertyGrid.

Being able to call methods on these objects is essential too. We are
not just pushing around data there is usually some sort of simulation
going on in these tools.

I have thought of many different ways to do this, but none are really
"Clean", and this stops many developers in this community for adopting
this technology, Imprisoning them in the world of MFC.


Have you considered a very thin MC++ wrapper around your C++ code?
Jul 21 '05 #2
Tom
The problem with this is that the C++ is changeing constantly and
rapidly and the people that are doing this work cannot be constanly
haveing to update a parallel class structure. Most of the time they
are not even famliar with PC development, let alone Managed C++.
Basically you are insuring that the MC++ layer will always be broken.

"Daniel O'Connell [C# MVP]" <onyxkirx@--NOSPAM--comcast.net> wrote in message news:<eu******* *******@tk2msft ngp13.phx.gbl>. ..
One of the main issues that have to be solved is, only 1 point to
maintain the code. This code is being maintained by lot's of people
most of which will never even have VS.NET installed. i.e. maintaining
a parallel class hierarchy in c# is out of the question.

The objects members need to somehow be converted to Properties for
exposure to controls such as the PropertyGrid.

Being able to call methods on these objects is essential too. We are
not just pushing around data there is usually some sort of simulation
going on in these tools.

I have thought of many different ways to do this, but none are really
"Clean", and this stops many developers in this community for adopting
this technology, Imprisoning them in the world of MFC.


Have you considered a very thin MC++ wrapper around your C++ code?

Jul 21 '05 #3

"Tom" <ju********@hot mail.com> wrote in message
news:63******** *************** ***@posting.goo gle.com...
The problem with this is that the C++ is changeing constantly and
rapidly and the people that are doing this work cannot be constanly
haveing to update a parallel class structure. Most of the time they
are not even famliar with PC development, let alone Managed C++.
Basically you are insuring that the MC++ layer will always be broken.
Then you are out of luck. C++ classes cannot be imported directly into C#,
you only have pinvoke(importi ng C methods), MC++, and COM interop, none of
which seem to fit your needs. I'm sorry but C++ is your best bet, you can
use MC++ directly, which allows you to use the .NET framework and write
*SOME* of your code in C#, but I suspect the lions share will have to be
written in C++.

"Daniel O'Connell [C# MVP]" <onyxkirx@--NOSPAM--comcast.net> wrote in
message news:<eu******* *******@tk2msft ngp13.phx.gbl>. ..
> One of the main issues that have to be solved is, only 1 point to
> maintain the code. This code is being maintained by lot's of people
> most of which will never even have VS.NET installed. i.e. maintaining
> a parallel class hierarchy in c# is out of the question.
>
> The objects members need to somehow be converted to Properties for
> exposure to controls such as the PropertyGrid.
>
> Being able to call methods on these objects is essential too. We are
> not just pushing around data there is usually some sort of simulation
> going on in these tools.
>
> I have thought of many different ways to do this, but none are really
> "Clean", and this stops many developers in this community for adopting
> this technology, Imprisoning them in the world of MFC.


Have you considered a very thin MC++ wrapper around your C++ code?

Jul 21 '05 #4
Hi Tom,

Did you know that there is a newsgroup
microsoft.publi c.dotnet.langua ges.Csharp

There are a lot active who knows very much about C#.
(Although that is in this newsgroup as well)

Cor

Jul 21 '05 #5
Tom
Actually I posted the question there and got no response. Maybe it is
badly phrased. There is no particular reason to use C# over MC++, I
guest I really mean unmanaged to Managed. Using MC++ is fine but it
doesn't solve anything. I can bring an unmanaged class into a MC++
project and use it. But I would have to build a wrapper to do anything
usefull in .NET with it( i.e.. you can't even do any reflection on a
unmanaged class correct?). This is the step that I can't find a clean
solution for.

I'm seeing this all over the industry right now, and its a shame
because most game companies have just completely dismissed .NET
entirely. I'm pretty sure that even the next XBOX will not support
managed code. Which means that these companies will be doing MFC
development for at least another 5-6 years. Plus it will get harder
because more tools, source examples, 3rd part libs will be managed. Or
worst yet, maybe 3rd parties will also choose not to use .Net because
of this. I am afraid this fracture in the development community will
seriously hurt this industry, which is one the typically need to be on
the forfront of new technologies. Espically rapid development and
reuseability of UI code.

"Cor Ligthert" <no**********@p lanet.nl> wrote in message news:<#f******* ******@tk2msftn gp13.phx.gbl>.. .
Hi Tom,

Did you know that there is a newsgroup
microsoft.publi c.dotnet.langua ges.Csharp

There are a lot active who knows very much about C#.
(Although that is in this newsgroup as well)

Cor

Jul 21 '05 #6
Tom
Actually I posted the question there and got no response. Maybe it is
badly phrased. There is no particular reason to use C# over MC++, I
guest I really mean unmanaged to Managed. Using MC++ is fine but it
doesn't solve anything. I can bring an unmanaged class into a MC++
project and use it. But I would have to build a wrapper to do anything
usefull in .NET with it( i.e.. you can't even do any reflection on a
unmanaged class correct?). This is the step that I can't find a clean
solution for.

I'm seeing this all over the industry right now, and its a shame
because most game companies have just completely dismissed .NET
entirely. I'm pretty sure that even the next XBOX will not support
managed code. Which means that these companies will be doing MFC
development for at least another 5-6 years. Plus it will get harder
because more tools, source examples, 3rd part libs will be managed. Or
worst yet, maybe 3rd parties will also choose not to use .Net because
of this. I am afraid this fracture in the development community will
seriously hurt this industry, which is one the typically need to be on
the forfront of new technologies. Espically rapid development and
reuseability of UI code.

"Cor Ligthert" <no**********@p lanet.nl> wrote in message news:<#f******* ******@tk2msftn gp13.phx.gbl>.. .
Hi Tom,

Did you know that there is a newsgroup
microsoft.publi c.dotnet.langua ges.Csharp

There are a lot active who knows very much about C#.
(Although that is in this newsgroup as well)

Cor

Jul 21 '05 #7

"Tom" <ju********@hot mail.com> wrote in message
news:63******** *************** ***@posting.goo gle.com...
Actually I posted the question there and got no response. Maybe it is
badly phrased. There is no particular reason to use C# over MC++, I
guest I really mean unmanaged to Managed. Using MC++ is fine but it
doesn't solve anything. I can bring an unmanaged class into a MC++
project and use it. But I would have to build a wrapper to do anything
usefull in .NET with it( i.e.. you can't even do any reflection on a
unmanaged class correct?). This is the step that I can't find a clean
solution for.
No, you can't reflect over an unmanaged class. The integration story isn't
great, unfortunatly, for your purposes. However, althought you can't reflect
over classes, C++ class in-memory layouts are defined aren't they(atleast
for the compiler)? Have you considered writing a code generator that parses
your C++ header files and generates wrapper classes in MC++ or C# using
unsafe code? That would allow you to write your dev side tools in managed
code and still use the unmanaged classes as needed. It will take some work
but it should be possible to reuse the generation tool across multiple
projects and may be faster in the long run.
I'm seeing this all over the industry right now, and its a shame
because most game companies have just completely dismissed .NET
entirely. I'm pretty sure that even the next XBOX will not support
managed code. Which means that these companies will be doing MFC
development for at least another 5-6 years. Plus it will get harder
because more tools, source examples, 3rd part libs will be managed. Or
worst yet, maybe 3rd parties will also choose not to use .Net because
of this. I am afraid this fracture in the development community will
seriously hurt this industry, which is one the typically need to be on
the forfront of new technologies. Espically rapid development and
reuseability of UI code.
As it stands, I don't htink managed code fits the platform gaming paradigm
very well. The GC alone causes some weird issues with delays, etc that may
anger gammers that wouldn't aggervate an office user, for example.
"Cor Ligthert" <no**********@p lanet.nl> wrote in message
news:<#f******* ******@tk2msftn gp13.phx.gbl>.. .
Hi Tom,

Did you know that there is a newsgroup
microsoft.publi c.dotnet.langua ges.Csharp

There are a lot active who knows very much about C#.
(Although that is in this newsgroup as well)

Cor

Jul 21 '05 #8
Why don't you compile your C++ as managed C++? This way you don't need
wrappers and you can access your C++ code directly from C#.

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk
"Tom" <ju********@hot mail.com> schrieb im Newsbeitrag
news:63******** *************** ***@posting.goo gle.com...
I have had a reoccurring issue with movement to C# and I was wondering
if any C# gurus can give me any suggestions to this problem. Lately I
have be running into companies with large c++ code repositories that
are interested in leveraging the power of C# development. However
Throwing away the c++ code is just not an option. Most of this is in
regards to the gaming industry where the base C++ code needs to be
run on something like a PlayStation, where you still want to be able
to use your code in Development tools on the PC. As you could imagine
these tools are VERY complex and would greatly benefit from the managed
environment.

If you boil it down here is really the problem. Let's say I have a c++
class Vehicle.

class Vehicle:public GameObject
{
public:
float m_speed;
float m_mass;
PropritaryStrin gType m_name;
}

This class is needed by the system at run time which CANNOT be managed
under any circumstances (I don't foresee a CLR interpreter for the
Playstation or GameCube any time soon). Also a lot of this code needs
to also run in tools like 3dSMax or Maya;

However when I am building content I would like to leverage the things
in C# like the PropertyGrid for automatic UI, and serialization. Not to
mention just getting it into C# so all the PC app development can
happen there.

In the past this was done with a MFC layer built on top of the game
code. In general you would build some proprietary Reflection system
into your c++ libraries and write some wild MFC UI Generator to
generate code. This has many downsides if you could imagine. These UI
generators are usually unstable and not as functional as the C# built
in systems, and usually take months to build and maintain.

One of the main issues that have to be solved is, only 1 point to
maintain the code. This code is being maintained by lot's of people
most of which will never even have VS.NET installed. i.e. maintaining
a parallel class hierarchy in c# is out of the question.

The objects members need to somehow be converted to Properties for
exposure to controls such as the PropertyGrid.

Being able to call methods on these objects is essential too. We are
not just pushing around data there is usually some sort of simulation
going on in these tools.

I have thought of many different ways to do this, but none are really
"Clean", and this stops many developers in this community for adopting
this technology, Imprisoning them in the world of MFC.

Jul 21 '05 #9
Tom
Please explain how this would work. I to have a class become visiable
to a c# application it had to have the GC Keyword on it. If this were
true that would be great because you could then reflect over the non
managed classes.
"cody" <no************ ****@gmx.net> wrote in message news:<u0******* *******@TK2MSFT NGP11.phx.gbl>. ..
Why don't you compile your C++ as managed C++? This way you don't need
wrappers and you can access your C++ code directly from C#.

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk
"Tom" <ju********@hot mail.com> schrieb im Newsbeitrag
news:63******** *************** ***@posting.goo gle.com...
I have had a reoccurring issue with movement to C# and I was wondering
if any C# gurus can give me any suggestions to this problem. Lately I
have be running into companies with large c++ code repositories that
are interested in leveraging the power of C# development. However
Throwing away the c++ code is just not an option. Most of this is in
regards to the gaming industry where the base C++ code needs to be
run on something like a PlayStation, where you still want to be able
to use your code in Development tools on the PC. As you could imagine
these tools are VERY complex and would greatly benefit from the managed
environment.

If you boil it down here is really the problem. Let's say I have a c++
class Vehicle.

class Vehicle:public GameObject
{
public:
float m_speed;
float m_mass;
PropritaryStrin gType m_name;
}

This class is needed by the system at run time which CANNOT be managed
under any circumstances (I don't foresee a CLR interpreter for the
Playstation or GameCube any time soon). Also a lot of this code needs
to also run in tools like 3dSMax or Maya;

However when I am building content I would like to leverage the things
in C# like the PropertyGrid for automatic UI, and serialization. Not to
mention just getting it into C# so all the PC app development can
happen there.

In the past this was done with a MFC layer built on top of the game
code. In general you would build some proprietary Reflection system
into your c++ libraries and write some wild MFC UI Generator to
generate code. This has many downsides if you could imagine. These UI
generators are usually unstable and not as functional as the C# built
in systems, and usually take months to build and maintain.

One of the main issues that have to be solved is, only 1 point to
maintain the code. This code is being maintained by lot's of people
most of which will never even have VS.NET installed. i.e. maintaining
a parallel class hierarchy in c# is out of the question.

The objects members need to somehow be converted to Properties for
exposure to controls such as the PropertyGrid.

Being able to call methods on these objects is essential too. We are
not just pushing around data there is usually some sort of simulation
going on in these tools.

I have thought of many different ways to do this, but none are really
"Clean", and this stops many developers in this community for adopting
this technology, Imprisoning them in the world of MFC.

Jul 21 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

193
9521
by: Michael B. | last post by:
I was just thinking about this, specifically wondering if there's any features that the C specification currently lacks, and which may be included in some future standardization. Of course, I speak only of features in the spirit of C; something like object-orientation, though a nice feature, does not belong in C. Something like being able to #define a #define would be very handy, though, e.g: #define DECLARE_FOO(bar) #define...
2
4456
by: ck388 | last post by:
I was wondering if anyone could answer a couple of questions regarding developing games. I would like to create one for fun on my spare time. I want to know what type of technologies I would have to use. Basically I want to create a sort of board game (for mutual funds). I want to animate things like money (like have a pile of money in the middle of the board, then pay money to each player, where the chips/money would move to the...
1
1343
by: Brian Basquille | last post by:
Hello all. Have been working on the Air Hockey game on and off for a couple of weeks now.. but have had plenty of other assignments to keep me busy along with it. But i would like some suggestions on improving it. It's far from fully working, but some suggestions on the following would be great. Please download it from: http://homepage.eircom.net/~basquilletj/AirHockey.rar.
11
303
by: Tom | last post by:
I have had a reoccurring issue with movement to C# and I was wondering if any C# gurus can give me any suggestions to this problem. Lately I have be running into companies with large c++ code repositories that are interested in leveraging the power of C# development. However Throwing away the c++ code is just not an option. Most of this is in regards to the gaming industry where the base C++ code needs to be run on something like a...
10
3828
by: Max Kubierschky | last post by:
Hello, I'm planning to give a game programming course for kids of mixed age. For this, I am looking for an open source 2D game development kit. I am also willing to participate in the development of the development kit. Features I'd like to see - Possibility to construct simple games via drag and drop without programming - Integration into an IDE - Based on Java or Python
3
1891
by: =?Utf-8?B?cGNnYW1lcg==?= | last post by:
Is VB good for game development? Or is C# or some other language better? I'm a beginner programmer and would like to get into game development. I can't find any decent tutorials, so links would be very helpful. Thanks
0
1467
by: Advertiser for `2D Games Development Central` | last post by:
New to game development? Need a headstart in creating that first game of yours? Want to meet others who share a passion for playing and creating games? Need support, but don't know where go for it? Are you just passionate about games? 2D Game Development Central is a newly founded group on Google Groups that is dedicated to the creation of games, especially with regards to 2D. We offer you the chance to join a community of newcomers just...
6
1806
by: pereges | last post by:
I want to begin by making simple 2D games for Dos. What particular features of C should I look to strengthen ? I am not asking about the graphics bit but in general.
7
2365
by: Benjamin Vigneaux | last post by:
Well, I'm very interested in game development, I'm just starting out though, browsing here and there for tutorials, references, etc.. and learning about the game development industry... What i've realized is that, apparently, most of the games out there are likely to be coded in C++, is this because the language offers features which are better suited for game development? or just because it has been out in market for a longer period of...
0
8421
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8844
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8518
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8621
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7354
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5643
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2743
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1971
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.