473,382 Members | 1,635 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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;
PropritaryStringType 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 1898
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**************@tk2msftngp13.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********@hotmail.com> wrote in message
news:63**************************@posting.google.c om...
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(importing 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**************@tk2msftngp13.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.public.dotnet.languages.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**********@planet.nl> wrote in message news:<#f*************@tk2msftngp13.phx.gbl>...
Hi Tom,

Did you know that there is a newsgroup
microsoft.public.dotnet.languages.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**********@planet.nl> wrote in message news:<#f*************@tk2msftngp13.phx.gbl>...
Hi Tom,

Did you know that there is a newsgroup
microsoft.public.dotnet.languages.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********@hotmail.com> wrote in message
news:63**************************@posting.google.c om...
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**********@planet.nl> wrote in message
news:<#f*************@tk2msftngp13.phx.gbl>...
Hi Tom,

Did you know that there is a newsgroup
microsoft.public.dotnet.languages.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********@hotmail.com> schrieb im Newsbeitrag
news:63**************************@posting.google.c om...
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;
PropritaryStringType 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**************@TK2MSFTNGP11.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********@hotmail.com> schrieb im Newsbeitrag
news:63**************************@posting.google.c om...
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;
PropritaryStringType 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
You do not have to deal with unmanaged code - you can simply recompile the
C++ code as Managed C++ code. Maybe you have to make some code changes, but
you should give it a try.

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk
"Tom" <ju********@hotmail.com> schrieb im Newsbeitrag
news:63**************************@posting.google.c om...
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**************@TK2MSFTNGP11.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********@hotmail.com> schrieb im Newsbeitrag
news:63**************************@posting.google.c om...
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;
PropritaryStringType 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 #11
Tom
I have tried this, if you just comile normal C++ code in an assembly
it is not visible to C#. The classes to be GC to be visible. The whole
point is that I can't make code changes like making them GC classes
because then they wouldn't compile on the platform.

"cody" <no****************@gmx.net> wrote in message news:<eI**************@tk2msftngp13.phx.gbl>...
You do not have to deal with unmanaged code - you can simply recompile the
C++ code as Managed C++ code. Maybe you have to make some code changes, but
you should give it a try.

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk
"Tom" <ju********@hotmail.com> schrieb im Newsbeitrag
news:63**************************@posting.google.c om...
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**************@TK2MSFTNGP11.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********@hotmail.com> schrieb im Newsbeitrag
news:63**************************@posting.google.c om...
> 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;
> PropritaryStringType 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 #12

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

Similar topics

193
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...
2
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...
1
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...
11
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...
10
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...
3
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...
0
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?...
6
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
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.