View Full Version : Android Support

04-11-2011, 09:13 PM
Here is the first experiment with Android where I mixed Java(creating main view and attaching GLSurfaceView) and Pascal(changing OpenGL ES states, rendering, etc.). Simple demo shows green rectangle with red border. On photo you can see Eclipse 3.7.1, FreePascal 2.5.1, Lazarus 0.9.31 and dirty LG Optimus One in my hands :)
http://zengl.org/history/zengl_android_screen_01s.jpg (http://zengl.org/history/zengl_android_screen_01.jpg)

Unfortunately there are many problems and FreePascal still not ready for Android(but I hope I will change my mind :)). Just including some Unix-units will crash your app(and this prevent me to use timers, file operations, etc.), using cthreads will fail your linking stage. I will continue my work, but full port won't be soon, I guess.

04-11-2011, 09:34 PM
Very interesting! It is a good start! =)

04-11-2011, 10:18 PM
Can't we just write some bindings to borrow the C++ libraries? Or, drop to root on android and build fpc from source on android itself?

04-11-2011, 11:40 PM
Very cool. Any consideration towards Oxygene 5 support in ZenGL?

You could get on their beta by contacting Marc Hoffman on their site.

05-11-2011, 07:22 AM
Any consideration towards Oxygene 5 support in ZenGL?
ZenGL isn't a simple library, so it will be too hard to make such a port because Oxygene just a "Java with Pascal face" and this is not enough. Also I didn't find any information about integration with Eclipse(only with Visual Studio under Windows... O_o and where is my Linux support? :))

// spam-bots... they like to post in my threads, or their invisible messages are everywhere?

05-11-2011, 09:13 PM
// spam-bots... they like to post in my threads, or their invisible messages are everywhere?

In theory, it is not possible for you to see those posts - interesting. To be honest, deleting them makes my job a tad harder as for some reason the selection button doesn't work properly every time otherwise. Can't be helped I guess - I end up taking care of 30 odd posts a day whenever my Internet connection decides to play ball, but as the modem is dyeing (doesn't sync above 2.1meg and decreasing) things aren't looking as good as they could be... :)

only with Visual Studio under Windows

Thats a surprise - a LOT of development nowadays is done under Mac and Linux - especially for a linux target like android.

06-11-2011, 10:07 AM
In theory, it is not possible for you to see those posts - interesting
I'm moderator in ZenGL part of forum, so I see these messages... :)

06-11-2011, 11:44 AM
Ah, makes sense.

15-11-2011, 10:14 PM
I just leave it here :)
// yeah, I know, there is a small bug with 2D-camera - it just doesn't reinitialize for newer resolution )

15-11-2011, 11:49 PM
Wow! Wow! Wow! =)

Very impressive!!! And It seems rock fast!! =)

I can't wait to test it! =P

16-11-2011, 01:03 AM
wooh kinda nice :)

how stable is it actually? or better how hard to get a zengl made game running there? ;)

16-11-2011, 06:01 AM
indeed this is quite impressive . 10/10 for zengl

16-11-2011, 10:00 PM
Here is a bit improved version and built for devices - TestZenGL.apk (http://zengl.org/history/TestZenGL.apk)

16-11-2011, 11:38 PM
Nice!! I will test on a Android of a friend mine tomorrow!

But I think you will make me buy an Android Cell Phone! =)... (for my Wife :P)

17-11-2011, 12:07 AM
for guys like me who dont have a android phone yet i recommend LiveAndroid (http://code.google.com/p/live-android/)
its also better then the crappy and slow emulator that comes with the sdk

17-11-2011, 04:34 AM
the crappy and slow emulator that comes with the sdk
On my machine it starts in 15 seconds and works fine for testing :) Also no need to restart it every time.

17-11-2011, 09:40 AM
Tested it on a MOTOROLA DEFY™!
Solid 60 fps! =)

I need to test something more heavy! =P

17-11-2011, 01:21 PM
its a while since i tested the sdk emulator but it was kinda slowly
the liveandroid runs just fine on virtualbox but maybe i give the sdk emulator another try ;)

22-11-2011, 09:11 PM
New features:
- playing sounds and music(streaming from memory) via OpenAL
- headers and compiled Chipmunk(ARMv5 version with soft-float is quite slow, so I will try to build it for ARMv6 with VFPv2 and test later)
- touch input(but I need some device with real multi-touch to test my code)

But due to some FreePascal incompatibilities with Android it's quite hard to make some progress in low-level parts of this port, e.g. unit cthreads doesn't work so I need to use my own unit with pthreads.

22-11-2011, 10:23 PM
Can you share with me, how you managed to get OpenAL working on Android? I believe it is not part of the NDK. Did you build OpenAL yourself from source?

Thanks :)

22-11-2011, 10:35 PM
I use this fork (http://repo.or.cz/w/openal-soft/android.git).

26-11-2011, 09:27 PM
Finally ZenGL got an Android 2.1+ support in latest svn revision. You can grab it from here with your svn client:

Standard demo05 for learning how to use ZenGL with Android is placed here (http://zengl.org/history/zengl_android_demo05.zip). Just unpack it somewhere and import into Eclipse - File->New->Project->Android Project and choose "Create project from existing source":

Then choose some other options like Android SDK and so on. Next step - download from here (http://zengl.org/history/zengl_android_demo05_lazarus.zip) project for Lazarus(also there is a Makefile). Unpack it into demos directory of ZenGL svn working copy. Open demo05.lpi in Lazarus and change path to lib directory and libdl.so to your own from yours Android NDK:

Compile and copy all *.so libraries into TestZenGL/libs/armeabi. So, now you can start to test it on your device or emulator :)

PS: Everything was tested with FreePascal compiled from fixes_2_6 branch (http://svn.freepascal.org/svn/fpc/branches/fixes_2_6/). Any other details like "How to setup Eclipse with Android SDK/NDK on my OS" and "How to compile FreePascal for ARM on my OS" are not a topics of this topic, so... maybe later I will try to prepare some notes in wiki for Linux/Windows, but due to lack of time I don't know when I will do this.

27-11-2011, 03:13 PM
congratulation , good news , i'll check if i could make something visual with Android

i've a question :
why Zengl dosen't have a Net Feature Till now ? .

27-11-2011, 03:43 PM
why Zengl dosen't have a Net Feature Till now ?
Because I never do things "for fun" in which I'm not interested :)

27-11-2011, 09:32 PM
Very interesting. Good to see they made OpenAL work on android. :)

Another question: You probably encountered some problems while you made ZenGL ready for android. Can you tell me how you debugged your code? I've been looking for a good way to do it, but the only method I know is just to write to the log. Did you find any other way to catch bugs on android?

28-11-2011, 05:05 AM
I haven't tried this, but I didn't tried it and with iOS :) And yes, currently I use only logging. But as I know, debugging even C/C++ code is not so simple.

28-11-2011, 03:01 PM
More improvements:
- now multi-threaded resource loading works :)
- ZenGL will not check EGL(no need in it)

Still don't know what to do with "OpenGL context lost"... I don't like an idea to reload every texture...

14-01-2012, 08:39 PM
I am going to try to make a simple game like "Whack-A- Mole" with this. Works pretty smooth with LG GT540 - Android 2.1

13-03-2012, 08:55 PM
Wiki has been updated. Now you can read about compilation of cross-compiler for Android in GNU/Linux and Windows (http://zengl.org/wiki/doku.php?id=compilation:android).

16-03-2012, 05:09 PM
I returned to Android development and implemented virtual kayboard :) A bit updated old demo is here (http://zengl.org/tmp/TestZenGL.apk). It uses the same scene with penguins, plays music in separate thread and shows virtual keyboard(with handling text input) after tapping on blue square. All changes can be found in latest svn revision of ZenGL.

16-03-2012, 05:21 PM
Awesome! =)

I will make some tests this weekend! I can't wait to start porting my games to Android! =)

20-03-2012, 04:17 AM
Hi Andru,
I tested your demo on my ancient Samsung Galaxy Spica. (2 years old :-) with 2.2.1 homebrew ROM) and it works perfectly.

20-03-2012, 03:16 PM
Thanks for testing! :)

23-03-2012, 11:20 AM
I checked the updated demo on LG GT540 with stock ROM - Android 2.1 and I am getting around ~39FPS.
Nice to see that Resume and Exit stuff now works :)

20-04-2012, 08:00 AM
Andru: Thanks for the excellent documentation on how to get Fpc working on Windows for cross-compilation to Android. I found this thread and your guide here (http://zengl.org/wiki/doku.php?id=compilation:android) to be very detailed and helpful. I got the basics working thanks to this information and next I will try to get simple OpenGL ES applications running. I'm sure I will go to the ZenGL source for reference. If I get something working I might try to port my own engine later on. Again, thanks for sharing all this information. Fpc for Android is not very well documented as I'm sure many have found out :)

20-04-2012, 10:24 AM
you're welcome! :)

Fpc for Android is not very well documented as I'm sure many have found out
Unfortunately main problem of FreePascal for Android is not a documentation(as I remember there are some instructions on FreePascal/Lazarus wiki and even third party iso-file for VirtualBox with all installed for development), but support of Android. As you have already seen - I use my own patches for threads and one more patch for possibility to use units SysUtils, Math and Classes.

21-04-2012, 07:40 PM
You know it might be easiest to support Android by focusing on adding to support to Oxygene for Java instead. To get FPC on board with Android, you'd have to wait for them to add features, while supporting Oxygene for Java, the support is on you to work around what is missing.

...and with those that have taken up the latest PGD Challenge along with the added challenge of making a game using Oxygene, they could help you to test support and offer advice towards what you can and can't do in it.

21-04-2012, 11:49 PM
To get FPC on board with Android, you'd have to wait for them to add features, while supporting Oxygene for Java, the support is on you to work around what is missing.
O'rly? :) I was needed threads via standard functions instead of pthread*, so I took source code of FreePascal and just done everything I need. All other stuff works like a charm and no need to wait anything else.

07-07-2012, 10:48 PM
Now lazy people also can use FreePascal for Android, because precompiled version of it with installation instructions available here (http://zengl.org/wiki/doku.php?id=compilation:android#precompiled_freepa scal_for_lazy_people) :)

08-07-2012, 02:59 PM
Lazy people... Sure does sound a lot like me there andru :)

09-07-2012, 03:26 PM
I see you are making progress with this. Nice job, keep it up! :)

09-07-2012, 09:37 PM
an awesome job! it took me 2 weeks to get fpc to compile for android, it is a fairly complex task. so this should ease the pain for a lot of people.

10-07-2012, 09:01 AM
good work , thanks for sharing

23-12-2012, 06:30 PM
Anyone tried this engine on Android x86 ?

23-12-2012, 08:46 PM
ZenGL won't work out of the box with Android x86 for the next reasons:
- internal define ANDROID is only for arm-linux(but can be changed easily)
- additional libraries compiled only for ARM architecture(not a problem to recompile everything, but I don't see any reason to do so)
- situation with FreePascal is not clear for Android x86(I'm not 100% sure that it will work out of the box with my patches)

24-12-2012, 09:50 PM
Yeah,probably it will take a while for a Freespascal x86 crosscompiler and maybe there is still not so many gamers with Intel Atom x86 based,Android devices.