PDA

View Full Version : Android Support



Andru
04-11-2011, 10: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.

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

code_glitch
04-11-2011, 11: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?

WILL
05-11-2011, 12:40 AM
Very cool. Any consideration towards Oxygene 5 support in ZenGL?

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

Andru
05-11-2011, 08: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?

code_glitch
05-11-2011, 10: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.

Andru
06-11-2011, 11: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... :)

code_glitch
06-11-2011, 12:44 PM
Ah, makes sense.

Andru
15-11-2011, 11:14 PM
http://www.youtube.com/watch?v=VmU_RYA0XMo
I just leave it here :)
// yeah, I know, there is a small bug with 2D-camera - it just doesn't reinitialize for newer resolution )

wagenheimer
16-11-2011, 12:49 AM
Wow! Wow! Wow! =)

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

I can't wait to test it! =P

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

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

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

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

wagenheimer
17-11-2011, 12:38 AM
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)

Daikrys
17-11-2011, 01: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

Andru
17-11-2011, 05: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.

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

I need to test something more heavy! =P

Daikrys
17-11-2011, 02: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 ;)

Andru
22-11-2011, 10: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.

chronozphere
22-11-2011, 11: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 :)

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

Andru
26-11-2011, 10:27 PM
Finally ZenGL got an Android 2.1+ support in latest svn revision. You can grab it from here with your svn client:
http://zengl.googlecode.com/svn/trunk/

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":
http://zengl.org/history/zengl_android_import.png

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:
http://zengl.org/history/zengl_android_options.png

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.

virtual
27-11-2011, 04: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 ? .

Andru
27-11-2011, 04: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 :)

chronozphere
27-11-2011, 10: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?

Andru
28-11-2011, 06: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.

Andru
28-11-2011, 04: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...

gintasdx
14-01-2012, 09: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

Andru
13-03-2012, 09: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).

Andru
16-03-2012, 06: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.

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

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

joseywales72
20-03-2012, 05: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.
Thanks.
Anil

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

gintasdx
23-03-2012, 12:20 PM
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 :)

VilleK
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 :)

Andru
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.

WILL
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.

Andru
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.

Andru
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) :)

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

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

Dan
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.

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

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

Andru
23-12-2012, 09: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)

gintasdx
24-12-2012, 10: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.