SFML community forums
General => General discussions => Topic started by: Beuc on April 19, 2012, 09:24:02 pm
-
Hi,
I am experimenting with SFML on Android :)
(It's currently based on 1.6, but with the new 2.0rc, I'm interested in upgrading ;))
The version is currently able to grab the Android app window and display sprites!
Check it out at:
https://github.com/Beuc/SFML-Android
Here's a sample application :
http://www.beuc.net/tmp/sfml-android/sfml-test-debug.apk
as well as its source code :
http://www.beuc.net/tmp/sfml-android/test-sfml.tar.gz
I hope this will help with porting SFML officially to Android.
What do you think? :)
It requires Android 2.3 or later, as it's based on NativeActivity (aka no line of Java is needed).
The changes consists of all the EGL initialization, change glVertex to GLES1's glDrawArray, and deal with a decent number of idiosyncrasies with the default Android app window. It's currently not possible to create additional windows, not sure if that's possible.
Post effects will probably require a full GLES2 version, as shader don't seem to be available as extensions in a GLES1 environment (unlike "desktop" OpenGL).
Screenshot :
(http://www.beuc.net/tmp/sfml-android/device-2012-04-19-212548.png)
-
It's currently based on 1.6
Wow, must have been a real pain... ;D
SFML 2 is a lot easier to work with regarding porting to other systems (Window and context are separated, vertex arrays are used instead of immediate rendering, etc.), and I'm planning to improve it further to provide a robust and flexible base that can hopefully be ported easily enough to iOS, Android, etc.
I'll definitely have a look at your work when I start playing with Android :)
-
I'll look from a close point your project too. I don't play with Android yet, but it's something planned :D
-
I am actually wondering if you have changed the public interface any? Don't have time to take a look at it and I'm kinda lazy but I am interested ^^
-
it's based on NativeActivity (aka no line of Java is needed)
Great !!! 8)
-
Wow, must have been a real pain... ;D
Yeah, the build system played some nasty tricks on me, and the global static Context/Window, initialized before the SFML is even called, caused a crash that was difficult to track down :-\
Android C/C++ apps are also launched very peculiarly (it's really a Java environment that calls various hooks / event handlers in the application .so library, with android_main() usually started in a separate thread) - not a classic executable with a main()..
I am actually wondering if you have changed the public interface any?
No, but I expect we'll have to add new APIs do deal with:
- resources loading (everything is a zip-like .apk, not extracted, by default) - currently I extract assets/ in the cache directory and chdir() there as a work-around
- detect touchscreen presence (only clicks and drag&drop's, no "passive" mouse move)
- possibly specific features such as multi-touch, accelerometer, etc. - at least providing access to the global JNI object
-
While I think of it: one of the Android-specific changes that will be needed is the ability to resume a paused or killed application, including reloading all the OpenGL resources.
-
Just downloaded and tested it:
Awesome! Keep up the good work, I would be really interested in working with sfml on android!
Looking forward for 2.0 ;)