google / filament

Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WebGL2
https://google.github.io/filament/
Apache License 2.0
17.79k stars 1.89k forks source link

Support for Kotlin Native #1197

Open spencerelliott opened 5 years ago

spencerelliott commented 5 years ago

Describe the solution you'd like Adding support for Kotlin Native would allow developers to create a single codebase that supports iOS, Desktop, and Android. The code would be compiled to native code for each platform possibly increasing performance.

Describe alternatives you've considered It is currently possible to build macOS, PC, Android, and Linux apps using Kotlin. These platforms each require their own build to be performed, though. Apps for iOS need to be rewritten in C++.

bejado commented 5 years ago

I haven't explored Kotlin Native too deeply, but I think it's an interesting idea. Not sure how much additional work it would be given we already have JNI bindings.

romainguy commented 5 years ago

What support do you need added exactly?

spencerelliott commented 5 years ago

The cinterop tool would need to be run on the Filament codebase. This would generate an interface between the native code and Kotlin Native. From there, I believe work would have to be done to build a stable API for each platform to pass in a valid surface using the expect/actual mechanism.

Additionally, it would be nice to have it available as a Multiplatform library through Maven. Kotlin Native has support for publishing artifacts. This may be a separate ticket, though.

honza-vanek commented 4 years ago

Filament is such a great piece of work; this would make it a killer lib. Any news on the issue? We are currently starting a rewrite of an AR app running on iOS to support Android and multiplatform kotlin-native is the way to go. The possibility to use filament would be fantastic

romainguy commented 4 years ago

I agree supporting Kotlin Native would be fantastic. Unfortunately it is not a priority at this point. To do this properly we first need to find a scalable and sustainable way to support all the different language bindings since this would at least require to recreate the Java APIs in Kotlin.

That said a possible workaround for you right now would be to start from our JNI binding as a base for a C API for Filament. This should be usable with Kotlin.

unicomp21 commented 4 years ago

FYI https://kotlinlang.org/docs/reference/native/c_interop.html

honza-vanek commented 4 years ago

Thank you for the fast answers, sorry to hear that, will try to find some other way... Good luck with filament and thanks for all the work

chris-hatton commented 4 years ago

...another developer here whose cross-platform 3D dreams have been stopped dead in their tracks by the realisation that Kotlin/Native can't currently use Filament due to incompatibility with C-interop tool. Filament is a fabulous piece of work, would be a great 'force multiplier' to have these bindings available so it can be used as a Kotlin/Multiplatform library & beyond.

honza-vanek commented 4 years ago

Actually nope, they haven't. We have simply written a cross-platform renderer ourselves. Half a year delay but it's done :)

romainguy commented 4 years ago

@chris-hatton I understand but we just don't have resources to spare on this at the moment :(