Welcome, Guest. Please login or register.

Author Topic: SFML on Android - proof of concept  (Read 9842 times)

0 Members and 1 Guest are viewing this topic.

Beuc

  • Newbie
  • *
  • Posts: 5
    • View Profile
SFML on Android - proof of concept
« on: April 19, 2012, 07: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 :
« Last Edit: April 19, 2012, 07:28:36 pm by Beuc »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 28357
    • View Profile
    • SFML's website
    • Email
Re: SFML on Android - proof of concept
« Reply #1 on: April 19, 2012, 07:36:18 pm »
Quote
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 :)
Laurent Gomila - SFML developer

Lo-X

  • Hero Member
  • *****
  • Posts: 557
    • View Profile
    • My personal website, with CV, portfolio and projects
Re: SFML on Android - proof of concept
« Reply #2 on: April 19, 2012, 09:23:12 pm »
I'll look from a close point your project too. I don't play with Android yet, but it's something planned :D

Groogy

  • Hero Member
  • *****
  • Posts: 1485
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Re: SFML on Android - proof of concept
« Reply #3 on: April 19, 2012, 09:34:29 pm »
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 ^^
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

mateandmetal

  • Full Member
  • ***
  • Posts: 171
  • The bird is the word
    • View Profile
    • my blog
Re: SFML on Android - proof of concept
« Reply #4 on: April 19, 2012, 10:39:23 pm »
it's based on NativeActivity (aka no line of Java is needed)

Great !!!  8)
- Mate (beverage) addict
- Heavy metal addict _lml
- SFML 2 addict
- My first (and free) game: BichingISH!

Beuc

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: SFML on Android - proof of concept
« Reply #5 on: April 20, 2012, 10:01:31 pm »
Quote
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()..

Quote
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

Beuc

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: SFML on Android - proof of concept
« Reply #6 on: April 21, 2012, 09:43:13 pm »
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.

Fkscorpion

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: SFML on Android - proof of concept
« Reply #7 on: April 23, 2012, 09:05:07 am »
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  ;)

 

anything