floooh / sokol

minimal cross-platform standalone C headers
https://floooh.github.io/sokol-html5
zlib License
7.12k stars 501 forks source link

Why isn't SOKOL_NO_ENTRY supported on android? Is it impossible or just not implemented yet? #1015

Open creikey opened 8 months ago

creikey commented 8 months ago

Trying to decide between SOKOL_NO_ENTRY and linking to a DLL that has sokol functions from JAI, or figuring out how to somehow link to sokol in such a way that I define sokol_main and the header has the entry point. I'd like to do no entry but if that means no android then that's bad.

floooh commented 8 months ago

IIRC mainly because the Android entry code looks and works completely different then all other platforms.

Most importantly, Android doesn't have the C main function, but instead ANativeActivity_onCreate is the entry point, and ANativeActivity is entirely event based, so the sokol_app.h implementation of ANativeActivity_onCreate creates a thread and then hands off control to that thread (and the original main thread is dispatching events.

I guess one solution would be to move the code in ANativeActivity_onCreate into an _sapp_android_run() function and then when SOKOL_NO_ENTRY is defined not create our own ANativeActivity_onCreate, but instead depend on the user to build the Android-specific startup code, but I'm not sure how that could be hooked up to JAIs entry function.

Did you already solve the problem of hooking up ANativeActivity with JAI's entry point somehow? In that case we can experiment with the idea outlined above.