Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Console Programming

Options
  • 11-12-2006 11:45pm
    #1
    Closed Accounts Posts: 81 ✭✭


    Hi I'm just wondering what programming language Ps2 and ps3 games are programmed in in general.I know its c# for the xbox but whenever I talk to programmers they just say its an iffy area.Is it an iffy area because of the programming or because of the v expensive dev kits?


Comments

  • Registered Users Posts: 1,481 ✭✭✭satchmo


    Both PS3 and 360 primarily use C++. C# isn't used on the 360, I don't know about the original Xbox but I also doubt it. There might well be a C# compiler for one or both xboxes, but C++ is the language of choice for consoles for performance reasons. C# is more of a tools language.

    As for graphics, the xbox and the 360 use Direct3D. The PS2 used a vector-based microcode called VU (not much fun to program), while the PS3 uses a subset of OpenGL called PSGL, or a lower-level library called libGCM.


  • Closed Accounts Posts: 25,848 ✭✭✭✭Zombrex


    Shoot-a wrote:
    Hi I'm just wondering what programming language Ps2 and ps3 games are programmed in in general.I know its c# for the xbox but whenever I talk to programmers they just say its an iffy area.Is it an iffy area because of the programming or because of the v expensive dev kits?

    A console is just a computer, so technically you can use any language that you have a compiler for.

    But nearly all PS2, PS3, Windows and Xbox 360 games would be programmed in C++, because it is fast and a lot of programmers would be experience in it.

    Microsoft have just launched the XNA Development platform for Windows and Xbox 360 which allows hobby and amature programmers to write games for the Xbox 360. This uses C#, probably because Microsoft are trying to get everyone to use C# (it is their language after all).

    C# is like Java, it is compiled down to a byte code form, but this is not the same as machine specific machine code, so it has to be interpreted by a small program called the virtual machine, that runs on the computer and turns the byte code instructions into specific instructions on the CPU. There are a few advantages to doing this, but this makes it a little slower than using C++ which is compiled to pure CPU machine code.

    You can actually do this with C++ as well in Visual Studio. Microsoft call it Managed C++. But this still has the speed issue the same as C#, so if you are going to write a program that is compiled down to byte code you might as well use C#, since it has some nice features.

    I doubt C# will be used by professional Xbox 360 developers any time soon, as they would want to squeeze the best performance out of the machine. But a professional development system for the Xbox 360, which would include all the C++ code for accessing the graphics systems and stuff, costs tens of thousands of euro, and you then need a licence from microsoft to publish your game.

    So this is far out of reach for hobby or independent game developers. Which is where the XNA project comes in.

    Besides for a hobby programmer making a game on their own C# would probably be grand for what they want to do. The Xbox 360 is a very fast system, if you are just throwing up a simple platform game (like Super Mario on the DS), or something that Xbox 360 would be more than capable of running that at a fast speed even if it was written in C#.

    See my thread for info on the XNA Development platform.


  • Closed Accounts Posts: 4,943 ✭✭✭Mutant_Fruit


    But nearly all PS2, PS3, Windows and Xbox 360 games would be programmed in C++, because it is fast and a lot of programmers would be experience in it.
    Factor in that development time in C# would be less than development time in C++ (assuming you're equally proficient in both), possibly by a considerable margin. With the extra time you have left over from developing in C# you could perform a few more optimisations than you usually would have to.

    I think the performance loss is approximately 10%* (depending on the actual game used) if you use a c# as opposed to c++, so it's not that considerable. 27fps isn't that different to 30fps. 54fps is definitely as playable as 60fps.


    *number taken from a benchmark i saw before of two different game engines, one in C# one in c++. IIRC the C# enging was a port of the c++ one. I'll try to hunt out the benchmark.

    EDIT: Another popular approach (used in second life) is to use C++ for the rendering and textures and all that, for maximum speed, and then use C# for game logic because it's faster to develop in c#.


    EDIT2: Bing: http://www.mmoroundtable.com/forums/viewtopic.php?t=7


  • Registered Users Posts: 1,481 ✭✭✭satchmo


    But unfortunately more time doesnt necessarily equal more optimizations. Sometimes the code is as fast as it's going to get, but the amount of data being processed means that the more overhead introduced by extra layers on the implementation side, the slower the processing is going to be. These are the areas where it pays to get as low-level as possible, which mean C++.

    Besides, for cross-platform developments it just doesn't make sense to develop portions of the Xbox version using C# when you're going to have to develop the same portions on the PS3 version with C++ anyway. Any development time gained by using C# is going to be lost by having to port that code to C++, not to mention the extra time added for maintaining two different code bases along with the bugs that could be introduced by having two different implementations of the same functionality. Overall it just makes sense to use C++ for everything.


  • Closed Accounts Posts: 4,943 ✭✭✭Mutant_Fruit


    satchmo wrote:
    But unfortunately more time doesnt necessarily equal more optimizations. Sometimes the code is as fast as it's going to get, but the amount of data being processed means that the more overhead introduced by extra layers on the implementation side, the slower the processing is going to be. These are the areas where it pays to get as low-level as possible, which mean C++.
    Aye, that's true. But if you develop your game with a 3-4 weeks extra to spare, then you can definately start doing more optimisations then you would previously have had time for. But there's no guarantee that you'll be able to make it appreciably faster.
    Besides, for cross-platform developments it just doesn't make sense to develop portions of the Xbox version using C# when you're going to have to develop the same portions on the PS3 version with C++ anyway. Any development time gained by using C# is going to be lost by having to port that code to C++, not to mention the extra time added for maintaining two different code bases along with the bugs that could be introduced by having two different implementations of the same functionality. Overall it just makes sense to use C++ for everything.
    It depends really on what your target audience is. If you go the XNA route, you've just developed one codebase that runs on Xbox and on the PC. Isn't that nifty, that's a lot more market coverage for less effort than doing a pure C++ version. Then there's the possibility of creating a very minimal linux distro and bundling Mono + XNA with your game. Then you can run your XNA based game on your PS3 with a (probably) small performance hit for running linux underneath it all. Since the PS3 supports linux out of box, then it shouldn't take much effort to make a minimal version that has all the features you need with no extra crap.


  • Advertisement
  • Registered Users Posts: 1,481 ✭✭✭satchmo


    If you're a hobbyist looking to develop for both Xbox and PC, then C# makes sense alright since it can be used for both and is easier than C++ to get up and running fast... but then again you really don't have any choice because if you want to develop for Xbox at all then you have to use C# and XNA.

    But whatever about the overhead of running a game through the multiple levels that would be required to get an XNA app running on linux and on a PS3, there's no way of accessing the SPUs and so you lose a hell of a lot of the processing power available to the PS3. And there's also the fact that the RSX needs a lot of love and attention to get it running at a decent speed, so simply doing some sort of automatic layering from Direct3D to PSGL or libGCM (which would be very hard by itself) is going to end up with severely sub-par rendering speed. That would be if PS3 linux had access to the graphics hardware in the first place, which it doesn't! So you're limited to software 3D acceleration, which might be an option if you could use a few SPUs for rendering, but...


  • Closed Accounts Posts: 81 ✭✭Shoot-a


    Cool thanks everyone for that info.Well I'm just beginning c++ and i'm only at the very basics (overviewing c quickly) and I was wondering if there are any books or websites that anyone would recommend?I intend to use it for game programming.Probably pc game programming at first;popcap style games not 3d at moment.


  • Closed Accounts Posts: 4,943 ✭✭✭Mutant_Fruit


    http://www.taoframework.com/Mono.Xna

    That might be of interest to someone. If anyone is interested i coding away at a cross platform XNA implementation, give me a PM and i can get ye reading the intro document and hacking away at some code.


  • Moderators, Society & Culture Moderators Posts: 9,689 Mod ✭✭✭✭stevenmu


    Linux on the PS3 can access the SPEs, but to do so you'd really want to be writing code specifically for IBMs Cell SDK. It may be possible to do that with C#/Mono but it won't be cross-platform, and would probably be a lot of hassle doing so.


  • Registered Users Posts: 1,481 ✭✭✭satchmo


    Oh of course they can be accessed if you're writing a native app, my point is that it won't be possible to write an XNA app and just have it automagically work without modification.


  • Advertisement
  • Registered Users Posts: 872 ✭✭✭grahamor


    Shoot-a wrote:
    are any books or websites that anyone would recommend?

    3D Buzz is a great resource for 3D and programming, they offer C++ and openGL video tutorials


  • Registered Users Posts: 1,481 ✭✭✭satchmo


    I've found both the CPlusPlus.com and CProgramming.com tutorials to be comprehensive and also easy to follow. Start at the beginning and then work your way through to the end... if you don't understand something at first then don't worry about it to much, just continue to the next topic and return to it when you're more comfortable with the things you do understand.

    Don't bother starting with C and then progressing to C++; start with C++ directly. Otherwise you start picking up bad programming habits and hacking C++ in a C-way. It'll still work, it just won't be pretty and might confuse you.


  • Closed Accounts Posts: 4,943 ✭✭✭Mutant_Fruit


    satchmo wrote:
    Oh of course they can be accessed if you're writing a native app, my point is that it won't be possible to write an XNA app and just have it automagically work without modification.
    But that's the whole point behind XNA. You write your app once and it runs everywhere without modification. The problem is in making the framework support the hardware. The framework is a layer of abstraction over the hardware in order to allow this to work. You write your application once and you make your application compatible with the framework. Then the framework will do all the hard work of making your app then run on whatever hardware. Be it a pentium, a cell processor or your mobile phone.

    I forsee a day (maybe 2 years time) when i'll be able to boot up an XBox (or whatever) and play a game i wrote on my pc a few hours earlier. Then i could pop it on my memory stick and cart it over to my friends XBox 360 where we'll load up a save game and continue on.


  • Registered Users Posts: 1,481 ✭✭✭satchmo


    I was talking about an XNA app running on some combination of abstraction layers that allowed it to run on PS3 linux; it may work, but it won't be able to use the SPUs.


Advertisement