Games in C# is it even Possible
-
David Kentley wrote:
Possibly because C# has been shown to be about twice as slow as C++?
Shown by who ? C++ programmers who don't know how to use C# ? I write image processing software. I implimented an algorithm in C#, and moved it to C++. It went from 15 seconds to "I gave up after a day". I know C++ better than C#, but I'd just ported the code holus bolus, when I went back and looked at it, I could see why, and I changed the way my algorithm was implimented, and ended up with something slightly faster, as in 12 seconds or something. I still use that C++ code in my C# app, just to save those few seconds, but most of my processing is a lot less intense than that lot was ( HDR image merging ), and it works just fine in C#.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
Christian Graus wrote:
Shown by who ? C++ programmers who don't know how to use C# ?
I think I was basing my "twice as slow" comment on this link that I found a while ago. Judging from the site name I doubt they're biased against C#. In particular the Sieve of Eratosthenes results were interesting (scroll down, the Hello World results are useless and not at all unexpected). BTW, I program in C# and believe that in the vast majority of applications, being twice as slow doesn't matter at all (most programs spend most of their time waiting for the much slower human component). I like C# as a language. But it's not as efficient as C or C++, and by design it can't be. So for something like a modern 3D game, which needs all the performance it can get, C++ is going to be the better choice. As for DirectX only being 4-5% slower when using C#, that's all well and good but considering DirectX spends most of its time in libraries that aren't written in C#, it's not surprising and nor is it very useful. The rest of the app (physics, AI, what have you) will be much slower and significantly so.
-
I have been studying Information Systems programming for two years now, but have always been intrigued by games programming, now there is a campus opening in SA that offers C# 3D Games Programming using Direct X. Now this all sounds very cool since I am a great fan of Java and C# but does anyone know is it possible to create a good game in C# that can compete in the market?
Oliekrokenosterpikkelikkeastrysvoel
Well there is stuff on how to do this, and there is a few c# games written - some of them are even on this site. If you want to have a look at how to do this then perhaps you should try MSDN webcasts or http://www.digipen.edu/main/Webcast Ciao, M.:laugh:
-
Exactly, it's written in C/C++ as a thin layer around the graphics drivers. .NET accessibility is probably just a thin layer around the native DirectX layer, giving the 4-5% performance penalty. It's all the other stuff around the DirectX, where .NET will hurt performance. For instance, handling trees, queues, lists, arrays, will always be faster in native code. Native code doesn't have to go through all the hoops .NET lays out (security, memory management, exception handlers (yes, these are serious performance hoggers - even so in C++ apps), etc). Native apps also have less memory overhead, allowing for less page faults and better cache management which are probably the biggest performance killers. If C#/.NET had been a viable option for games, we would've seen them by now. (No, Tetris doesn't count ;))
Age of Empire!?!
-
I have been studying Information Systems programming for two years now, but have always been intrigued by games programming, now there is a campus opening in SA that offers C# 3D Games Programming using Direct X. Now this all sounds very cool since I am a great fan of Java and C# but does anyone know is it possible to create a good game in C# that can compete in the market?
Oliekrokenosterpikkelikkeastrysvoel
Written in every programming language; including assembly. Give enough engineers enough non-project time and they will code a game.
A man said to the universe: "Sir I exist!" "However," replied the Universe, "The fact has not created in me A sense of obligation." -- Stephen Crane
-
Age of Empire!?!
Does it run well on a $1000 machine? Is it entirely written in .NET? It's hard to verify how much C++/CLI there is in there to speed it up. :)
-
Does it run well on a $1000 machine? Is it entirely written in .NET? It's hard to verify how much C++/CLI there is in there to speed it up. :)
Jörgen Sigvardsson wrote:
much C++/CLI there is in there to speed it up
Obviously not! Are you of these fool who would think .NET a failure until Windows and Office would be entirely managed? When you've got some running C code, keep it! We are not in the Java crowd here...
Jörgen Sigvardsson wrote:
Is it entirely written in .NET?
err.. mistake here. C++/CLI is just the same as C#. only pure C++ could have some sort of advantage. Now I'm not convinced at all by the so-called "overpowering advantage of C++". All tests I have done or seen failed to convince me. But hey, if the competition stick to C++, all the better for me! ;P
-
Jörgen Sigvardsson wrote:
much C++/CLI there is in there to speed it up
Obviously not! Are you of these fool who would think .NET a failure until Windows and Office would be entirely managed? When you've got some running C code, keep it! We are not in the Java crowd here...
Jörgen Sigvardsson wrote:
Is it entirely written in .NET?
err.. mistake here. C++/CLI is just the same as C#. only pure C++ could have some sort of advantage. Now I'm not convinced at all by the so-called "overpowering advantage of C++". All tests I have done or seen failed to convince me. But hey, if the competition stick to C++, all the better for me! ;P
Super Lloyd wrote:
Obviously not! Are you of these fool who would think .NET a failure until Windows and Office would be entirely managed?
Look who's calling names. Last time I checked, Office is not a game. :) And where did I say .NET is a failure? Stop putting words in my mouth...
Super Lloyd wrote:
err.. mistake here. C++/CLI is just the same as C#. only pure C++ could have some sort of advantage.
If I'm not mistaken, you can mix native and CLI as you go in C++/CLI. There's a reason why they didn't ditch C++ alltogether. My theory is that "it's the perfect legacy glue" is partly a "marketing" reason. Real time apps (meaning apps which cannot afford which require minimal response time) are still in need of native code, and Microsoft knows this.
-
Christian Graus wrote:
Shown by who ? C++ programmers who don't know how to use C# ?
I think I was basing my "twice as slow" comment on this link that I found a while ago. Judging from the site name I doubt they're biased against C#. In particular the Sieve of Eratosthenes results were interesting (scroll down, the Hello World results are useless and not at all unexpected). BTW, I program in C# and believe that in the vast majority of applications, being twice as slow doesn't matter at all (most programs spend most of their time waiting for the much slower human component). I like C# as a language. But it's not as efficient as C or C++, and by design it can't be. So for something like a modern 3D game, which needs all the performance it can get, C++ is going to be the better choice. As for DirectX only being 4-5% slower when using C#, that's all well and good but considering DirectX spends most of its time in libraries that aren't written in C#, it's not surprising and nor is it very useful. The rest of the app (physics, AI, what have you) will be much slower and significantly so.
mmhh??? where does those results comes from? I have .NET 2 and gcc 3.4.4 I compiled like this: CPP> gcc -O3 -o sieve2.exe sieve.cpp -lstdc++ C#> csc /o+ /nologo /out:sieve.exe Sieve.cs I got: C# 10000 Milliseconds = 1156 C++ 10000 Milliseconds = 1313 Haheum..... what else can I say?
-
mmhh??? where does those results comes from? I have .NET 2 and gcc 3.4.4 I compiled like this: CPP> gcc -O3 -o sieve2.exe sieve.cpp -lstdc++ C#> csc /o+ /nologo /out:sieve.exe Sieve.cs I got: C# 10000 Milliseconds = 1156 C++ 10000 Milliseconds = 1313 Haheum..... what else can I say?
GCC isn't the most optimised compiler out there. If you get comparable results with the Intel or Microsoft compilers I'd be very surprised!
Anna :rose: Currently working mostly on: Visual Lint :cool: Anna's Place | Tears and Laughter "Be yourself - not what others think you should be" - Marcia Graesch "Anna's just a sexy-looking lesbian tart" - A friend, trying to wind me up. It didn't work.
-
Super Lloyd wrote:
Obviously not! Are you of these fool who would think .NET a failure until Windows and Office would be entirely managed?
Look who's calling names. Last time I checked, Office is not a game. :) And where did I say .NET is a failure? Stop putting words in my mouth...
Super Lloyd wrote:
err.. mistake here. C++/CLI is just the same as C#. only pure C++ could have some sort of advantage.
If I'm not mistaken, you can mix native and CLI as you go in C++/CLI. There's a reason why they didn't ditch C++ alltogether. My theory is that "it's the perfect legacy glue" is partly a "marketing" reason. Real time apps (meaning apps which cannot afford which require minimal response time) are still in need of native code, and Microsoft knows this.
Jörgen Sigvardsson wrote:
Look who's calling names. Last time I checked, Office is not a game. And where did I say .NET is a failure? Stop putting words in my mouth...
Well, maybe not your words, allright...
Jörgen Sigvardsson wrote:
If I'm not mistaken, you can mix native and CLI as you go in C++/CLI. There's a reason why they didn't ditch C++ alltogether. My theory is that "it's the perfect legacy glue" is partly a "marketing" reason. Real time apps (meaning apps which cannot afford which require minimal response time) are still in need of native code, and Microsoft knows this.
Well I'm using .NET2 and last time I tried (5 minute) a #pragma unmanaged I had some kind of error message and though, ho well! And ManagedC++ is much more fussy..... Anyway there is an unavoidable cost everytime you cross the managed world (yeah, yeah, even with SuppressManagedSecurityAttribute, which don't apply in managed C++ anyway) so it's better do it all managed, I reckon...
-
GCC isn't the most optimised compiler out there. If you get comparable results with the Intel or Microsoft compilers I'd be very surprised!
Anna :rose: Currently working mostly on: Visual Lint :cool: Anna's Place | Tears and Laughter "Be yourself - not what others think you should be" - Marcia Graesch "Anna's just a sexy-looking lesbian tart" - A friend, trying to wind me up. It didn't work.
Well, err... How do I compile?!? I tried cl /O2 sieve.cpp but that produce an unworking executable....
-
Well, err... How do I compile?!? I tried cl /O2 sieve.cpp but that produce an unworking executable....
Super Lloyd wrote:
Well, err... How do I compile?!?
With Intel, you download, pay money for license, install, and compile as usual. :)
_________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
-
GCC isn't the most optimised compiler out there. If you get comparable results with the Intel or Microsoft compilers I'd be very surprised!
Anna :rose: Currently working mostly on: Visual Lint :cool: Anna's Place | Tears and Laughter "Be yourself - not what others think you should be" - Marcia Graesch "Anna's just a sexy-looking lesbian tart" - A friend, trying to wind me up. It didn't work.
cl /O2 /EHsc sieve.cpp compiles cleanly but crash right away....
-
I have been studying Information Systems programming for two years now, but have always been intrigued by games programming, now there is a campus opening in SA that offers C# 3D Games Programming using Direct X. Now this all sounds very cool since I am a great fan of Java and C# but does anyone know is it possible to create a good game in C# that can compete in the market?
Oliekrokenosterpikkelikkeastrysvoel
I think for now its the best environment for tools development and prototyping, but depending on your target specs at least the core graphics engine and potentially the AI will still need to be C++. But in time this may change. Just my point of view.
This statement is false.
-
I have been studying Information Systems programming for two years now, but have always been intrigued by games programming, now there is a campus opening in SA that offers C# 3D Games Programming using Direct X. Now this all sounds very cool since I am a great fan of Java and C# but does anyone know is it possible to create a good game in C# that can compete in the market?
Oliekrokenosterpikkelikkeastrysvoel
Arena Wars[^] is a great game.
Regards Thomas
Disclaimer:
Because of heavy processing requirements, we are currently using some of your unused brain capacity for backup processing. Please ignore any hallucinations, voices or unusual dreams you may experience. Please avoid concentration-intensive tasks until further notice. Thank you. -
Christian Graus wrote:
Shown by who ? C++ programmers who don't know how to use C# ?
I think I was basing my "twice as slow" comment on this link that I found a while ago. Judging from the site name I doubt they're biased against C#. In particular the Sieve of Eratosthenes results were interesting (scroll down, the Hello World results are useless and not at all unexpected). BTW, I program in C# and believe that in the vast majority of applications, being twice as slow doesn't matter at all (most programs spend most of their time waiting for the much slower human component). I like C# as a language. But it's not as efficient as C or C++, and by design it can't be. So for something like a modern 3D game, which needs all the performance it can get, C++ is going to be the better choice. As for DirectX only being 4-5% slower when using C#, that's all well and good but considering DirectX spends most of its time in libraries that aren't written in C#, it's not surprising and nor is it very useful. The rest of the app (physics, AI, what have you) will be much slower and significantly so.
You should replace for (int i = begin; i < end; ++i) with for (int i = begin; i < primes.Length; ++i) And do the same with the inner loop. This is a special construct recognized by the JIT that eliminates array bounds checking. I haven't tested this on .NET 2.0 yet, maybe .NET 2.0 eliminates array bound checking even when not using that fix.
-
Chona1171 wrote:
Mabe I should just stick to Information Systems its what I am good at.
Nah, stretch yourself, become good at other things. Resources such as bitmap handles and database connections can be cleaned up by the IDisposable interface, which just means if an object has a Dispose method, you should call it when you don't want an object anymore. It's a poor mans substitute for deterministic destruction.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
Actually, with a game, you shouldn't dispose resources as soon as you're finished with it. If possible, you should make sure the GC doesn't, either. The idea is to dispose unused resources during a transition (those times when the loading screen pops up) so as to avoid hiccups in the frame rate. It's not all that important when it's just one or two little resources but if you're clearing out game resources in bulk players will notice. Same goes for loading them.
Christopher S. 'coldacid' Charabaruk
-
Christian Graus wrote:
Why ?
Possibly because C# has been shown to be about twice as slow as C++? For a time critical app like a 3D game, that might be important.
Puh-leeze. C# isn't faster or slower than any other language, it's all in how it's used. I developed a little game in 3 days that used only 2D graphics with the help of SDL.NET, and it struggles at 30 FPS. I've seen MDX and Tao.OpenGL that just fly. C# is a perfectly good language for game development, concerns about resource & memory management or no.
Christopher S. 'coldacid' Charabaruk
-
I have been studying Information Systems programming for two years now, but have always been intrigued by games programming, now there is a campus opening in SA that offers C# 3D Games Programming using Direct X. Now this all sounds very cool since I am a great fan of Java and C# but does anyone know is it possible to create a good game in C# that can compete in the market?
Oliekrokenosterpikkelikkeastrysvoel
Try to implement perpixel alpha blending in C# and you'll see why there are no many games written in .net. The answer is - because there are many winapi functions which doesn't have corresponding .net methods. These functions are in most cases so-called low level, such as WINAPI UpdateLayeredWindow function. So, the only way to implement pp alpha blending is to call WINAPI function from C# but does it make any sense? Isn't it better to write the game in C++ and use WINAPI functions directly?
-
I have been studying Information Systems programming for two years now, but have always been intrigued by games programming, now there is a campus opening in SA that offers C# 3D Games Programming using Direct X. Now this all sounds very cool since I am a great fan of Java and C# but does anyone know is it possible to create a good game in C# that can compete in the market?
Oliekrokenosterpikkelikkeastrysvoel