Forum > Lazarus

New OpenGL Android Example

(1/17) > >>

felipemdc:
Hello,

There is a new Android NDK example in the Lazarus CCR. The most important thing that this example adds is that there are precise step-by-step instructions for the entire process and also a full project structure for building it. The instructions cover from configuring the cross-compiler up to installing the APK in the telephone:

http://wiki.lazarus.freepascal.org/Android_Interface/Android_Programming#Build_the_NDK_OpenGL_example

The example itself is very simple, and just processes some touch screen inputs and draws some colors in the screen.

It uses JNI and the NativeActivity so it runs on all phones with Android 2.3+ (because the cross-compiler uses soft-float). In this example there is zero Java source code, the NativeActivity does everything that we need. This method is fully sponsored by Google, so applications built like that are really on the safe side.

I am no OpenGL expert, so I don't know yet much about this part, so I just reused older examples for that, but what really amazed me is that I was able to create a project which correctly links to Android native libraries from the NDK, so I gained some knowledge here which I tought people might find useful:

1> Copying .so libraries from the device to link to them is not required, just link against the .so files which are in the NDK
2> Specifying the path to the .so files with -Fl works nicely as described in the example instructions
3> I previously heard from someone that FPC had some initialization issues in Android libs, but I haven't found any in this project (I still have to check if it doesn't appear if I added more units to the uses clause)
4> It is possible to write an application which uses OpenGL and touch screen input with zero Java code =D
5> You need at least ant 1.8 to use the latest Android SDK, so you might need to upgrade your Linux (I had to upgrade from Mandriva 2010 to Mageia 1 for this)

I hope you enjoy,

Stoney:
This is awesome. Thank you so much. Haven't had a chance to try this yet, but I will very soon.

Leledumbo:
First problem, I got error regarding missing /lib/ld-linux.so.3, that's easy to fix looking at another thread. Second one, I got this:

--- Quote ---C:\fpc\bin\i386-win32\arm-linux-ld.exe: warning: E:\Sources\lazarus-fpc\android-ndk\examples\opengltest\android\libs\armeabi\link.res contains output sections; did you forget -T?
E:\Sources\lazarus-fpc\android-ndk\examples\opengltest\lib\arm-linux\ndkopengltest.o: In function `FPC_SHARED_LIB_START':
ndkopengltest.pas:(.text.n_p$ndkopengltest_$$_fpc_shared_lib_start+0x0): multiple definition of `FPC_SHARED_LIB_START'
C:\fpc\units\arm-linux\rtl\dllprt0.o:dllprt0.as:(.text+0x0): first defined here
ndkopengltest.pas(255,37) Error: Error while linking

--- End quote ---
For this one, I have no idea...

felipemdc:

--- Quote from: Leledumbo on November 12, 2011, 11:53:27 pm ---For this one, I have no idea...

--- End quote ---

I had tested it with my FPC 2.5 snapshot and some things changed in the compiler in the mean time. Do svn update, it should be fixed now.

Laksen:
felipemdc, the problem with FPC_SHARED_LIB_START has been fixed in svn trunk, so it should be removed from the example

Specifically this should be removed:

--- Code: ---procedure PASCALMAIN; external name 'PASCALMAIN';

procedure FPC_SHARED_LIB_START; [public, alias: 'FPC_SHARED_LIB_START'];
begin
   PASCALMAIN;
end;

--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version