Hide the ugliness of JNI

This commit is contained in:
Patrick Nicolas
2023-11-26 16:57:51 +01:00
parent 10fa78c21c
commit 31bd160749
4 changed files with 319 additions and 112 deletions
+3 -31
View File
@@ -49,38 +49,9 @@ struct application_info
#endif
};
class application;
#ifdef XR_USE_PLATFORM_ANDROID
class jni_thread
{
JNIEnv * env = nullptr;
JavaVM * vm = nullptr;
public:
explicit jni_thread(application & app);
jni_thread();
~jni_thread();
JNIEnv * get_JNIEnv()
{
return env;
}
};
#else
class [[maybe_unused]] jni_thread
{
public:
explicit jni_thread(application & app) {}
jni_thread() = default;
~jni_thread() = default;
};
#endif
class application
{
friend class scene;
friend class jni_thread;
application_info app_info;
#ifdef XR_USE_PLATFORM_ANDROID
@@ -108,8 +79,6 @@ class application
static application * instance_;
jni_thread jni;
// OpenXR stuff
xr::instance xr_instance;
xr::system xr_system_id;
@@ -306,6 +275,9 @@ public:
application(const application &) = delete;
~application();
#ifdef XR_USE_PLATFORM_ANDROID
void setup_jni();
#endif
static bool is_session_running()
{