Running a libGDX-kotlin app in the browser
Written by Coen Rijsdijk
We have developed several apps in Kotlin with libGDX.
I am doing a research traineeship to make it run in the browser, and will share findings here. In my research I come across many different possibilities, some of which are useful,
but others have limitations that are not handy. I elaborate this further below.
With kotlin native you can’t use Java code. Also WebGL can’t be used in combination with compiled Kotlin Native for WebAssembly.
JWebAssembly didn’t look quite right yet, lack of activity, no community platform.
But finally after a lot of research and trials, I have reached a possible solution; Bytecoder. Bytecoder looks vibrant, fits well within our existing code base. Also Bytecoder supports WASM, which TeaVM can’t properly yet.
After I verified the most important parts and functions in the app I started trying out different Web API’s. The first focus was on audio, then WebGL as this is a very important part within the app. With the documentation about WebGL from Mozilla I started to get basic understanding.
So I started setting up a project simply by making a small example which can print a line in the console of the DOM. That went quite easily, so I started setting up tasks together with Kees to make a Bytecoder backend for LibGDX. All the issues we created during the whole process can be found here.
The first error we encountered occurred quite quickly, a spritebatch instantiation crashed. A method inside Bytecoder was missing, we reported the issue at Bytecoder: https://github.com/mirkosertic/Bytecoder/issues/467. Because we wanted to proceed quickly, we cloned Bytecoder locally and added the missing method by ourselves. Then we submitted this again as a pull request and asked if the maintainer would accept it.
More coming soon.Posted in: Apps Web
Kees van Dieren, CEO
We've years of experience helping startups and scale-ups to work more efficient by creating apps that are fit their needs.
Let’s talk. We look forward to exploring the opportunity to help your company too.
Go ahead and send us a message. We look forward to exploring the opportunity to help you too.