"Minimum hassle" porting to the iPhone

Hello,

I’m getting an iPhone GS next week, and I want (if my schedule allows it) to
port GLtron to it. As some of you may know, GLtron currently uses SDL /
OpenGL, libpng, libz and SDL_sound. Of course I need to port to OpenGL ES
but that shouldn’t be too difficult. Also, I’m not worried about png/zlib, I
guess Apple will have some functions available for loading textures (and I
guess I’ll convert everything into that compressed texture format the Power
VR chip prefers anyway).

That leaves SDL & SDL_sound. What I need is recommendations on how to
proceed:

SDL is used to setup the GL context, and handle input and audio out.

  • Use the SDL iPhone port, or use Apple’s stuff?

On the audio side, I need support for plain audio files
(wav/ogg/mp3/whatever) and either .it playback or mp3/ogg playback (although
that will blow up the file size).

  • Has someone compiled SDL_sound for the iPhone? Or should I ditch the
    Impulse-Tracker stuff and use Apple’s stuff?

I’m not scared of learning a new API, but of course, if the current stuff is
usable on the iPhone without much hassle (I’d rather not spend hours and
hours tweaking things or fighting the dev-kit) I wouldn’t mind to safe
myself the trouble.

Thanks for your recommendations,

  • Andreas

Andreas Umbach wrote:

Hello,

I’m getting an iPhone GS next week, and I want (if my schedule allows
it) to port GLtron to it. As some of you may know, GLtron currently
uses SDL / OpenGL, libpng, libz and SDL_sound. Of course I need to port
to OpenGL ES but that shouldn’t be too difficult. Also, I’m not worried
about png/zlib, I guess Apple will have some functions available for
loading textures (and I guess I’ll convert everything into that
compressed texture format the Power VR chip prefers anyway).

There are samples on the dev site to load an image to a texture, but
it’s probably just as easy to load a png manually and pop it on a texture.

The compressed texture formats are all lossy. In other words the output
is ugly. The 2 bit format is uglyugly. I don’t know if the Power VR chip
on the new iPhone has additonal non-lossy formats.
Normal 16-bit textures (RGBA4444) showed visible banding. Probably worth
sticking with RGBA8.

That leaves SDL & SDL_sound. What I need is recommendations on how to
proceed:

SDL is used to setup the GL context, and handle input and audio out.

  • Use the SDL iPhone port, or use Apple’s stuff?

For the iPhone port of Critical Mass I ended up not using SDL, partly
because Holmes just started working on the port. Since GLtron already
uses SDL, it’s probably worth trying the SDL iPhone port.

With the available samples on the dev site, setting up a GL context
isn’t too hard. Ditto for input handling. High scrore text entry needed
a bit of code to get the on-screen keyboard to show up.

I dropped the soundtrack to save space and the device is an mp3 player
so the user can play whatever music they want. Sound fx are played using
AudioServicesPlaySystemSound.

On the audio side, I need support for plain audio files
(wav/ogg/mp3/whatever) and either .it playback or mp3/ogg playback
(although that will blow up the file size).

  • Has someone compiled SDL_sound for the iPhone? Or should I ditch the
    Impulse-Tracker stuff and use Apple’s stuff?

I’m not scared of learning a new API, but of course, if the current
stuff is usable on the iPhone without much hassle (I’d rather not spend
hours and hours tweaking things or fighting the dev-kit) I wouldn’t mind
to safe myself the trouble.

The most time consuming part was getting the performance up to a
playable level. Loading files from flash is s-l-o-w. There’s a reason
most apps show a loading screen. The Power VR’s fill rate isn’t great,
but it can handle quite a bit of geometry. I didn’t have to simplify any
of the critter models.

The menu had to change quite a bit to make it tap friendly and fit
within the small screen.

Getting GLtron to run well on the iPhone is probably more work than you
think (isn’t it always?), but I’m sure you’ll find it to be a fun project.

Cheers,
Frank.