Porting a C++ game to iPhone

Member
Posts: 81
Joined: 2007.07
Post: #1
As far as I can tell you must write your program in Objective C, is this correct? From my limited research Objective C is built on C, and replaces C++. Would the easiest way to port a C++ game to run on the iPhone be to simply convert the code to pure C? Are there any conversion utilities to convert C++ to Objective C or aid in this process?

Is there any way to compile or run C++ on the iPhone? Perhaps by sticking it in a library or DLL?
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #2
C++ should compile and run with no problem. You'll need to write at least a small amount of Objective-C or Objective-C++ glue code to work with the system and set stuff up, but other than that, there's no reason at all you can't use C++ for everything else.
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #3
Anyone ported SDL to the iphone yet?

It's not magic, it's Ruby.
Quote this message in a reply
Moderator
Posts: 691
Joined: 2002.04
Post: #4
Sam Lantinga Wrote:SDL is participating in the Google Summer of Code!

I'd like to thank everyone who applied, and introduce the students who were
accepted:

[...]

Holmes Futrell:
Holmes is an undergrad in computer science and mathematics, and will be porting SDL to the iPhone.

So, not yet it would seem...

Mark Bishop
Quote this message in a reply
Apprentice
Posts: 13
Joined: 2008.06
Post: #5
Good news! But even so.. I doubt Apple would allow unofficial libraries (SDL) to be sold/given through AppStore since they officially chose OpenGL ES for the iPhone/Touch?

If they'll allow SDL through the AppStore, then I'm in for a much easier road!
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #6
I can't imagine Apple would prevent SDL. SDL is just a bootstrap for events and for getting graphics context abstractions ( and that includes OpenGL ).
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #7
SDL would not be sold or distributed via the app store... it'd be provided to you, the developer, in exactly the same way it is for Mac OS X, most likely.
Quote this message in a reply
Apprentice
Posts: 13
Joined: 2008.06
Post: #8
I'm sorry, I wasn't clear in my previous post ;p

I mean, if iPhone SDL would be released and we could create games using that SDL, I doubt Apple would let us distribute our games through the AppStore because we didn't use the official library (OpenGL ES?) they have chosen for the iPhone?
Quote this message in a reply
Member
Posts: 114
Joined: 2005.03
Post: #9
Why wouldn't they? It's just a wrapper around existing libraries, after all.
Quote this message in a reply
Apprentice
Posts: 13
Joined: 2008.06
Post: #10
Cochrane Wrote:Why wouldn't they? It's just a wrapper around existing libraries, after all.

Cochrane, thank you. You've just made my day!

This means I can continue working on my project and eventually make it available before first having to learn OpenGL ES!

I don't know very much about such stuff yet, been only in the programming scene for about half a year now so I can sound pretty not-knowing sometimes. LOL
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #11
I doubt that SDL software drawing routines would be fast enough on the phone. You'll almost certainly still have to use OpenGL for graphics, which implies learning OpenGL ES for the iPhone port. SDL would just be for getting a window on the screen and handling events... and given the events are completely different to what you'd get with a keyboard and mouse, the event handling code won't be common, so... just getting a window on the screen. At that point, why bother?
Quote this message in a reply
Member
Posts: 320
Joined: 2003.06
Post: #12
I agree with OSC there, I don't see how the main parts of SDL would be at all useful for games on the iPhone. SDL_image and some of the other add ons could be useful, but only if you were trying to make a cross platform (including windows) code base. And if you're making a game that could share the same source at such a low level for both a windows version and an iPhone version, you're going to have a hard time whatever you chose.

If you want to make a game easy to port later use OpenGL (doesn't have to be OpenGL ES). For all your rendering, including UI, and OpenAL for your audio. Also keep a few key iPhone specific things in mind, like your app could be told to quit at any time, so you need to be able to save quick and restore state just as quick. Also battery usage is important so keep your CPU usage down and of course the user input methods are very unique and need to be designed for.

Chopper, iSight Screensavers, DuckDuckDuck: http://majicjungle.com
Quote this message in a reply
Moderator
Posts: 3,570
Joined: 2003.06
Post: #13
I agree with OSC and Reubert. I just don't see how SDL on iPhone would be able to add any advantage to simply programming directly on iPhone. It's going to have to use OpenGL ES anyway, and software rendering is going to be hard to make happen with the limited resources. Not saying it won't happen, but I'm skeptical of how useful or advantageous it would be.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  porting to the iphone NelsonMandella 12 4,252 Aug 15, 2009 04:22 PM
Last Post: arekkusu
  [Help] - Porting a game engine to iPhone iarwain 0 2,582 May 20, 2009 08:33 PM
Last Post: iarwain