Migrate a Java application using Jogl to Android tablet

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Migrate a Java application using Jogl to Android tablet

mimou
I have an OpenGL application written in Java. I need to deploy it on an Android tablet. Do you think I can reuse some code or I'll have to rewrite it at all ?
Regards
Reply | Threaded
Open this post in threaded view
|

Re: Migrate a Java application using Jogl to Android tablet

Sven Gothel
Administrator
On 02/10/2012 02:58 PM, Mimou [via jogamp] wrote:
>
>
> I have an OpenGL application written in Java. I need to deploy it on an
> Android tablet. Do you think I can reuse some code or I'll have to rewrite
> it at all ?

You did not specify which OpenGL binding your code currently uses.
In case you use JOGL (JOGL2 that is), you should be able to deploy it
w/o code change as we have deployed our Android demos.

- Separate apk's (gluegen, jogl, launcher, demo) that is.
- Using NEWT (AWT is not supported on Android)
- Using GL2ES2/GLES2

Maybe you need to be a bit more specific.

I currently do an overhaul of our Android binding
making the deployment a bit more easier - than it is today.

Plus .. we will finally offer them on the 'market' :)

~Sven



signature.asc (910 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Migrate a Java application using Jogl to Android tablet

mimou
I'm using GL2 in my application.
I tried to build your demo but it's a bit tricky. I had to download gluegen from the repository because ant tasks depends from gluegen build tasks.
Is -it possible to deploy your demo's apks using eclipse as any android project ?

I tried also to create a single apk using your jars but it is impossible to deploy such a big apk.  Can you give some details about how the apks share data ?

Regards,
Mimou
Reply | Threaded
Open this post in threaded view
|

Re: Migrate a Java application using Jogl to Android tablet

Sven Gothel
Administrator
On 02/12/2012 09:40 PM, mimou [via jogamp] wrote:
>
>
> I'm using GL2 in my application.

You will need to utilize GL2ES2 only in your application
to be able to use GLES2 on your mobile device.

GLES2 (see the UML diagram, classes, specs) excludes the fixed function
pipeline of GL2 and the other compatibility profiles
(it's a subset so to speak).

> I tried to build your demo but it's a bit tricky. I had to download gluegen
> from the repository because ant tasks depends from gluegen build tasks.
> Is -it possible to deploy your demo's apks using eclipse as any android
> project ?

Even though I use Eclipse as an editor and refactoring tool,
I haven't yet tried it with Eclipse as a deployment tool, sorry.
For sure .. this is something we should do - ie. test it etc.
For now, we just use ant and deploy the 'apk's manually.

Rami started using the Eclipse / Android tool chain
before Siggraph last year .. but other work hindered him to finish it.

>
> I tried also to create a single apk using your jars but it is impossible to
> deploy such a big apk.  Can you give some details about how the apks share
> data ?

Right, we don't use a single APK - since we love reusing our stuff.
We managed to daisy chain the APK's (JARs and native libraries)
via our jogl.android-launcher.apk.

When looking into our demos, ie. 'NEWTLauncherGearsES2Activity',
you learn that we provide a common subclass
'com.jogamp.android.launcher.NEWTLauncherActivity' which handles
all required task: loading APKs (gluegen, jogl, 'user apk') and
kicking off the activity derived from 'jogamp.newt.driver.android.NewtBaseActivity'.

[1] NEWTLauncherActivity loads the APKs while creating a new ClassLoader via
  cl = ClassLoaderUtil.createJogampClassLoaderSingleton(this, getUserPackageName())

[2] getUserPackageName() is simply overridden by the demo's activity, ie
'NEWTLauncherGearsES2Activity' returns 'com.jogamp.opengl.test',
our jogl.test.apk's package name.

[3] NEWTLauncherActivity then uses the new ClassLoader to instantiate your
NewtBaseActivity's subclass and delegates all Activity calls to it!

+++

Current sub optimal situation:

By now you might have seen that you would need to
provide 2 APKs:

[u1] Your demo launcher APK, which needs to include code of our
     NEWTLauncherActivity and it's dependencies,
     so you will be able to actually daisy chain the components.
     Here you will also place your NEWTLauncherActivity's subclass
     which names your actual demo Activity (NewtBaseActivity subclass)
     and it's demo APK.
     You also need to drop all the XML resource files here.
     Classes within this package don't have direct access
     to JOGL/NEWT.

[u2] Your demo APK, which is a subclass of NewtBaseActivity.
     The demo APK is almost Android agnostic and you have full
     access to the JOGL/NEWT API, meaning your normal GLEventListener
     code shall work w/o changes when using NEWT.

Ours 2 APKs in this regard are:
     jogl.android-launcher.apk
     jogl.test.apk

This complication is due to the described daisy chaining
and using API compatible code. There is a version of class loading
around which replaces the system classloader .. however it uses
some peek & poke heavily and is not compatible.

http://forum.jogamp.org/Android-Test-APKs-201110080141utc-td3404613.html

I will look into this process this week, maybe we can simplify it a bit.
Maybe we can make the launcher a bit more generic, so one can just repack it
with a custom XML file (to name the NewtBaseActivity subclass and it's APK).

Hope this elaboration helps a bit.

~Sven

>
> Regards,
> Mimou
>


signature.asc (910 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Migrate a Java application using Jogl to Android tablet

Mimou
I'm interested in anything can be done to make it easier. For now I can't launch your demos because my emulator version is not implemented (armv5tejl). I modified the demos to include my code. But I can't rebuild new apks to deploy them. I develop on Windows and I try to deploy on an Android emulator. I don't have all the required libraries to rebuild the same way you do it.
For now I'll try to rewrite the code using the OPEN GL ES provided by khronos.

Regards
Reply | Threaded
Open this post in threaded view
|

Re: Migrate a Java application using Jogl to Android tablet

Sven Gothel
Administrator
On 02/14/2012 10:05 AM, Mimou [via jogamp] wrote:
>
>
> I'm interested in anything can be done to make it easier. For now I can't
> launch your demos because my emulator version is not implemented
> (armv5tejl). I modified the demos to include my code. But I can't rebuild
> new apks to deploy them. I develop on Windows and I try to deploy on an
> Android emulator. I don't have all the required libraries to rebuild the
> same way you do it.

We should work on this task together soon,
ie. cleanup the build environment. Thought only the NDK6 is required though.

My setup (compilerflags) compile for ARMv7 I guess.

Still merging new GL headers now (GL 4.2, and new EGL/ES1/ES2)
to update JOGLs GL binding.

> For now I'll try to rewrite the code using the OPEN GL ES provided by
> khronos.

Thats a good start. If it works with GL2ES2 (to target ES2 on the device)
you are in very good shape. You may also follow my other post here (?)
in regards testing w/ PVR ES2 emulation (Imageon's emulator).

I figured when all these things worked out, you can skip the emulator.
Usually it's the actual ES driver on the device which causes trouble,
if at all (-> see my blogs).

~Sven

>
> Regards


signature.asc (910 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Migrate a Java application using Jogl to Android tablet

jedwards1211
In reply to this post by Sven Gothel
Hi Sven,

Where are the Android demos located?  I'm having a tough time finding them and other detailed information about porting to Android.

Thanks!
Andy
Reply | Threaded
Open this post in threaded view
|

Re: Migrate a Java application using Jogl to Android tablet

Sven Gothel
Administrator
On 10/12/2013 06:46 PM, jedwards1211 [via jogamp] wrote:
> Hi Sven,
>
> Where are the Android demos located?  I'm having a tough time finding them and
> other detailed information about porting to Android.

The builds location is described here:
  https://jogamp.org/wiki/index.php/Android_Packages

The demos are simply JOAL/JOGL unit tests and hence
included in the JOAL/JOGL git repo.

You can find them by checking the
jogl/make/resources/android/AndroidManifest-test.xml

Further more .. Mark added some tooling / example
in jogl-demos which removes some project setup differences
and using maven .. i.e. project compile for desktop and android.

Hope this helps.

~Sven

>
> Thanks!
> Andy


signature.asc (911 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Migrate a Java application using Jogl to Android tablet

jedwards1211
Okay, great, I'll let you know how testing it goes.  Also, as a new JOGL user, I just wanted to say thanks!! It's a pretty incredible project.  I'm working on a game for desktop/Android.  Hopefully before long I'll have something cool to show!