I’ve been using some time recently to learn WebGL and cross platform development with Kotlin. Ultimately I want to be able to use OPENRNDR in the browser, and maybe as a native compiled code in the future. I learned that cross platform Kotlin libraries have to adhere to certain standards. For example there should be no dependency on standard Java libraries, so no java.lang.Math
, StrictMath
, no Serializable
.
I made a small experiment to compile openrndr-math
to JavaScript:
It worked and I can actually already start doing some nice creative coding experiments just with openrndr-math
. But I had to do some small modifications, and I was not sure how to solve some issues, so I commented out part of the code. I also moved to kotlin native serialization. Here is the commit with all the modifications:
The JavaScript output is around 5kB after advanced optimizations and dead code removal with google closure compiler:
@edwin I would be interested in your opinion on how it can be pushed forward and if you think it’s realistic to change the code and packaging of some OPENRNDR modules to make them “Pure Kotlin” and cross platform?