Game porting requirments

Member
Posts: 509
Joined: 2002.05
Post: #1
I want to go 100% cross platform with future games, but I am considering recoding my current game to be cross platform. What I want to know is how much work is going to be involved. I am using cocoa and Open GL with objective-c as a language. I will try to build a running list.

• Replace all NSStrings with char arrays
• Redo file paths from NSBundle to a data folder
• Get rid of any other cocoa references (I didn't use too many of them)
• Get SDL added to the program
• Redo cocoa windows with SDL Windows
• Redo cocoa input with SDL input (would also allow for joysticks later)

These following ones have questions attached
• Get GCC to compile windows code - Can I do this in XCode or will it be easy to set up DevC++ on my PC to do it?


Thanks, I think my next game will be good enough quality to sell equal amounts for the PC and Mac.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
Careful with the strings, make sure you test your game in paths that contain foreign characters.
Quote this message in a reply
Member
Posts: 39
Joined: 2002.04
Post: #3
* Don't forget about byte order issues - for game saves, network messages and such ...
* Make sure that your code really conforms to the language standard or whatever works in multiple compilers if standard support is shaky.
* You might want to look into build tools, so that you can use the same build file to build for multiple platforms e.g. Autotools (to make configure-make-install style make code), SCons ...
* Also consider where game preferences and save files should be stored in the filesystem, this may differ between OSes and depend on if the OS is a single or multiuser OS.
Quote this message in a reply
Member
Posts: 39
Joined: 2002.04
Post: #4
It has also been mentioned on this site, that the default C random function, has poor randomness in Windows - I assume that this only applies if the Microsoft C complier / random lib is used.
Quote this message in a reply
Member
Posts: 509
Joined: 2002.05
Post: #5
Thanks, Byte order should not be a problem. Both compilers I plan on using are GCC so that should help some.
Quote this message in a reply
Nibbie
Posts: 1
Joined: 2010.11
Post: #6
Amen to that decision Jake, it's not hard to build a game 100% cross platform if you have two networked computers, a Mac and a PC (I use VPC, but a real one is "better" for testing).
Quote this message in a reply
Member
Posts: 509
Joined: 2002.05
Post: #7
AHHH! I can't even get a SDL program to run in XCode without references to cocoa with the template. Does anyone have a very bare bones XCode project with only C or maybe C++ that they can email me?
Quote this message in a reply
Moderator
Posts: 608
Joined: 2002.04
Post: #8
Jake Wrote:AHHH! I can't even get a SDL program to run in XCode without references to cocoa with the template. Does anyone have a very bare bones XCode project with only C or maybe C++ that they can email me?
The Mac OS X implementation of SDL uses Cocoa. I'm not sure why that's a big deal, though...
Quote this message in a reply
Moderator
Posts: 771
Joined: 2003.04
Post: #9
Jake Wrote:AHHH! I can't even get a SDL program to run in XCode without references to cocoa with the template. Does anyone have a very bare bones XCode project with only C or maybe C++ that they can email me?

At one point, during the earliest stages of Okugai's development, I wondered how hard would it be to port it to Windows, since I was using cross platform libraries after all: SDL, SDL_image & SDL_mixer.

It took me 20 min. to download the Windows versions of the libraries, install them (basically, put the headers in the right directory and the dll's in the project dir.) and create a simple test project in MS VisualC++.
The actual porting of Okugai took something like 15-25 minutes, most of it involving working around silly behaviors in Microsoft's compiler (16 bit rand(), no "for (int i=0;i<something;i++)", HORRIBLE fscanf, etc.). Oh, and another 5 minutes to download & install updated OpenGL drivers from NVidia's | ATI's site (otherwise you'll get 2FPS and wonder what's going on - I did Wink )

Just ignore the Cocoa file from the Xcode project: make a test SDL project in VC++ or Dev-C++, ("Draw a red triangle" or something like that), once that works, drop all your source files in it, hit build and start fixing/#ifdef-ing as necessary. You'll be surprised how fast you can get your game up & running Smile

Edit: Not a template by any means, but vSpeed uses C++,SDL,SDL_mixer,SDL_image & OpenGL.
Quote this message in a reply
Member
Posts: 184
Joined: 2004.07
Post: #10
PowerMacX Wrote:The actual porting of Okugai took something like 15-25 minutes, most of it involving working around silly behaviors in Microsoft's compiler (16 bit rand(), no "for (int i=0;i<something;i++)", HORRIBLE fscanf, etc.). Oh, and another 5 minutes to download & install updated OpenGL drivers from NVidia's | ATI's site (otherwise you'll get 2FPS and wonder what's going on - I did Wink )

Another subtle point for why porting is a good idea is that you might catch more bugs- between my win and mac builds, I had some bug where I de-allocated memory before I was done with it, which I only caught on one of the platforms. So it's certainly a practice that can make your code more bulletproof as well.
Quote this message in a reply
Member
Posts: 509
Joined: 2002.05
Post: #11
Thanks for the great info, I am going to start fixing up the code in my spare time. I will post any milestones when they come.
Quote this message in a reply
Member
Posts: 509
Joined: 2002.05
Post: #12
I now have SDL working on my mac, I didn't realize those cocoa files were just backend setup files. I have a nice little circle demo my friend wrote working without any code changes.

Now I have one big question about using ObjectiveC on windows. I know the language is cross platform, but what about methods like alloc and dealloc? I think they are from NSObject which is part of Cocoa. Does anyone know if they are built into the language?
Quote this message in a reply
Member
Posts: 370
Joined: 2002.04
Post: #13
If you want to use Objective-C on the PC (Windows or Linux) your best bet is probably GNUstep (http://gnustep.org/)

It's an open-source reimplementation of the NEXTstep API (Foundation and AppKit)

It's still a bit marginal in its ease-of-use, but it does seem to work after much fiddling.

Did you ever wonder why we had to run for shelter when the promise of a brave new world unfurled beneath the clear blue sky?
Quote this message in a reply
Member
Posts: 509
Joined: 2002.05
Post: #14
Steven Wrote:If you want to use Objective-C on the PC (Windows or Linux) your best bet is probably GNUstep (http://gnustep.org/)

It's an open-source reimplementation of the NEXTstep API (Foundation and AppKit)

It's still a bit marginal in its ease-of-use, but it does seem to work after much fiddling.


WOW!!! If that works as good as it sounds this will be awesome, I was fearing having to port all of my NSStrings and such (NSBundle still may be a problem but is easy to get around I think)
Quote this message in a reply
Member
Posts: 370
Joined: 2002.04
Post: #15
It works almost as well is it sounds Smile
Give it a try!

Did you ever wonder why we had to run for shelter when the promise of a brave new world unfurled beneath the clear blue sky?
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  FlowerMan: PC-DirectX game for Macintosh - porting tools? MarekUhrin 13 6,917 Aug 9, 2006 11:21 AM
Last Post: MarekUhrin
  SDL game porting trouble: undefined symbols destructive cactus 6 5,501 Jul 28, 2005 04:29 PM
Last Post: destructive cactus