kool-engine / kool

An OpenGL / WebGPU engine for Desktop JVM, Android and Javascript written in Kotlin
https://fabmax.github.io/kool/kool-js
Apache License 2.0
303 stars 20 forks source link

Physx JNI fix #35

Closed mqxf closed 1 year ago

mqxf commented 1 year ago

You probably got an email from my friend Julian about the engine and the jni not loading. I found the issue, in one of the enums which calls native functions upon initializing, it tries to do so before the static block that loads the native libraries. I know this is also an issue with physx jni, but the reason I post this here is because the simplest fix is when creating a KoolContext, it should call de.fabmax.physxjni.Loader.load() upon making the context, that way this issue does not occur.

fabmax commented 1 year ago

I will fix that on the physx-jni side. Auto-calling the loader on context creation is not possible because kool-physics is separated from kool-core, i.e. KoolContext has no access to physx-jni functions.

mqxf commented 1 year ago

Yeah, that works better, its just some dumb ClassLoader issue which loads enum declarations before static block.