Archived

This topic is now archived and is closed to further replies.

Roof Top Pew Wee

Going to take the plunge. Converting an engine C++ -> C#

Recommended Posts

A year ago or so, I started hearing a lot about C#. I was immediately scared. Would this mean that I would have to scrap my nice little C++ 2D engine? I was reassured by multiple posts claiming that C++ still has its place and C# is not a replacement. Whew, I could stick to what I was doing. Now, a year later, I keep hearing about C#. My engine, the Flat Red Ball Template, is designed to sacrifice a little bit of performance but make the programmer''s job much easier. It''s claim to fame (well, ok, it''s not famous) is its ease of use and how fast you can make games in it. Hmm, small sacrifice in performance but increase in productivity; Sounds a little bit like C#. So it would only be natural for me to finally switch over. I guess it seems almost inevitable, but I have a few concerns that I would like to see some experienced C#-ers address. 1. What will the learning curve be like? I am quite experienced with C++. Been coding for over 7 years, programming games for 3 years, and have been working on my engine for over a year now. 2. How difficult will it be to convert my engine to C#. I use a LOT of pointers for dynamic arrays and linked lists. My engine is thousands of lines long, and I''d like to avoid rewriting all of that. 3. What does the DX support look like for C#? More specifically, are there docs specifically addressing managed DX coding? What about community support here in the forums? And of course, how difficult is it to code? I am more of a high-level coder myself, so I like to set up my DX stuff and not touch it again, so I am not looking forward to touching DX once again. Thanks for your help, all. --Vic-- The future of 2D game development: Flat Red Ball

Share this post


Link to post
Share on other sites
You shouldn''t have any trouble learning C#. I was a java programmer until I got a job where I have to use C#, and the switch over was very easy. Granted C# is more like java, but going from C++ shouldn''t be a problem if you have a good understaning of OOP.

As for the second and third question, I''m not sure. I don''t really have any experience with C++ or DX. I did hear, but I am unable to confirm it, that setting up DX with C# is easier. Someone correct me if I''m wrong.

Hope this helps

Share this post


Link to post
Share on other sites
I am currently doing something similar (converting a largish project across to C#) So far I have had few problems and yes C# is much quicker to develop in.

The learning curve was not particularly steep really. The help as been pretty good with plenty of examples. Initially I have found that I have been able to program at least as fast as I could have in C++ and my speed increased rapidly.

The only real area that I have concerns with is dealing with the rather large map file that my game uses. Implementing the path finding etc from within C# worries me a bit. I am thinking of using the original code and wrapping it in a COM object and using the interop. From what I have read this should involve few hits on performance as I am doing all the calculation within the COM object and am making (relatively) few calls. This feature is one of the things that makes C# such an attractive option.

I have had a brief look at some examples of Direct draw (all I need for my project) and it looks very simple. If you have the SDK, there are some examples on it. You might be able to get them from the Web. If you don''t have access to them I can probably send them to you (they are very small).

Hope this helps

Share this post


Link to post
Share on other sites
It might be easier to take your experiences and convert a few of those useful functions - but think about creation rather then conversion. C# and C++ are very different and have different performance bottle-necks - and Direct X 9 is a pretty quantium leap from Direct X 7, and a few steps on from 8.

So in your position I would be tempted to gut the engine for parts and start with a fresh mind and cup of coffee. You CAN code with pointers and such in C# - but at least to start with you may want to take advantage of C#s memory management stuff.

SharpDevelop is good if you cannot afford the Microsoft suite.

Share this post


Link to post
Share on other sites
Also, I''m looking on EBay for the software package. I found a package that contains the standard edition. Is this good? Or would I want to go with professional (assumed alternative)? Here''s the link:

http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=3637085416&category=46327#ebayphotohosting

Thanks for the help all.

--Vic--

The future of 2D game development:
Flat Red Ball

Share this post


Link to post
Share on other sites
What are the business needs for switching to C#? Just because it's the latest trend? I've seen soooo much software re-written for no other reason than simply to rewrite it in Java. No new features, no bug fixes, just new technology. Sorry, but that seems like a colossal waste of time, effort, and money to me. Why not just write a thin C# veneer over your *already working* engine if you want to access it from C# code?

Another thing to consider - are there platforms that you may target in the future that don't run .NET? Cell phones? PDA's? Consoles? If you're doing 2D developement, seems that these could all be viable platforms. If .NET doesn't run on them, will you have to port your engine again?

EDIT: Sorry - Just re-read the original post and noticed the line about not wanting to rewrite the entire engine. I concur with that approach. Keep what works and write a C# interface - that would be my advice.

--
Dave Mikesell Software & Consulting

[edited by - dmikesell on November 18, 2003 9:19:35 AM]

Share this post


Link to post
Share on other sites
Well, to start off, this isn''t a business. It''s a hobby. And the need is the productivity gain from switching. So again, no waste of money

Currently my engine isn''t the moste efficient and it is higly platform dependent (needs DX). There is no way my stuff could run on cell phones, pdas, or consoles. I take full liberty in exploiting all of the HW acceleration and processing power of today''s computers. Again, it''s not made to be a sleek engine, but rather a breeze to program with. I will be the main user of the engine, so it is highly unlikely that I won''t have the setup required to run the engine I build


--Vic--

The future of 2D game development:
Flat Red Ball

Share this post


Link to post
Share on other sites
Sorry if I came off as preachy. I work in IT, and am growing sensitive to the perceived need in my field to always stay on the "bleeding edge" of technology. Seems we are always re-writing stuff that's not very old (and works!) to take advantage of the latest technological "silver bullet". Stuff that adds no value for the customer but is The Latest Thing (tm), so off we go.

I almost dread when my colleagues return from conferences (e.g. Java One), chock full of buzzwords and visions of rewriting healthy, functioning software.

So okay.

--
Dave Mikesell Software & Consulting

[edited by - dmikesell on November 18, 2003 2:28:54 PM]

Share this post


Link to post
Share on other sites
I totally understand, and I myself am much like you, which is why I hesitated on the switch for over a year. I much like C++, and wouldn''t mind sticking to it. But then again, I was so happy I switched to DX8 from DX7, or more specifically from DDraw to D3D. Made my engine a million times faster and capable.

So I guess I''m just listening to some buddies of mine that are pretty adept programmers when they say that I will see great improvements in programming speed. Hope they''re right.

--Vic--

The future of 2D game development:
Flat Red Ball

Share this post


Link to post
Share on other sites
Perhaps you should compare and contrast a similar conversion...
Ogre (C++) to Axiom (C#). Note that Ogre/Axiom essentially only deals with 3-dimensional rendering and not other aspects of an ''engine''. Also of note would be the relative age of the projects and amount of work done on each, Ogre has been around much longer and has many more developers, Axiom has the benefit of faster productivity (I''d, guesstimate that given the same C++/C# profeciency you''d likely develop 20%+ faster in C#), but also it has Ogre as a template to work against, obviously saving much design and implementation time, though that would be in line with your current situation.

There''s a lot of FUD and not enough concrete data. Try it out and see. I will say that if you''re developing on Windows, .NET is not going to go away, however, what you will see is a reduction in the amount of unmanaged code. Weigh the pros and cons, try it out, measure it, and see if it meets your needs and goals. Of course going to .NET doesn''t mean that you have to go to C#, you could go with managed C++ or any other .NET language.

Share this post


Link to post
Share on other sites