Recent

Author Topic: New OpenGL Android Example  (Read 104616 times)

Laksen

  • Hero Member
  • *****
  • Posts: 802
    • J-Software
Re: New OpenGL Android Example
« Reply #45 on: November 21, 2011, 09:46:28 pm »
Do you have an example showing the offending code. Can you get a precise pointer value of the function that you are calling? That would indicate whether it's a problem with calling Thumb code or whether the problem lies elsewhere

Andru

  • Full Member
  • ***
  • Posts: 112
Re: New OpenGL Android Example
« Reply #46 on: November 22, 2011, 08:35:22 am »
Quote
Do you have an example showing the offending code.
Nope... ZenGL is quite big to use it as an example, so it will be impossible to find out where it doesn't work with older version of FreePascal. And I didn't see any debug messages of ZenGL initialization, so seems libZenGL.so wasn't loaded or "crashed" at start. I will try to remove static linking with libzip and linking with libchipmunk.so for physics and look again.
« Last Edit: November 22, 2011, 08:37:51 am by Andru »

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: New OpenGL Android Example
« Reply #47 on: November 22, 2011, 09:02:20 am »
static dynamic link to shared objects should work around January 19th. After all, my OpenGL example does use a number of native shared objects. Just to start with, it uses OpenGL and JNI.

Maybe you are using dynamic loading the shared object?

Or maybe you are using hardware floating point in a device which has no FPU?

I suppose that one interresting test would be simply using my pre-compiled compiler and see if things improve:

http://sourceforge.net/projects/p-tools/files/Free%20Pascal%20for%20ARM/

It is a Linux x86->Android-arm cross-compiler

Andru

  • Full Member
  • ***
  • Posts: 112
Re: New OpenGL Android Example
« Reply #48 on: November 22, 2011, 09:47:48 am »
Quote
Maybe you are using dynamic loading the shared object?
Only for GLES libraries, and this is works with new FPC.

Quote
Or maybe you are using hardware floating point in a device which has no FPU?
I use only soft-float currently, but my device support ARMv6 with VFP. Even so, why newer FPC works?

Quote
I suppose that one interresting test would be simply using my pre-compiled compiler and see if things improve:
Ok, I will try it. And can you show your make options for it?

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: New OpenGL Android Example
« Reply #49 on: November 22, 2011, 10:49:30 am »
Quote
Maybe you are using dynamic loading the shared object?
Only for GLES libraries, and this is works with new FPC.

Are you sure that you understood what I said? dynamically loading means using GetProcAddress and LoadLibrary. Thats unusual for basic bindings like OpenGL.

Quote
Even so, why newer FPC works?

I think that the most interresting question here is why it fails for you but it works correctly for me with my 19th January compiler.

Quote
And can you show your make options for it?

I built it 10 months ago, so I can't be sure, but I think it was:

make crossinstall CPU_TARGET=arm OS_TARGET=linux CROSSBINDIR=/home/felipe/Programas/fpctrunk/binutils OPT=-dFPC_ARMEL INSTALL_PREFIX=/usr/

Andru

  • Full Member
  • ***
  • Posts: 112
Re: New OpenGL Android Example
« Reply #50 on: November 22, 2011, 11:35:00 am »
Quote
Are you sure that you understood what I said? dynamically loading means using GetProcAddress and LoadLibrary. Thats unusual for basic bindings like OpenGL.
Yes, I'm sure and I'm using dynamic loading for GL/GLES libraries via dlopen/dlsym(or LoadLibrary/GetProcAddress under Windows) and OS specific glxGetProcAddress/wglGetProcAddress/eglGetProcAddress because of many reasons.

Quote
I think that the most interresting question here is why it fails for you but it works correctly for me with my 19th January compiler.
Maybe because of different code :) When I get home I will test simple library without all my code. Also maybe there is a difference in version/etc. of binutils.
« Last Edit: November 22, 2011, 11:39:39 am by Andru »

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: New OpenGL Android Example
« Reply #51 on: November 22, 2011, 11:41:23 am »
Yes, I'm sure and I'm using dynamic loading for GL/GLES libraries via dlopen/dlsym(or LoadLibrary/GetProcAddress under Windows) because of many reasons.

Ok, so now we found the problem. 2 things you should know about:

1> Free Pascal has no support at all for dynamic loading in Android. Not in my pre-compiled snapshot and also not in trunk. In trunk this support was added for generic arm-linux which simply broke the compilation of Android projects because the Android uses a completely different dynamic linker.

2> The Android dynamic linker is very different from the Linux one and even has some bugs, see for example this thread:

http://groups.google.com/group/android-ndk/browse_thread/thread/2779732b85fef9b3

So summing up I would really recommend statically linking all shared objects that you need in Android.

Andru

  • Full Member
  • ***
  • Posts: 112
Re: New OpenGL Android Example
« Reply #52 on: November 22, 2011, 12:41:53 pm »
Quote
Free Pascal has no support at all for dynamic loading in Android.
So how it works for me with FreePascal 2.5.1 from fixes_2_6 branch? O_o Maybe you confuse it with dynamic loading of libraries which are inside apk?

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: New OpenGL Android Example
« Reply #53 on: November 22, 2011, 01:31:52 pm »
So how it works for me with FreePascal 2.5.1 from fixes_2_6 branch?

I never tried it, since I don't use this, I just wrote what I understood from the commits I read and bug reports, so I could be saying something wrong.

Plus it seams that you use something non-standard, I was refering to the standard way of doing this: dynlibs unit from Free Pascal, which has LoadLibrary (don't confuse it with Windows.LoadLibrary, they are named the same and do the same but are not the same). But it seams that you use a non-standard method: directly calling dlopen from the linker?

So what exactly fails here for you and how do you know that dynamic loading works? I though that you previously said that your project does not work in Android at the moment.

Quote
O_o Maybe you confuse it with dynamic loading of libraries which are inside apk?

Does it matter the location of the libraries?

Andru

  • Full Member
  • ***
  • Posts: 112
Re: New OpenGL Android Example
« Reply #54 on: November 22, 2011, 02:07:11 pm »
Quote
something non-standard
Before saying this just learn about API's in different OS'es... dlopen and dlsym are standard functions from libc :)

Quote
I though that you previously said that your project does not work in Android at the moment.
It works, but not all things which I want... E.g. static linking(I mean linking with objects files, not with shared object) with chipmunk doesn't work. Also I have some troubles with libjpeg.so, but maybe this is because of my own function inside it... And as I wrote before - units like math, Unix and SysUtils makes my library unloadable, but this is because of known bug as you mentioned.

Quote
Does it matter the location of the libraries?
Of course, when your library is inside apk you can't load it(without hacks like extracting it to /sdcard and loading). You can use only linking with shared object with previous loading it in your Java code(Syste.loadLibrary).

Andru

  • Full Member
  • ***
  • Posts: 112
Re: New OpenGL Android Example
« Reply #55 on: November 22, 2011, 05:24:36 pm »
So... seems I just forgot about FPC_SHARED_LIB_START. Also your build needs one patch which I mentioned before(without it I can't call any JNI function via JNIEnv on my device). But even with it my problems the same - static linking with object files of chipmunk doesn't work(but maybe this is because of unknown requirements... the worst thing on Android is that I can compile shared object with unresolved externals and got no errors >_<), so no matter can I include SysUtils or not.

Laksen

  • Hero Member
  • *****
  • Posts: 802
    • J-Software
Re: New OpenGL Android Example
« Reply #56 on: November 22, 2011, 07:05:42 pm »
FPC_SHARED_LIB_START should be in the RTL. If it is not there you probably have a too old RTL

Andru

  • Full Member
  • ***
  • Posts: 112
Re: New OpenGL Android Example
« Reply #57 on: November 22, 2011, 08:04:23 pm »
Laksen
We talk about some old revision(16750) here, so yes, it wasn't there I think :)

PS: unit chreads wants pthread instead of libc... so many problems should be solved >_<

Jonathan

  • New Member
  • *
  • Posts: 40
Re: New OpenGL Android Example
« Reply #58 on: November 23, 2011, 03:59:59 am »
Hi felipemdc,finally I got the apk(size:155k),but when I installed into android 2.3 machine and the emulator,it didnot work!as the picture shows.  so I try to  check  libmain.so,I do not find anything wrong.

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: New OpenGL Android Example
« Reply #59 on: November 23, 2011, 07:08:05 am »
What does "adb logcat" say about it?

Are you using my pre-compiled snapshot compiler or did you build your own?

 

TinyPortal © 2005-2018