The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Porting to Android: NDK strategies, etc.
jlunderville


Joined: 28 Jul 2010
Posts: 8
I'm working on porting a game to Android, and trying to get the SDL running on Android as part of that.

Since there's a port to iOS going on in parallel, and that's supported in 1.3, I'm more interested in getting 1.3 working than 1.2. I need to be able to publish the result as an .apk that runs on as many phones as possible without incident or special-case workarounds, and without requiring the user to do extra work to install.

From what I gather there are a few ports of varying quality, but pelya's seems to be the most actively worked on right now. It was a little hard for me to figure out what state the 1.3 port was in by browsing the code and the threads here, so I figured I'd just start asking questions.

Before I go too far with this, are there any official plans to support the SDL on Android? Any noise from Google about whether there'll be official support for it in a future NDK? Or if there'll be native APIs for audio/input/etc. at some point?

My understanding is that pelya's 1.3 port doesn't include support for input or haptics, and uses some not-officially-supported APIs, which makes me wonder about whether it can be relied on for future hardware where those interfaces might change. Also, I'm a little unclear on the build process. From browsing the source it doesn't look like it builds using ndk-build, which implies you need to have the Android source installed on your machine and a separate cross-compiler setup to build that .so. Is that correct?

Is there another port I should be looking at?
jlunderville


Joined: 28 Jul 2010
Posts: 8
In case it's not clear, if I do end up working a different porting strategy, I'd like to get my code back into the SDL mainline so everyone can benefit (and I'm not alone in maintaining it...).

Specifically it seemed to me that for compatibility, it would be desirable to run the audio, input, and haptics through JNI. A little tedious, but very straightforward. I heard people talk about an SDL_mobile API for handling save/restore state, which seems like a great idea too.

I had an idea that it should be possible to make use of the GLSurfaceView by running an extra thread for the app's main() and etc.; it starts up suspended, and gets woken up every time onDrawFrame is called. When it's done rendering, the flip() function puts the thread back to sleep and wakes the GLSurfaceView up (I'd actually want to implement this using something like setcontext() to avoid poking the kernel unnecessarily, but hopefully you get the gist).

Any comments on either of these? Am I just overthinking the problem?
Nathaniel J Fries


Joined: 30 Mar 2010
Posts: 444
There is already a GSoC project for a port to Android.

Using that and providing any assistance possible to the student working on it would the best way to meet both your goal of getting your SDL game on Android and with your efforts assisting the rest of those using SDL.


As for SDL_mobile, that's not something that's actually been coordinated or anything yet, just a recommendation. Who knows if and/or when that will ever happen.
Realistically, it will at the very least need both an Android and an iPhone developer to coordinate together. MichelleC seemed very interested in making SDL more useful in iPhone development, so maybe you should speak with her. And as always, I am very willing to make recommendations on the API and (where possible) suggestions on its implementation. I've never developed for either device and definitely lack the time to learn either right now, so I'm afraid I wouldn't be much help beyond commenting on the API.
jlunderville


Joined: 28 Jul 2010
Posts: 8
Quote:
There is already a GSoC project for a port to Android.


Indeed. I tried to get in touch with the person working on it a couple days ago, but I'm not sure if they're reading email at the address I sent to, because I never got a response. I was kind of hoping that I'd be able to get in touch with them by posting here..
Porting to Android: NDK strategies, etc.
Vittorio G.
Guest

i'm too quite interested into the iphone port, and i take advantage of
this post to remind of a couple of bugs (
http://bugzilla.libsdl.org/show_bug.cgi?id=1025
http://bugzilla.libsdl.org/show_bug.cgi?id=1027
http://bugzilla.libsdl.org/show_bug.cgi?id=996
http://bugzilla.libsdl.org/show_bug.cgi?id=1026
) which should be really neat to look at (or at wrost just take the
patch and apply it)
bye
Vittorio

On Thu, Jul 29, 2010 at 2:09 AM, Nathaniel J Fries wrote:
Quote:
There is already a GSoC project for a port to Android.

Using that and providing any assistance possible to the student working on
it would the best way to meet both your goal of getting your SDL game on
Android and with your efforts assisting the rest of those using SDL.


As for SDL_mobile, that's not something that's actually been coordinated or
anything yet, just a recommendation. Who knows if and/or when that will ever
happen.
Realistically, it will at the very least need both an Android and an iPhone
developer to coordinate together. MichelleC seemed very interested in making
SDL more useful in iPhone development, so maybe you should speak with her.
And as always, I am very willing to make recommendations on the API and
(where possible) suggestions on its implementation. I've never developed for
either device and definitely lack the time to learn either right now, so I'm
afraid I wouldn't be much help beyond commenting on the API.

________________________________
EM3 Nathaniel Fries, U.S. Navy

http://natefries.net/
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
jlunderville


Joined: 28 Jul 2010
Posts: 8
An update on this in case anyone actually cares: I did manage to get in touch with Paul, and it turns out that the porting strategy is pretty much as above (except the parts that don't make sense). Things seem to be in pretty good shape; video, audio, and keyboard support are all sort of alpha-level, basically working but with caveats.