javagl / JglTF

Java libraries related to glTF
MIT License
209 stars 61 forks source link

Android support #117

Open javagl opened 2 months ago

javagl commented 2 months ago

There have been several issues asking about Android support. I'm not nearly up to date with the latest state of Android and this "API Level" concept there. This issue is intended for tracking any changes that may be required (or helpful) when trying to get JglTF running under Android.

One project where @mikikg used JglTF in Android is https://github.com/mikikg/AndroidJgltfViewer . I never managed to take a look at the actual changes that have been done there, and how they could be re-integrated into JglTF. But it may be a starting point for someone who wants to address this, and maybe even open a dedicated PR for Android support here.

BenManwaring commented 1 month ago

Hi,

I've kinda started looking into this but I can't guarantee how quickly it will progress, I'm sharing here incase anyone picks it up before I progress the work any further.

I started by working out what commit I thought the code was copied from for https://github.com/mikikg/AndroidJgltfViewer, it seems to have been based upon https://github.com/javagl/JglTF/commit/82bb96b0064732436fdc9e771bdbe717a2b8d8f2.

So what I have done is made a branch of a fork of this repo with the code changes merged back in, they had been reformatted and the newline character changed but I think I got them all, it needs tidying to minimise the changes further but it is a starting point. I have also added the Android build project and relative simlinked the files into (I'm sure there is probably a better integration possible between Maven and Gradle but this works for now).

The code can be found here: https://github.com/BenManwaring/JglTF/pull/1

it will need updating to use the latest master from this repo and the code improving/solving the TODOs, maturing and making production ready but I hope this serves to at least expose what changes were done by https://github.com/mikikg to make an initial Android version.

All thanks goes to https://github.com/mikikg for these initial changes, I have merely moved code around.

javagl commented 1 month ago

Thanks @BenManwaring

I have not yet thought about an actual strategy for this. There are certainly different approaches, and which one works "best" is hard to say beforehand. (Specifically: It would require knowledge about the Android build systems and depdendency management that I don't have - for example, I think that ~"this has to use gradle (somehow)", but I don't know anything about the details there).

If I had to tackle this now, my approach would have been roughly

The last step refers to the fact that there seem to be files like jgltf-android/app/src/main/res/mipmap-xhdpi/ic_launcher.png of which I hope/think that they don't have to be tracked in Git.

And the "refactorings" refers to the fact that I think that there had been some classes used in JglTF that had not been available in Android a few years ago. (I think that something like BufferedImage did not exist back then). So it may be necessary to split some packages into jgltf-...-desktop and jgltf-...-mobile/android or so.


Again: This may not be the smartest way to do this. Maybe updating the state from your PR with the latest master from JglTF could be easier. But ... I don't know whether there have been changes made in AndroidJgltfViewer that could cause merge conflicts.

So... to summarize...:

I've kinda started looking into this but I can't guarantee how quickly it will progress

Same here....